| #!/bin/sh |
| set -e |
|
|
| echo "启动纯前端 PanSou Web 应用..." |
|
|
| |
| mkdir -p /var/log/nginx |
|
|
| |
| 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配置已生成" |
|
|
| |
| echo "启动Nginx服务..." |
| nginx -g "daemon off;" |
|
|