nginx.conf 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # lq_label 前端 Nginx 配置
  2. # 将此文件复制到 Nginx 配置目录,或 include 到主配置中
  3. server {
  4. listen 80;
  5. server_name localhost; # 修改为你的域名
  6. # 前端静态文件目录
  7. # 根据实际部署路径修改
  8. root /path/to/lq_label/dist/apps/lq_label;
  9. index index.html;
  10. # Gzip 压缩
  11. gzip on;
  12. gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
  13. gzip_min_length 1000;
  14. # 静态资源缓存
  15. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
  16. expires 1y;
  17. add_header Cache-Control "public, immutable";
  18. }
  19. # API 代理到后端
  20. location /api/ {
  21. proxy_pass http://localhost:8003/;
  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. }
  27. # SPA 路由支持 - 所有路由返回 index.html
  28. location / {
  29. try_files $uri $uri/ /index.html;
  30. }
  31. # 错误页面
  32. error_page 500 502 503 504 /50x.html;
  33. location = /50x.html {
  34. root /usr/share/nginx/html;
  35. }
  36. }