server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Node-RED 最新实时快照;必须放在通用 /api 代理之前 location = /api/realtime { proxy_pass http://nodered:1880/api/realtime; proxy_set_header Host $host; add_header Cache-Control "no-store"; } # 优化后端 API(同源 /api → backend 容器) location /api/ { proxy_pass http://backend:8077; proxy_set_header Host $host; } # Node-RED 实时数据 WebSocket(同源 /ws → nodered 容器) location /ws/ { proxy_pass http://nodered:1880; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; } # 展示页不缓存(改动即时生效);js 长缓存 location = /index.html { add_header Cache-Control "no-store"; } location = /config.html { add_header Cache-Control "no-store"; } location = /home.html { add_header Cache-Control "no-store"; } location = / { try_files /home.html =404; add_header Cache-Control "no-store"; } location ~* \.js$ { add_header Cache-Control "public, max-age=86400"; } location / { try_files $uri $uri/ /index.html; } }