Spaces:
Running
Running
github-actions[bot] commited on
Commit ·
f037e20
1
Parent(s): 8379b30
deploy: 3113f4b — 更新 nginx.conf
Browse files- frontend/nginx.conf +79 -92
frontend/nginx.conf
CHANGED
|
@@ -1,109 +1,96 @@
|
|
| 1 |
-
user nginx;
|
| 2 |
worker_processes auto;
|
| 3 |
error_log /var/log/nginx/error.log warn;
|
| 4 |
pid /var/run/nginx.pid;
|
| 5 |
|
| 6 |
events {
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
multi_accept on;
|
| 10 |
}
|
| 11 |
|
| 12 |
http {
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
gzip on;
|
| 27 |
-
gzip_vary on;
|
| 28 |
-
gzip_proxied any;
|
| 29 |
-
gzip_comp_level 6;
|
| 30 |
-
gzip_types text/plain text/css text/xml application/json application/javascript
|
| 31 |
-
application/xml+rss application/atom+xml image/svg+xml;
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
}
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
server_name _;
|
| 56 |
-
|
| 57 |
-
client_max_body_size 100M;
|
| 58 |
-
proxy_read_timeout 300s;
|
| 59 |
-
proxy_connect_timeout 10s;
|
| 60 |
-
proxy_send_timeout 300s;
|
| 61 |
-
|
| 62 |
-
# ── OpenAI-compatible AI API endpoints (via LiteLLM) ──────────────
|
| 63 |
-
location /v1/ {
|
| 64 |
-
limit_req zone=v1 burst=50 nodelay;
|
| 65 |
-
|
| 66 |
-
proxy_pass http://litellm;
|
| 67 |
-
proxy_http_version 1.1;
|
| 68 |
-
proxy_set_header Host $host;
|
| 69 |
-
proxy_set_header X-Real-IP $remote_addr;
|
| 70 |
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 71 |
-
proxy_set_header X-Forwarded-Proto $scheme;
|
| 72 |
-
proxy_set_header Connection "";
|
| 73 |
-
|
| 74 |
-
# SSE / streaming support
|
| 75 |
-
proxy_buffering off;
|
| 76 |
-
proxy_cache off;
|
| 77 |
-
chunked_transfer_encoding on;
|
| 78 |
-
proxy_read_timeout 300s;
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
# ── Backend Management API ────────────────────────────────────────
|
| 82 |
-
location /api/ {
|
| 83 |
-
limit_req zone=api burst=20 nodelay;
|
| 84 |
-
|
| 85 |
-
proxy_pass http://backend;
|
| 86 |
-
proxy_http_version 1.1;
|
| 87 |
-
proxy_set_header Host $host;
|
| 88 |
-
proxy_set_header X-Real-IP $remote_addr;
|
| 89 |
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 90 |
-
proxy_set_header X-Forwarded-Proto $scheme;
|
| 91 |
-
proxy_set_header Connection "";
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
# ── Frontend SPA ──────────────────────────────────────────────────
|
| 95 |
-
# BUG FIX #12: Removed Upgrade / Connection "upgrade" headers.
|
| 96 |
-
# The frontend is a static React SPA served by nginx — it does not use
|
| 97 |
-
# WebSockets. Sending Upgrade headers to a plain HTTP upstream is
|
| 98 |
-
# incorrect. Connection "" clears the hop-by-hop header and enables
|
| 99 |
-
# HTTP/1.1 keepalive to the upstream frontend container.
|
| 100 |
-
location / {
|
| 101 |
-
proxy_pass http://frontend;
|
| 102 |
-
proxy_http_version 1.1;
|
| 103 |
-
proxy_set_header Host $host;
|
| 104 |
-
proxy_set_header X-Real-IP $remote_addr;
|
| 105 |
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 106 |
-
proxy_set_header Connection "";
|
| 107 |
-
}
|
| 108 |
}
|
| 109 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
worker_processes auto;
|
| 2 |
error_log /var/log/nginx/error.log warn;
|
| 3 |
pid /var/run/nginx.pid;
|
| 4 |
|
| 5 |
events {
|
| 6 |
+
worker_connections 4096;
|
| 7 |
+
multi_accept on;
|
|
|
|
| 8 |
}
|
| 9 |
|
| 10 |
http {
|
| 11 |
+
include /etc/nginx/mime.types;
|
| 12 |
+
default_type application/octet-stream;
|
| 13 |
+
|
| 14 |
+
```
|
| 15 |
+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
| 16 |
+
'$status $body_bytes_sent "$http_referer" '
|
| 17 |
+
'"$http_user_agent" rt=$request_time';
|
| 18 |
+
|
| 19 |
+
access_log /var/log/nginx/access.log main;
|
| 20 |
+
|
| 21 |
+
sendfile on;
|
| 22 |
+
tcp_nopush on;
|
| 23 |
+
tcp_nodelay on;
|
| 24 |
+
keepalive_timeout 65;
|
| 25 |
+
gzip on;
|
| 26 |
+
gzip_vary on;
|
| 27 |
+
gzip_proxied any;
|
| 28 |
+
gzip_comp_level 6;
|
| 29 |
+
gzip_types text/plain text/css text/xml application/json application/javascript
|
| 30 |
+
application/xml+rss application/atom+xml image/svg+xml;
|
| 31 |
+
|
| 32 |
+
limit_req_zone $binary_remote_addr zone=api:10m rate=100r/m;
|
| 33 |
+
limit_req_zone $binary_remote_addr zone=v1:10m rate=200r/m;
|
| 34 |
+
|
| 35 |
+
upstream backend {
|
| 36 |
+
server backend:3001;
|
| 37 |
+
keepalive 32;
|
| 38 |
+
}
|
| 39 |
|
| 40 |
+
upstream litellm {
|
| 41 |
+
server litellm:4000;
|
| 42 |
+
keepalive 64;
|
| 43 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
upstream frontend {
|
| 46 |
+
server frontend:80;
|
| 47 |
+
keepalive 16;
|
| 48 |
+
}
|
| 49 |
|
| 50 |
+
server {
|
| 51 |
+
listen 80;
|
| 52 |
+
server_name _;
|
| 53 |
+
|
| 54 |
+
client_max_body_size 100M;
|
| 55 |
+
proxy_read_timeout 300s;
|
| 56 |
+
proxy_connect_timeout 10s;
|
| 57 |
+
proxy_send_timeout 300s;
|
| 58 |
+
|
| 59 |
+
location /v1/ {
|
| 60 |
+
limit_req zone=v1 burst=50 nodelay;
|
| 61 |
+
proxy_pass http://litellm;
|
| 62 |
+
proxy_http_version 1.1;
|
| 63 |
+
proxy_set_header Host $host;
|
| 64 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 65 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 66 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
| 67 |
+
proxy_set_header Connection "";
|
| 68 |
+
proxy_buffering off;
|
| 69 |
+
proxy_cache off;
|
| 70 |
+
chunked_transfer_encoding on;
|
| 71 |
+
proxy_read_timeout 300s;
|
| 72 |
}
|
| 73 |
|
| 74 |
+
location /api/ {
|
| 75 |
+
limit_req zone=api burst=20 nodelay;
|
| 76 |
+
proxy_pass http://backend;
|
| 77 |
+
proxy_http_version 1.1;
|
| 78 |
+
proxy_set_header Host $host;
|
| 79 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 80 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 81 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
| 82 |
+
proxy_set_header Connection "";
|
| 83 |
}
|
| 84 |
|
| 85 |
+
location / {
|
| 86 |
+
proxy_pass http://frontend;
|
| 87 |
+
proxy_http_version 1.1;
|
| 88 |
+
proxy_set_header Host $host;
|
| 89 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 90 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 91 |
+
proxy_set_header Connection "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
}
|
| 93 |
}
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
}
|