Files

35 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

# Nginx 示例:部署 npm run build:prod 后的 dist 目录
# 将本文件复制到服务器,修改 root 路径和 server_name 后 include 或替换站点配置
server {
listen 80;
server_name jfplat.suzhouyuqi.com;
# 重要root 必须指向「包含 index.html 和 static 目录」的目录(即整个 dist
# 例如部署到 /var/www/jfplat 时,应把 dist 里的内容放到该目录:
# index.html 在 /var/www/jfplat/index.html
# static/ 在 /var/www/jfplat/static/
root /var/www/jfplat;
index index.html;
# 先尝试作为文件,再作为目录,最后回退到 index.htmlSPA 路由)
location / {
try_files $uri $uri/ /index.html;
}
# 可选:静态资源缓存
location /static/ {
expires 7d;
add_header Cache-Control "public, immutable";
}
# 可选API 反向代理(若前端直接请求同域 api
# location /api/ {
# proxy_pass http://jfplatapi.suzhouyuqi.com;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# }
}