Django(uwsgi)+ nginx 在 curl 请求时挂起

Django(uwsgi)+ nginx 在 curl 请求时挂起

我正在尝试调试一个问题,即使用 curl 执行的请求挂起。如果我通过任何 Web 浏览器打开网站,该网站都可以正常显示。我在日志文件中也找不到任何可疑的东西。

我已经启用日志记录error_log info;,但在 nginx 日志文件中没有看到任何内容。

以下是示例请求:

$ curl -v -o test.txt https://www.happyworld.bg
* Rebuilt URL to: https://www.happyworld.bg/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 172.104.135.164...
* Connected to www.happyworld.bg (172.104.135.164) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 604 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_256_GCM_SHA384

.... 证书信息 ... * ALPN,服务器接受使用 http/1.1

GET / HTTP/1.1 主机:www.happyworld.bg 用户代理:curl/7.47.0 接受:/

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0< HTTP/1.1 200 OK
< Server: nginx/1.13.6
< Date: Thu, 30 Aug 2018 14:18:56 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 32484
< Connection: keep-alive
< Vary: Cookie
< X-Frame-Options: SAMEORIGIN
< Cache-Control: max-age=600
< Expires: Thu, 30 Aug 2018 14:28:56 GMT
< Strict-Transport-Security: max-age=63072000; includeSubdomains
< X-Frame-Options: DENY
< X-Content-Type-Options: nosniff
< 
{ [15988 bytes data]
 74 32484   74 24037    0     0   2563      0  0:00:12  0:00:09  0:00:03 

过了一段时间我得到:

* Closing connection 0
curl: (18) transfer closed with 8447 bytes remaining to read

进入应用程序日志文件,我只能看到:

[pid: 12406|app: 0|req: 1/1] ........... () {42 vars in 486 bytes} [Thu Aug 30 14:15:03 2018] GET / => generated 24037 bytes in 85 msecs (HTTP/1.1 200) 6 headers in 193 bytes (1 switches on core 0)

以下是虚拟块配置的示例:

upstream wagtail { server 127.0.0.1:3002; }

location @CMS {
  include /etc/nginx/uwsgi_params;
  uwsgi_pass wagtail;
  uwsgi_param Host $host;
  uwsgi_param X-Real-IP $remote_addr;
  uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
  uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
}

有任何线索可以知道是什么原因造成的或者我是否遗漏了什么?

相关内容