Django (uwsgi) + nginx 掛在curl 請求上

Django (uwsgi) + nginx 掛在curl 請求上

我正在嘗試調試使用curl 完成的請求掛起的問題。如果我透過任何網頁瀏覽器開啟網站,則該網站呈現良好。我在日誌檔案中也找不到任何可疑的內容。

我已啟用日誌記錄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;
}

任何線索可能是什麼原因造成的或我是否遺漏了什麼?

相關內容