unis_crm/frontend/nginx/default.conf.template

70 lines
2.3 KiB
Plaintext
Raw Normal View History

server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
resolver ${RESOLVER} valid=30s ipv6=off;
# 静态资源:命中直接返回文件并长时间缓存;缺失返回 404绝不回退成 HTML
# 避免 CDN/网关把误回退的 index.html 当资源缓存造成 MIME 报错。
location /assets/ {
try_files $uri =404;
expires 1y;
add_header Cache-Control "public, max-age=31536000, immutable";
access_log off;
}
# index.html 不缓存,保证每次回源拿到最新 hash 引用。
location = /index.html {
add_header Cache-Control "no-cache";
}
location / {
try_files $uri $uri/ /index.html;
}
# 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;
2026-07-24 06:05:35 +00:00
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;
2026-07-24 06:05:35 +00:00
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;
2026-07-24 06:05:35 +00:00
proxy_read_timeout 360s;
proxy_send_timeout 360s;
}
}