lq_label.conf 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. server {
  2. listen 9003;
  3. server_name _;
  4. root /usr/share/nginx/html_app/lq_label;
  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://lq-label-backend:8000/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. # SPA 路由支持
  34. location / {
  35. try_files $uri $uri/ /index.html;
  36. }
  37. # 健康检查
  38. location /health {
  39. access_log off;
  40. return 200 "healthy\n";
  41. add_header Content-Type text/plain;
  42. }
  43. # 安全配置
  44. location ~ /\. {
  45. deny all;
  46. access_log off;
  47. log_not_found off;
  48. }
  49. }