首页 > 解决方案 > 与 dokku 和 hasura 的“上游过早关闭连接”

问题描述

当通过 nginx 向 Dokku 上托管的 Hasura 发送 2.7mb 有效负载(较小的有效负载工作正常)时,我收到一个 502 给客户端,并且在内部出现以下错误:

root@api-dev:/# dokku nginx:error-logs hasura
[error] 44443#44443: *19 upstream prematurely closed connection while reading response header from upstream, client: 103.75.204.31, server: xxx.yyy.net.au, request: "POST /v1/graphql HTTP/1.1", upstream: "http://172.17.0.3:8080/v1/graphql", host: "xxx.yyy.net.au"

172.17.0.3 是 hasura 应用程序:

root@api-dev:/# dokku network:report hasura
=====> hasura network information
       Network attach post create:    
       Network attach post deploy:    
       Network bind all interfaces:   false
       Network web listeners:         172.17.0.3:5000


root@api-dev:/# dokku nginx:report hasura
=====> hasura nginx information
       Nginx access log format:                                
       Nginx access log path:         /var/log/nginx/hasura-access.log
       Nginx bind address ipv4:                                
       Nginx bind address ipv6:       ::                       
       Nginx client max body size:                             
       Nginx disable custom config:   false                    
       Nginx error log path:          /var/log/nginx/hasura-error.log
       Nginx global hsts:             true                     
       Nginx computed hsts:           true                     
       Nginx hsts:                                             
       Nginx hsts include subdomains: true                     
       Nginx hsts max age:            15724800                 
       Nginx hsts preload:            false                    
       Nginx proxy buffer size:       4096                     
       Nginx proxy buffering:         on                       
       Nginx proxy buffers:           8 4096                   
       Nginx proxy busy buffers size: 8192                     
       Nginx proxy read timeout:      60s                      
       Nginx last visited at:         1619572196               
       Nginx x forwarded for value:   $remote_addr             
       Nginx x forwarded port value:  $server_port             
       Nginx x forwarded proto value: $scheme                  
       Nginx x forwarded ssl:                                  
root@api-dev:/# 

hasura 容器内没有错误,容器日志中的最后一行是 normal starting API server

{"type":"startup","timestamp":"2021-04-28T00:38:43.470+0000","level":"info","detail":{"kind":"server","info":{"time_taken":0.882082376,"message":"starting API server"}}}

我已经对有效载荷进行了计时,需要 18-29 秒才能显示上述错误。Dokku 在最小的 Vultr VPS (1gb ram) 上运行。

我已按照以下说明将 nginx 请求的最大大小增加到 50mb:dokku: 413 Request Entity Too Large

我尝试通过节点脚本发送,Postman 和我也得到了同样的错误,所以上游客户端不是问题 - 它必须是 Postman 和 nginx 之间的东西。

Vultr 端是否有代理会断开连接?没有负载平衡器、代理、网络配置等——只有 VPS。

有没有人有任何线索?谢谢

标签: nginxdokkuhasuravultr

解决方案


推荐阅读