-
Notifications
You must be signed in to change notification settings - Fork 4
Upgrade nginx configuration to reduce 104 error #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,10 @@ | |
| # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
|
||
| worker_processes 1; | ||
| worker_processes 1; | ||
|
|
||
| events { | ||
| worker_connections 1024; | ||
| worker_connections 65535; | ||
| } | ||
|
Comment on lines
+18
to
22
|
||
|
|
||
| http { | ||
|
|
@@ -65,8 +65,21 @@ http { | |
| # allow 10.1.0.0/16; | ||
| # deny all; | ||
|
|
||
| {%- if MODEL_PROXY_URI %} | ||
| # Upstream keepalive pool for model-proxy. | ||
| # Reuses persistent connections and enables automatic stale-connection retry | ||
| # before nginx has committed to the client response -- eliminating the race | ||
| # that causes [Errno 104] Connection reset by peer under high concurrency. | ||
| upstream model_proxy_upstream { | ||
| server {{MODEL_PROXY_URI | replace('http://', '') | replace('https://', '')}}; | ||
| keepalive 32; | ||
| keepalive_requests 1000; | ||
| keepalive_timeout 60s; | ||
| } | ||
| {%- endif %} | ||
|
|
||
| server { | ||
| listen 80; | ||
| listen 80 backlog=4096; | ||
| server_name localhost; | ||
| client_max_body_size 0; # Disable checking of client request body size. | ||
| client_body_buffer_size 256M; | ||
|
|
@@ -84,7 +97,7 @@ http { | |
|
|
||
| {% if SSL_ENABLE %} | ||
| server { | ||
| listen 443 ssl; | ||
| listen 443 ssl backlog=4096; | ||
| server_name localhost; | ||
|
|
||
| ssl_certificate /root/{{CRT_NAME}}; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,10 @@ python3 /pylon-config/render.py | |||||||||||
| cp /root/nginx.conf /etc/nginx/nginx.conf | ||||||||||||
| cp /root/location.conf /etc/nginx/location.conf | ||||||||||||
|
|
||||||||||||
| # Increase TCP listen backlog to match nginx backlog=4096. | ||||||||||||
| # Requires NET_ADMIN capability; if it fails, fall back to OS default silently. | ||||||||||||
| sysctl -w net.core.somaxconn=4096 2>/dev/null || true | ||||||||||||
|
Comment on lines
+25
to
+26
|
||||||||||||
| # Requires NET_ADMIN capability; if it fails, fall back to OS default silently. | |
| sysctl -w net.core.somaxconn=4096 2>/dev/null || true | |
| # Note: Changing net.core.somaxconn may require sysctl permissions (e.g. pod securityContext.sysctls in Kubernetes), | |
| # not just NET_ADMIN. If this fails, log a warning and continue with the OS default. | |
| sysctl -w net.core.somaxconn=4096 >/dev/null 2>&1 || echo "Warning: Failed to set net.core.somaxconn=4096; ensure pod securityContext.sysctls is configured if backlog tuning is required." >&2 |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,156 @@ | ||||
| import random | ||||
| import string | ||||
| import time | ||||
| import asyncio | ||||
| from typing import List | ||||
|
||||
| from typing import List |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove the comments in Chinese
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and other places
Copilot
AI
Apr 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For OpenAI-style streaming responses, clients typically expect the id to remain stable across all chunks of a single completion. Generating a new id per chunk can break client-side correlation/assembling logic. Prefer generating one id per request and reusing it in all chunks (and optionally include consistent created metadata as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hard-codes
http://model_proxy_upstreameven whenMODEL_PROXY_URIishttps://...(the upstream definition strips both schemes). That will break TLS-to-upstream and can cause backend connection failures or unintended plaintext traffic. Preserve the upstream scheme (e.g., selecthttpvshttpsvia templating /map, and add the requiredproxy_ssl_*directives when using HTTPS).