Files
web/nginx/web.conf

46 lines
1.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 供 compose 中 web 容器使用:宿主机挂载 web/dist 与 verify-root仅提供静态与 SPA 回退
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
location ~ ^/([A-Za-z0-9._-]+\.(txt|html|xml))$ {
alias /verify-root/$1;
}
location ^~ /assets/ {
try_files $uri =404;
access_log off;
expires 7d;
add_header Cache-Control "public, immutable";
}
# web/public 挂载 /var/www/yh-public单段文件名同 dist 根 URL优先挂载后回退 dist
location ~ ^/([^/]+\.(?:png|jpe?g|gif|ico|svg|webp|webmanifest))$ {
root /var/www/yh-public;
try_files /$1 @dist_root_public;
}
location @dist_root_public {
root /usr/share/nginx/html;
try_files $uri =404;
}
location ^~ /social/ {
alias /var/www/yh-public/social/;
add_header Cache-Control "public, max-age=300";
}
location ^~ /promotion/ {
try_files $uri =404;
add_header Cache-Control "public, max-age=86400";
}
location = / {
try_files /index.html =404;
}
# 前台为 Vue SPA任意路径须回退到 index.html否则直接访问 /xxx 会得到 nginx 404
location / {
try_files $uri $uri/ /index.html;
}
}