From 3779cacfff125b99d4bd0483fac0f0e40ded4de9 Mon Sep 17 00:00:00 2001 From: zxstty Date: Tue, 10 Jun 2025 19:52:12 +0800 Subject: [PATCH] =?UTF-8?q?rpm=E6=A8=A1=E5=BC=8F=E4=B8=8Bnginx=E7=9A=84con?= =?UTF-8?q?fig=E5=A2=9E=E5=8A=A0=E5=AF=B9witchaind=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/linux/nginx.conf.local.tmpl | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/build/linux/nginx.conf.local.tmpl b/build/linux/nginx.conf.local.tmpl index a7a3d140..8c6b7d7d 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; -- Gitee