server { listen 80; server_name localhost; root /www/wwwroot/your-domain.com; # 修改为实际网站目录 index index.html index.htm; # 开启gzip压缩 gzip on; gzip_vary on; gzip_min_length 1024; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon; # 前端路由支持(History模式) location / { try_files $uri $uri/ /index.html; } # API 代理到后端 location /api/ { proxy_pass http://172.22.0.1:8080/; 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 30s; proxy_send_timeout 900s; proxy_read_timeout 900s; # 支持大文件上传 client_max_body_size 600M; } # 静态资源缓存 location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; } # 禁止访问隐藏文件 location ~ /\. { deny all; access_log off; log_not_found off; } }