- 修复nginx配置中X-Forwarded-Proto使用错误的问题 - 将 $http_x_forwarded_proto 改为 $scheme - 适配IP直接访问的场景 - 添加client_max_body_size 10G 支持大文件上传 - 增加API代理超时时间配置 - 添加favicon.ico避免404错误 修复后分享链接可以正常访问 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
44 lines
1.3 KiB
Nginx Configuration File
44 lines
1.3 KiB
Nginx Configuration File
server {
|
||
listen 80;
|
||
server_name localhost;
|
||
|
||
# 设置最大上传文件大小为10GB
|
||
client_max_body_size 10G;
|
||
|
||
# 前端静态文件
|
||
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;
|
||
|
||
# 增加超时时间支持大文件上传
|
||
proxy_connect_timeout 300;
|
||
proxy_send_timeout 300;
|
||
proxy_read_timeout 300;
|
||
}
|
||
|
||
# 分享链接重定向
|
||
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;
|
||
}
|
||
}
|