新增部署脚本

This commit is contained in:
2025-12-21 17:57:31 +08:00
parent cfd12f01db
commit 3c102aaa7e
3 changed files with 133 additions and 1 deletions
+32 -1
View File
@@ -3,7 +3,7 @@
server {
listen 80;
server_name 101.200.208.45 localhost 127.0.0.1;
server_name 101.200.208.45;
# 前端应用路径
location /emotion-museum/ {
@@ -67,6 +67,37 @@ server {
rewrite ^(.*)$ $1/ permanent;
}
# 体验前端应用路径 (course-web)
location /course-of-life/ {
alias /data/www/course-of-life/;
# 启用目录索引(可选)
autoindex off;
# 处理 SPA 的 history 模式 (React Router)
# 所有非文件请求都重定向到 index.html
try_files $uri $uri/ /course-of-life/index.html;
# 设置缓存策略
# HTML 文件不缓存
location ~ \.html?$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
# 静态资源缓存 1 年
location ~ \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
add_header Cache-Control "public, max-age=31536000, immutable";
expires 1y;
}
}
# 处理不带末尾斜杠的 /course-of-life 请求
location = /course-of-life {
rewrite ^(.*)$ $1/ permanent;
}
# 后端 API 代理
location /api {
proxy_pass http://127.0.0.1:19089;