Files
web/deploy/web/default.conf

60 lines
1.9 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.
# 与 nginx/web.conf 保持同步compose 挂载到 web 容器
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
# 域名/微信等验证文件:由外层 yh_nginx443直接 root /verify-root 提供,本容器不再挂载 verify-root
# 静态资源必须真实存在,避免错误回退成 index.html 导致白屏
location ^~ /assets/ {
try_files $uri =404;
access_log off;
expires 7d;
add_header Cache-Control "public, immutable";
}
# SPA 入口:勿长期缓存,否则发版后用户仍可能拿到旧 index
location = /index.html {
add_header Cache-Control "no-cache, no-store, must-revalidate";
expires -1;
}
# web/public 挂载到 /var/www/yh-public与 dist 根目录同 URL如 /logo.png优先读挂载无则回退 dist
location ~ ^/([^/]+\.(?:png|jpe?g|gif|ico|svg|webp|webmanifest))$ {
root /var/www/yh-public;
try_files /$1 @dist_root_public;
expires 7d;
add_header Cache-Control "public, max-age=604800";
}
location @dist_root_public {
root /usr/share/nginx/html;
try_files $uri =404;
expires 7d;
add_header Cache-Control "public, max-age=604800";
}
# web/public/social/ → 关注我们二维码等(挂载 /var/www/yh-public
location ^~ /social/ {
alias /var/www/yh-public/social/;
expires 7d;
add_header Cache-Control "public, max-age=604800";
}
# 推广素材:来自构建产物 deploy/web/dist/promotionpull-and-restart 从 web/promotion rsync后台上传走 /api/web/.../promotion-media/
location ^~ /promotion/ {
try_files $uri =404;
expires 7d;
add_header Cache-Control "public, max-age=604800";
}
location = / {
try_files /index.html =404;
}
# Vue SPA直接访问 /test 等路径须落到 index.html否则会 nginx 404
location / {
try_files $uri $uri/ /index.html;
}
}