Nginx反向代理FastAPI后端文件上传时出现net::ERR_HTTP2_PROTOCOL_ERROR错误求助
Nginx反向代理FastAPI后端文件上传时出现net::ERR_HTTP2_PROTOCOL_ERROR错误求助
大家好,我最近碰到了一个头疼的问题,想请各位大佬帮忙排查下。我在服务器上配置了Nginx作为反向代理,后端服务是用Python FastAPI开发的。现在尝试上传文件时,浏览器的网络面板里一直弹出错误:(failed)net::ERR_HTTP2_PROTOCOL_ERROR,试了几个调整都没解决,实在没头绪了。
下面是我的Nginx配置内容(部分输入内容截断,核心配置如下):
server { listen 443 ssl; server_name demo.snabup.com; gzip off; ssl_certificate somekey.pem; ssl_certificate_key someprivatekey.pem; client_max_body_size 50M; # 已调整允许的最大请求体大小 client_body_timeout 60s; client_header_timeout 60s; keepalive_timeout 60s; location / { proxy_pass http://localhost:3000; 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; } location /api/v1/ { proxy_pass http://localhost:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 后续配置内容被截断 } }
我已经设置了client_max_body_size来适配文件大小,也调整了超时参数,但还是没能解决这个HTTP2协议错误。有没有朋友遇到过类似的情况?或者能帮我分析下可能的原因和解决方向吗?
备注:内容来源于stack exchange,提问作者Tufail Ahmed
相关产品推荐
相关产品推荐

