This commit is contained in:
2026-02-03 19:37:58 +08:00
parent 8ffe3e0e15
commit db4a0b109c
42 changed files with 6594 additions and 183 deletions

View File

@@ -0,0 +1,27 @@
server {
listen 80;
server_name _; # 匹配所有域名,适合容器化部署
root /usr/share/nginx/html; # Nginx静态资源根目录和Dockerfile拷贝路径一致
index index.html index.htm; # 默认入口文件
# 客户端最大请求体大小,适配文件上传等场景
client_max_body_size 100M;
# 核心解决前端Vue/React/Angular等SPA的history模式路由刷新404问题
location / {
try_files $uri $uri/ /index.html;
}
# 全局禁用缓存:禁止浏览器/代理服务器缓存任何资源
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
add_header Surrogate-Control "no-store" always;
# 对所有静态资源单独强化无缓存配置,立即过期
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
try_files $uri =404; # 资源不存在直接返回404避免走index.html
expires -1; # 立即过期,优先级高于全局缓存配置
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
}
}