server { listen 80; server_name localhost; # 静态文件根目录 root /usr/share/nginx/html; index index.html; # 禁用缓存 location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; add_header Expires "0"; try_files $uri $uri/ =404; } # 处理单页应用路由 location / { try_files $uri $uri/ /index.html; } error_page 404 /index.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }