2025-08-19 14:37:19 +08:00
|
|
|
|
upstream portal {
|
|
|
|
|
server 127.0.0.1:18880;
|
|
|
|
|
keepalive 32;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
server {
|
|
|
|
|
listen 18080;
|
|
|
|
|
server_name _;
|
|
|
|
|
|
2025-08-20 16:00:41 +08:00
|
|
|
|
root html;
|
|
|
|
|
|
|
|
|
|
error_page 404 /404.html;
|
|
|
|
|
|
|
|
|
|
error_page 500 /50x.html?error=500;
|
|
|
|
|
error_page 502 /50x.html?error=502;
|
|
|
|
|
error_page 503 /50x.html?error=503;
|
|
|
|
|
error_page 504 /50x.html?error=504;
|
|
|
|
|
|
2025-08-19 14:37:19 +08:00
|
|
|
|
gzip on;
|
|
|
|
|
gzip_min_length 1k;
|
|
|
|
|
gzip_comp_level 9;
|
|
|
|
|
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
|
|
|
|
|
gzip_vary on;
|
|
|
|
|
gzip_disable "MSIE [1-6]\.";
|
|
|
|
|
|
2025-08-20 16:00:41 +08:00
|
|
|
|
# 传递用户请求的原始Host(域名或IP+端口)
|
|
|
|
|
# proxy_set_header Host $host;
|
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
|
# 传递用户真实IP
|
2025-08-19 14:37:19 +08:00
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
2025-08-20 16:00:41 +08:00
|
|
|
|
# 传递真实IP,包含整个代理链路的IP信息
|
2025-08-19 14:37:19 +08:00
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
2025-08-20 16:00:41 +08:00
|
|
|
|
# 传递用户请求的原始协议 (http 或 https)
|
2025-08-19 14:37:19 +08:00
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
2025-08-20 16:00:41 +08:00
|
|
|
|
# 用户原始的Cookie等完整请求头
|
|
|
|
|
proxy_set_header Cookie $http_cookie;
|
2025-08-19 14:37:19 +08:00
|
|
|
|
|
|
|
|
|
add_header X-Content-Type-Options "nosniff";
|
|
|
|
|
add_header X-Frame-Options "SAMEORIGIN";
|
|
|
|
|
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Connection "";
|
2025-08-20 16:00:41 +08:00
|
|
|
|
proxy_read_timeout 10s;
|
2025-08-19 14:37:19 +08:00
|
|
|
|
proxy_connect_timeout 5s;
|
2025-08-20 16:00:41 +08:00
|
|
|
|
proxy_send_timeout 10s;
|
2025-08-19 14:37:19 +08:00
|
|
|
|
|
|
|
|
|
proxy_buffering off;
|
|
|
|
|
|
|
|
|
|
location = / {
|
|
|
|
|
rewrite ^ /home permanent;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-20 16:00:41 +08:00
|
|
|
|
location = /404.html {
|
|
|
|
|
root html;
|
|
|
|
|
internal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location = /50x.html {
|
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
|
internal;
|
|
|
|
|
|
|
|
|
|
proxy_set_header X-Original-URI $request_uri;
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-19 14:37:19 +08:00
|
|
|
|
location / {
|
|
|
|
|
proxy_pass http://portal/;
|
2025-08-20 16:00:41 +08:00
|
|
|
|
proxy_intercept_errors on;
|
2025-08-19 14:37:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /assets/ {
|
|
|
|
|
proxy_pass http://portal/assets/;
|
|
|
|
|
expires 30d;
|
|
|
|
|
access_log off;
|
2025-08-20 16:00:41 +08:00
|
|
|
|
proxy_intercept_errors on;
|
2025-08-19 14:37:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /api/ {
|
|
|
|
|
proxy_pass http://portal/api/;
|
|
|
|
|
client_max_body_size 100M;
|
2025-08-20 16:00:41 +08:00
|
|
|
|
proxy_intercept_errors on;
|
2025-08-19 14:37:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /dev-api/ {
|
|
|
|
|
proxy_pass http://portal/dev-api/;
|
|
|
|
|
client_max_body_size 100M;
|
2025-08-20 16:00:41 +08:00
|
|
|
|
proxy_intercept_errors on;
|
2025-08-19 14:37:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|