前端改进: - 添加axios上传请求30分钟超时配置 Nginx改进: - 增加代理超时时间到30分钟(1800秒) - 添加 proxy_request_buffering off 避免大文件缓存到磁盘 - 添加 proxy_buffering off 禁用响应缓冲 - 优化 client_body_buffer_size 修复 ERR_HTTP2_PING_FAILED / Network Error 问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
74 lines
2.2 KiB
Nginx Configuration File
74 lines
2.2 KiB
Nginx Configuration File
server {
|
||
listen 80;
|
||
server_name localhost;
|
||
|
||
# 设置最大上传文件大小为10GB
|
||
client_max_body_size 10G;
|
||
|
||
# 安全响应头
|
||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||
add_header X-Content-Type-Options "nosniff" always;
|
||
add_header X-XSS-Protection "1; mode=block" always;
|
||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||
|
||
# 隐藏Nginx版本
|
||
server_tokens off;
|
||
|
||
# 禁止访问隐藏文件和敏感文件
|
||
location ~ /\. {
|
||
deny all;
|
||
return 404;
|
||
}
|
||
|
||
location ~ \.(env|git|config|key|pem|crt)$ {
|
||
deny all;
|
||
return 404;
|
||
}
|
||
|
||
# 前端静态文件
|
||
location / {
|
||
root /usr/share/nginx/html;
|
||
index index.html;
|
||
try_files $uri $uri/ =404;
|
||
}
|
||
|
||
# 后端API反向代理
|
||
location /api/ {
|
||
proxy_pass http://backend:40001;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header 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;
|
||
# 修复:使用当前请求协议(http或https),适用于直接IP访问
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
proxy_cache_bypass $http_upgrade;
|
||
|
||
# Cookie传递配置(验证码session需要)
|
||
proxy_set_header Cookie $http_cookie;
|
||
proxy_pass_header Set-Cookie;
|
||
|
||
# 增加超时时间支持大文件上传(30分钟)
|
||
proxy_connect_timeout 1800;
|
||
proxy_send_timeout 1800;
|
||
proxy_read_timeout 1800;
|
||
send_timeout 1800;
|
||
|
||
# 大文件上传缓冲优化
|
||
proxy_request_buffering off;
|
||
proxy_buffering off;
|
||
client_body_buffer_size 128k;
|
||
}
|
||
|
||
# 分享链接重定向
|
||
location /s/ {
|
||
proxy_pass http://backend:40001;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
# 修复:使用当前请求协议(http或https),适用于直接IP访问
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
}
|
||
}
|