92 lines
3.3 KiB
Plaintext
92 lines
3.3 KiB
Plaintext
server {
|
||
listen 80;
|
||
server_name localhost;
|
||
|
||
root /usr/share/nginx/html;
|
||
index index.html;
|
||
|
||
resolver ${RESOLVER} valid=30s ipv6=off;
|
||
|
||
# 压缩:nginx 官方镜像默认只压 text/html,等于把 2 MB 多的 JS 原样发给浏览器。
|
||
# 管理端首屏这些 chunk 压完能到原来的四分之一左右,这一条比省几个组件管用得多。
|
||
gzip on;
|
||
gzip_vary on;
|
||
gzip_comp_level 6;
|
||
gzip_min_length 1024;
|
||
gzip_proxied any;
|
||
gzip_types text/plain text/css text/xml text/javascript application/javascript
|
||
application/json application/xml application/xml+rss image/svg+xml
|
||
font/ttf font/otf application/font-woff application/font-woff2;
|
||
|
||
# 带 hash 的构建产物放心长缓存;index.html 每次回源,否则发版后拿旧包。
|
||
location /assets/ {
|
||
expires 30d;
|
||
add_header Cache-Control "public, immutable";
|
||
}
|
||
|
||
location = /index.html {
|
||
add_header Cache-Control "no-cache";
|
||
}
|
||
|
||
location / {
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
|
||
# MCP 工具入口:后端 McpController 只接受 POST /mcp。
|
||
# 缺这条会落到上面的 SPA location,nginx 对静态文件执行 POST 直接回 405。
|
||
location = /mcp {
|
||
set $backend_host __BACKEND_HOST__;
|
||
set $backend_port __BACKEND_PORT__;
|
||
proxy_pass http://$backend_host:$backend_port;
|
||
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_connect_timeout 10s;
|
||
proxy_read_timeout 360s;
|
||
proxy_send_timeout 360s;
|
||
}
|
||
|
||
# The system frontend prefixes canonical /sys paths with /api.
|
||
location /api/sys/ {
|
||
set $backend_host __BACKEND_HOST__;
|
||
set $backend_port __BACKEND_PORT__;
|
||
rewrite ^/api/(.*)$ /$1 break;
|
||
proxy_pass http://$backend_host:$backend_port;
|
||
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_connect_timeout 10s;
|
||
proxy_read_timeout 360s;
|
||
proxy_send_timeout 360s;
|
||
}
|
||
|
||
# CRM controllers already use /api as part of their canonical path.
|
||
location /api/ {
|
||
set $backend_host __BACKEND_HOST__;
|
||
set $backend_port __BACKEND_PORT__;
|
||
proxy_pass http://$backend_host:$backend_port;
|
||
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_connect_timeout 10s;
|
||
proxy_read_timeout 360s;
|
||
proxy_send_timeout 360s;
|
||
}
|
||
|
||
location /sys/ {
|
||
set $backend_host __BACKEND_HOST__;
|
||
set $backend_port __BACKEND_PORT__;
|
||
proxy_pass http://$backend_host:$backend_port;
|
||
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_connect_timeout 10s;
|
||
proxy_read_timeout 360s;
|
||
proxy_send_timeout 360s;
|
||
}
|
||
}
|