This commit is contained in:
2025-11-05 15:42:51 +08:00
parent 855d22f448
commit 283cfbbfc8
4 changed files with 382 additions and 25 deletions

View File

@@ -1,3 +1,9 @@
# WebSocket连接升级映射必须在server块之前定义
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# 80端口仅处理HTTP请求自动重定向到HTTPS
server {
@@ -46,21 +52,33 @@ server {
# 注意:这里的路径需要与前端 VUE_APP_BASE_API 配置一致
location /dev-api/ {
proxy_pass http://127.0.0.1:30313/; # 后端服务地址
# 请求头设置
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $server_name;
# WebSocket支持如果需要
# 请求体相关配置重要支持POST请求
proxy_set_header Content-Type $content_type;
proxy_set_header Content-Length $content_length;
proxy_pass_request_headers on;
proxy_pass_request_body on;
# HTTP版本和WebSocket支持
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Connection $connection_upgrade;
# 超时设置
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
# 请求缓冲设置(对大文件上传有用)
proxy_request_buffering on;1
client_max_body_size 100M;
}