Spaces:
Sleeping
Sleeping
Update nginx.conf
Browse files- nginx.conf +7 -15
nginx.conf
CHANGED
|
@@ -1,33 +1,27 @@
|
|
| 1 |
-
# 让 nginx 以非 root 用户运行,配合 Dockerfile 中的 appuser
|
| 2 |
user appuser;
|
|
|
|
| 3 |
worker_processes auto;
|
| 4 |
|
| 5 |
-
events {
|
| 6 |
-
worker_connections 1024;
|
| 7 |
-
}
|
| 8 |
|
| 9 |
http {
|
| 10 |
include mime.types;
|
| 11 |
default_type application/octet-stream;
|
| 12 |
|
| 13 |
-
sendfile on;
|
| 14 |
-
|
| 15 |
-
keepalive_timeout 65;
|
| 16 |
|
| 17 |
-
# 把日志放到 /tmp,避免权限问题
|
| 18 |
access_log /tmp/nginx/access.log;
|
| 19 |
error_log /tmp/nginx/error.log warn;
|
| 20 |
|
| 21 |
server {
|
| 22 |
-
|
| 23 |
-
listen 7860;
|
| 24 |
server_name _;
|
| 25 |
|
| 26 |
-
# 需要传大点请求体可放开
|
| 27 |
client_max_body_size 32m;
|
| 28 |
|
| 29 |
location / {
|
| 30 |
-
proxy_pass http://127.0.0.1:8000;
|
| 31 |
proxy_http_version 1.1;
|
| 32 |
|
| 33 |
proxy_set_header Host $host;
|
|
@@ -35,17 +29,15 @@ http {
|
|
| 35 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 36 |
proxy_set_header X-Forwarded-Proto $scheme;
|
| 37 |
|
| 38 |
-
# Cloudflare 等挑战/长响应:加大超时
|
| 39 |
proxy_connect_timeout 600s;
|
| 40 |
proxy_send_timeout 600s;
|
| 41 |
proxy_read_timeout 600s;
|
| 42 |
send_timeout 600s;
|
| 43 |
|
| 44 |
-
# SSE/流式
|
| 45 |
proxy_buffering off;
|
| 46 |
proxy_cache off;
|
| 47 |
-
proxy_set_header Connection "";
|
| 48 |
chunked_transfer_encoding off;
|
|
|
|
| 49 |
}
|
| 50 |
}
|
| 51 |
}
|
|
|
|
|
|
|
| 1 |
user appuser;
|
| 2 |
+
pid /tmp/nginx.pid;
|
| 3 |
worker_processes auto;
|
| 4 |
|
| 5 |
+
events { worker_connections 1024; }
|
|
|
|
|
|
|
| 6 |
|
| 7 |
http {
|
| 8 |
include mime.types;
|
| 9 |
default_type application/octet-stream;
|
| 10 |
|
| 11 |
+
sendfile on; tcp_nopush on; keepalive_timeout 65;
|
| 12 |
+
server_tokens off; underscores_in_headers on;
|
|
|
|
| 13 |
|
|
|
|
| 14 |
access_log /tmp/nginx/access.log;
|
| 15 |
error_log /tmp/nginx/error.log warn;
|
| 16 |
|
| 17 |
server {
|
| 18 |
+
listen 7860; # 必须与 App Port 一致
|
|
|
|
| 19 |
server_name _;
|
| 20 |
|
|
|
|
| 21 |
client_max_body_size 32m;
|
| 22 |
|
| 23 |
location / {
|
| 24 |
+
proxy_pass http://127.0.0.1:8000; # 同容器的 Uvicorn
|
| 25 |
proxy_http_version 1.1;
|
| 26 |
|
| 27 |
proxy_set_header Host $host;
|
|
|
|
| 29 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 30 |
proxy_set_header X-Forwarded-Proto $scheme;
|
| 31 |
|
|
|
|
| 32 |
proxy_connect_timeout 600s;
|
| 33 |
proxy_send_timeout 600s;
|
| 34 |
proxy_read_timeout 600s;
|
| 35 |
send_timeout 600s;
|
| 36 |
|
|
|
|
| 37 |
proxy_buffering off;
|
| 38 |
proxy_cache off;
|
|
|
|
| 39 |
chunked_transfer_encoding off;
|
| 40 |
+
proxy_set_header Connection "";
|
| 41 |
}
|
| 42 |
}
|
| 43 |
}
|