# Emotion Museum 前端应用 Nginx 配置 # 配置路径: /www/server/panel/vhost/nginx/emotion-museum.conf server { listen 80; server_name 101.200.208.45 localhost 127.0.0.1; # 前端应用路径 location /emotion-museum/ { alias /data/www/emotion-museum/; # 启用目录索引(可选) autoindex off; # 处理 Vue Router 的 history 模式 # 所有非文件请求都重定向到 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"; } # 静态资源缓存 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; } } # 处理不带末尾斜杠的 /emotion-museum 请求 location = /emotion-museum { rewrite ^(.*)$ $1/ permanent; } # 后端 API 代理 location /api { proxy_pass http://127.0.0.1:19089; 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; # 超时设置 proxy_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s; } # WebSocket 代理 location /ws { proxy_pass http://127.0.0.1:19089; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; 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; # WebSocket 超时设置 proxy_connect_timeout 7d; proxy_send_timeout 7d; proxy_read_timeout 7d; } # 健康检查端点 location /health { access_log off; return 200 "healthy\n"; add_header Content-Type text/plain; } # 禁止访问敏感文件 location ~ /\. { deny all; access_log off; log_not_found off; } access_log /www/wwwlogs/access.log; }