sub_system_server.conf 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. server {
  2. listen 9100;
  3. server_name _;
  4. root /usr/share/nginx/html_app/sub_system;
  5. index index.html index.htm;
  6. # 如果请求根目录,重定向到 index.html
  7. location = / {
  8. try_files $uri $uri/ /index.html;
  9. }
  10. # 静态资源缓存
  11. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
  12. expires 1y;
  13. add_header Cache-Control "public, immutable";
  14. access_log off;
  15. }
  16. # HTML 文件不缓存
  17. location ~* \.html$ {
  18. expires -1;
  19. add_header Cache-Control "no-cache, no-store, must-revalidate";
  20. add_header Pragma "no-cache";
  21. }
  22. # API 代理(可选,如果需要代理到后端)
  23. location /api/ {
  24. proxy_pass http://SubSystemServer:8100/api/;
  25. proxy_set_header Host $host;
  26. proxy_set_header X-Real-IP $remote_addr;
  27. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  28. proxy_set_header X-Forwarded-Proto $scheme;
  29. proxy_connect_timeout 30s;
  30. proxy_send_timeout 30s;
  31. proxy_read_timeout 30s;
  32. }
  33. # OAuth 代理
  34. location /auth/ {
  35. proxy_pass http://SubSystemServer:8100/auth/;
  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. # SPA 路由支持
  42. location / {
  43. try_files $uri $uri/ /index.html;
  44. }
  45. # 健康检查
  46. location /health {
  47. access_log off;
  48. return 200 "healthy\n";
  49. add_header Content-Type text/plain;
  50. }
  51. # 安全配置
  52. location ~ /\. {
  53. deny all;
  54. access_log off;
  55. log_not_found off;
  56. }
  57. }
  58. ~