智慧水务管理系统 - 精河县供水工程综合管理平台

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. server {
  2. listen 80;
  3. server_name localhost;
  4. root /usr/share/nginx/html;
  5. index index.html;
  6. # Gzip 压缩
  7. gzip on;
  8. gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
  9. gzip_min_length 1024;
  10. # 前端路由 (Vue Router History 模式)
  11. location / {
  12. try_files $uri $uri/ /index.html;
  13. }
  14. # 静态资源缓存
  15. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
  16. expires 30d;
  17. add_header Cache-Control "public, immutable";
  18. }
  19. # API 反向代理到网关
  20. location /api/ {
  21. proxy_pass http://wm-gateway:8080/;
  22. proxy_set_header Host $host;
  23. proxy_set_header X-Real-IP $remote_addr;
  24. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  25. proxy_set_header X-Forwarded-Proto $scheme;
  26. proxy_read_timeout 300s;
  27. proxy_connect_timeout 75s;
  28. }
  29. # WebSocket 代理
  30. location /ws/ {
  31. proxy_pass http://wm-gateway:8080/ws/;
  32. proxy_http_version 1.1;
  33. proxy_set_header Upgrade $http_upgrade;
  34. proxy_set_header Connection "upgrade";
  35. proxy_set_header Host $host;
  36. proxy_read_timeout 3600s;
  37. }
  38. # 健康检查
  39. location /health {
  40. access_log off;
  41. return 200 "OK";
  42. add_header Content-Type text/plain;
  43. }
  44. }