nginx.conf 635 B

123456789101112131415161718192021222324252627
  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. error_page 404 /index.html;
  19. error_page 500 502 503 504 /50x.html;
  20. location = /50x.html {
  21. root /usr/share/nginx/html;
  22. }
  23. }