diff --git a/build/linux/nginx.conf.local.tmpl b/build/linux/nginx.conf.local.tmpl index a7a3d14043f2611dcec897ba28cc113aa8316316..8c6b7d7d19c0588bc3a07e485ad27a79921f3683 100644 --- a/build/linux/nginx.conf.local.tmpl +++ b/build/linux/nginx.conf.local.tmpl @@ -59,7 +59,54 @@ server { proxy_pass http://127.0.0.1:8002/api/; } + + location ~ ^/witchaind(/?)(.*)$ { + # 提取路径后缀 + set $path_suffix $1; + + # 转发请求到本地服务,保留路径结构 + proxy_pass http://127.0.0.1:9888/witchaind$path_suffix; + + # HTTP/1.1 支持 + proxy_http_version 1.1; + + # 代理请求头设置 + 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 Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + # 代理缓冲设置 + proxy_buffering on; + proxy_buffer_size 4k; + proxy_buffers 8 32k; + proxy_busy_buffers_size 64k; + + # 请求和响应超时设置 + proxy_connect_timeout 60s; + proxy_send_timeout 60s; + proxy_read_timeout 60s; + + # 跨域设置 + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; + add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; + + # 处理 OPTIONS 请求 + if ($request_method = 'OPTIONS') { + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; + add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; + add_header Access-Control-Max-Age 1728000; + add_header Content-Type 'text/plain charset=UTF-8'; + add_header Content-Length 0; + return 204; + } + } + error_page 401 402 403 405 406 407 413 414 /error.html; error_page 404 /404.html; error_page 500 501 502 503 504 505 /error.html;