ps / start.sh
xcolorday's picture
Update start.sh
9512377 verified
Raw
History Blame Contribute Delete
1.02 kB
#!/bin/sh
set -e
echo "启动纯前端 PanSou Web 应用..."
# 创建必要的目录
mkdir -p /var/log/nginx
# 生成Nginx配置(适配 7860 端口)
cat > /etc/nginx/http.d/default.conf << EOF
server {
listen 7860;
server_name localhost;
# 静态资源 - 启用缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
root /app/dist;
expires 30d;
add_header Cache-Control "public, max-age=2592000";
add_header X-Content-Type-Options nosniff;
}
# 前端应用 - SPA路由支持
location / {
root /app/dist;
index index.html;
try_files \$uri \$uri/ /index.html;
# 防止缓存HTML文件
location ~* \.html$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
}
}
EOF
echo "Nginx配置已生成"
# 启动nginx
echo "启动Nginx服务..."
nginx -g "daemon off;"