nginx.conf 774 B

1234567891011121314151617181920212223242526272829303132
  1. server {
  2. listen 80;
  3. server_name localhost;
  4. # 静态文件根目录
  5. root /usr/share/nginx/html;
  6. index index.html;
  7. # 禁用缓存
  8. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
  9. add_header Cache-Control "no-cache, no-store, must-revalidate";
  10. add_header Pragma "no-cache";
  11. add_header Expires "0";
  12. try_files $uri $uri/ =404;
  13. }
  14. # 处理单页应用路由
  15. location / {
  16. try_files $uri $uri/ /index.html;
  17. }
  18. location /web {
  19. alias /usr/share/nginx/html;
  20. try_files $uri $uri/ /web/index.html; #解决页面刷新404问题
  21. }
  22. error_page 404 /index.html;
  23. error_page 500 502 503 504 /50x.html;
  24. location = /50x.html {
  25. root /usr/share/nginx/html;
  26. }
  27. }