server { listen 80 default_server; server_name _; charset utf-8; client_max_body_size 100m; absolute_redirect off; # Default entry for local debugging (serve cwos-portal as root shell) location = / { root /data/cwos/frontend/cwos-portal; try_files /index.html =404; } # root shell 使用 hash 路由,/login 统一跳转到 hash 登录页 location = /login { return 302 /#/login; } # SPA history fallback for root shell (e.g. /login, /home, /#/...) # Keep this after /api and other specific prefixes. location / { root /data/cwos/frontend/cwos-portal; try_files $uri $uri/ /index.html; } # root shell built assets are absolute /static/* location /static/ { alias /data/cwos/frontend/cwos-portal/static/; expires 7d; add_header Cache-Control "public"; try_files $uri =404; } location = /favicon.ico { alias /data/cwos/frontend/cwos-portal/favicon.ico; try_files $uri =404; } # front_acs (access control frontend) location /front_acs/ { alias /data/cwos/frontend/front_acs/; index index.html; try_files $uri $uri/ /front_acs/index.html; } # front_acs assets when served under /front_acs/ location /front_acs/static/ { alias /data/cwos/frontend/front_acs/static/; expires 7d; add_header Cache-Control "public"; try_files $uri =404; } # alarm-front location /alarm-front/ { alias /data/cwos/frontend/alarm-front/; index index.html; try_files $uri $uri/ /alarm-front/index.html; } # heat-analysis portal location /heat-analysis-portal/ { alias /data/cwos/frontend/heat-analysis-portal/; index index.html; try_files $uri $uri/ /heat-analysis-portal/index.html; } # API proxy to local V2 backend location /api/ { proxy_pass http://host.docker.internal:18081/api/; 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; } # Portal auth/captcha endpoints location /cwos-portal/ { proxy_pass http://host.docker.internal:18081/cwos-portal/; 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; } # Direct elevator API proxy location /elevator/ { proxy_pass http://host.docker.internal:18081/elevator/; 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; } }