|
- server {
- listen 80;
- server_name _;
- root /usr/share/nginx/html;
- index index.html;
-
- client_max_body_size 105m;
-
- gzip on;
- gzip_types text/plain text/css application/json application/javascript text/xml image/svg+xml;
- gzip_min_length 1024;
-
- location = /index.html {
- add_header Cache-Control "no-store";
- }
-
- location = /simulator {
- return 301 /simulator/;
- }
-
- location ^~ /simulator/ {
- proxy_pass http://emp-ws:3000/simulator/;
- 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;
- proxy_read_timeout 300s;
- }
-
- location ^~ /api/simulator/ {
- proxy_pass http://emp-ws:3000/api/simulator/;
- 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;
- proxy_read_timeout 300s;
- }
-
- location /api/ {
- proxy_pass http://emp-gateway:9000/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;
- proxy_read_timeout 300s;
- }
-
- location /socket.io/ {
- proxy_pass http://emp-ws:3000/socket.io/;
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
- proxy_set_header Host $host;
- proxy_read_timeout 300s;
- }
-
- # Grafana 监控:经本入口以 /grafana/ 子路径反代到监控栈(emp-mon 项目)的 grafana 容器。
- # 用 resolver + 变量 proxy_pass,grafana 未启动时仅此路径 502,不影响 nginx 启动与其他功能。
- # 需 grafana 容器(emp-mon-grafana)与本容器同网(emp-mon compose 已用 external 网络接入)。
- location ^~ /grafana/ {
- resolver 127.0.0.11 valid=10s ipv6=off;
- set $grafana_upstream emp-mon-grafana:3000;
- proxy_pass http://$grafana_upstream;
- 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_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
- proxy_read_timeout 300s;
- }
-
- location / {
- add_header Cache-Control "no-store";
- try_files $uri $uri/ /index.html;
- }
-
- location ~* \.(js|css)$ {
- expires -1;
- add_header Cache-Control "no-cache, no-store, must-revalidate";
- try_files $uri =404;
- }
-
- location ~* \.(png|jpg|jpeg|gif|ico|svg|woff2?|ttf|glb)$ {
- expires 30d;
- add_header Cache-Control "public, immutable";
- try_files $uri =404;
- }
- }
|