nginx.conf 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # 智裁云前端Nginx部署配置示例
  2. # 方案:同一域名子路径部署
  3. server {
  4. listen 80;
  5. server_name smartcut.example.com;
  6. # 系统管理后台
  7. location /platform {
  8. alias /var/www/smartcut/dist/platform-app;
  9. try_files $uri $uri/ /platform/index.html;
  10. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
  11. expires 1y;
  12. add_header Cache-Control "public, immutable";
  13. }
  14. }
  15. # 工厂管理后台
  16. location /factory {
  17. alias /var/www/smartcut/dist/factory-app;
  18. try_files $uri $uri/ /factory/index.html;
  19. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
  20. expires 1y;
  21. add_header Cache-Control "public, immutable";
  22. }
  23. }
  24. # 工人端
  25. location /worker {
  26. alias /var/www/smartcut/dist/worker-app;
  27. try_files $uri $uri/ /worker/index.html;
  28. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
  29. expires 1y;
  30. add_header Cache-Control "public, immutable";
  31. }
  32. }
  33. # 后端API代理
  34. location /api/ {
  35. proxy_pass http://127.0.0.1:8080;
  36. proxy_set_header Host $host;
  37. proxy_set_header X-Real-IP $remote_addr;
  38. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  39. proxy_set_header X-Forwarded-Proto $scheme;
  40. }
  41. # 健康检查
  42. location /health {
  43. proxy_pass http://127.0.0.1:8080;
  44. }
  45. # 监控端点
  46. location /metrics {
  47. proxy_pass http://127.0.0.1:8080;
  48. # 建议添加IP白名单限制
  49. # allow 10.0.0.0/8;
  50. # deny all;
  51. }
  52. # Gzip压缩
  53. gzip on;
  54. gzip_vary on;
  55. gzip_min_length 1024;
  56. gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
  57. }