# Nginx 服务器配置示例 # 使用方法:将此配置添加到你的 Nginx 配置文件中 server { listen 80; server_name your-domain.com; # 修改为你的域名 root /path/to/lottery-app/dist; # 修改为你的项目路径 index index.html; # Gzip 压缩配置 gzip on; gzip_vary on; gzip_min_length 1024; gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml+rss image/svg+xml; # HTML 文件不缓存 location / { try_files $uri $uri/ /index.html; add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; add_header Expires "0"; } # 静态资源长期缓存(带hash的JS、CSS、图片等) location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; access_log off; } # 代理 API 请求(如果需要) location /api/ { proxy_pass http://localhost:8123; # 修改为你的后端地址 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; } }