nginx - Apollo graphql 和 Nginx 的空响应
问题描述
我们的应用程序通过 Apollo、Express 和 Nest.js 公开了一个 graphql API。在 prod/staging 环境中,应用程序部署在 Nginx 入口(kubernetes)后面。API 在生产环境和kubectl port-forward
. 但是,当我们尝试使用 Nginx 背后的 API 时,当响应负载高于大约 1 KB 时,HTTP 响应会挂起(TCP 超时)。我们有一些结论:
- 应用程序正常工作(我们从日志中看到它正在返回正确的响应);
- 我们尝试增加 Nginx 代理缓冲区大小,但没有成功;
- 我们尝试在通常的 REST 端点(没有 graphql,只有 Nest.js 控制器)上返回相同的有效负载,并且成功了!
因此,这似乎是与作为代理的 Nginx 与 Apollo 服务器之间的集成有关的问题。有人对此有任何想法吗?
这是导致问题的 curl 请求的示例:
$ curl -v --location --request POST 'https://my-company.com/graphql' --header 'Content-Type: application/json' --data-raw '{"query":"query {\n myQueryHere \n}","variables":{}}'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying <my-ip-here>...
* TCP_NODELAY set
* Connected to my-company (my-ip-here) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: CN=*.mycompany.com
* start date: Dec 4 00:00:00 2019 GMT
* expire date: Jan 4 12:00:00 2021 GMT
* subjectAltName: host "my-company" matched cert's "*.my-company"
* issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
* SSL certificate verify ok.
> POST /graphql HTTP/1.1
> Host: my-company
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 159
>
* upload completely sent off: 159 out of 159 bytes
* TLSv1.2 (IN), TLS alert, Client hello (1):
* Empty reply from server
* Connection #0 to host my-company left intact
curl: (52) Empty reply from server
解决方案
推荐阅读
- python-3.x - 在 tkinter 中按下按钮时触发第二行代码
- derby - select 正在截断 ij 中的列名
- java - 无法获取文件类查找已存在的文件
- c# - how to use both the log writer and app insights within azure function?
- xamarin - How to don't open page select "Retry" or "OK" when take photo use library Plugin.Media on Xamarin Forms?
- mongodb - 如何遍历命名键并获取结果
- c# - 无法使用自定义 TypeConverter 反序列化
- reactjs - 不变违规:此导航器缺少导航道具
- ruby-on-rails - nil:NilClass 的未定义方法“人”
- hive - Hive - 即使使用“skip.header.line.count”=“1”,第一个表行也返回为 null