35 lines
942 B
Plaintext
35 lines
942 B
Plaintext
# 与 nginx/web.conf 保持同步;compose 挂载到 web 容器
|
||
server {
|
||
listen 80;
|
||
root /usr/share/nginx/html;
|
||
index index.html;
|
||
|
||
# 根路径下的验证文件走热加载目录
|
||
location ~ ^/([A-Za-z0-9._-]+\.(txt|html|xml))$ {
|
||
alias /verify-root/$1;
|
||
}
|
||
|
||
# 静态资源必须真实存在,避免错误回退成 index.html 导致白屏
|
||
location ^~ /assets/ {
|
||
try_files $uri =404;
|
||
access_log off;
|
||
expires 7d;
|
||
add_header Cache-Control "public, immutable";
|
||
}
|
||
|
||
# 推广素材:文件必须真实存在,禁止落到 SPA index.html(否则前端误判「静态存在」、视频拿到 HTML)
|
||
location ^~ /promotion/ {
|
||
try_files $uri =404;
|
||
add_header Cache-Control "public, max-age=86400";
|
||
}
|
||
|
||
location = / {
|
||
try_files /index.html =404;
|
||
}
|
||
|
||
# Vue SPA:直接访问 /test 等路径须落到 index.html,否则会 nginx 404
|
||
location / {
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
}
|