| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- server {
- listen 80;
- server_name localhost;
-
- root /usr/share/nginx/html;
- index index.html;
-
- # Gzip 压缩
- gzip on;
- gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
- gzip_min_length 1024;
-
- # 前端路由 (Vue Router History 模式)
- location / {
- try_files $uri $uri/ /index.html;
- }
-
- # 静态资源缓存
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
- expires 30d;
- add_header Cache-Control "public, immutable";
- }
-
- # API 反向代理到网关
- location /api/ {
- proxy_pass http://wm-gateway:8080/;
- 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;
- proxy_connect_timeout 75s;
- }
-
- # WebSocket 代理
- location /ws/ {
- proxy_pass http://wm-gateway:8080/ws/;
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
- proxy_set_header Host $host;
- proxy_read_timeout 3600s;
- }
-
- # 健康检查
- location /health {
- access_log off;
- return 200 "OK";
- add_header Content-Type text/plain;
- }
- }
|