【问题标题】:504 Gateway Time-out nginx/1.10.3 (Ubuntu)504 网关超时 nginx/1.10.3 (Ubuntu)
【发布时间】:2019-12-02 23:24:33
【问题描述】:

我正在尝试使用 Nginx 在 ubuntu 16.4 服务器上托管 django 1.11 应用程序。 但是在运行服务器后,我得到了504 Gateway Time-out

这是我的所有端口日志

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      3209/redis-server 1
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      15218/nginx -g daem
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1204/sshd
tcp6       0      0 :::9200                 :::*                    LISTEN      28810/java
tcp6       0      0 :::9300                 :::*                    LISTEN      28810/java
tcp6       0      0 :::22                   :::*                    LISTEN      1204/sshd
udp        0      0 0.0.0.0:68              0.0.0.0:*                           963/dhclient

command=/home/ubuntu/miniconda3/envs/ok/bin/gunicorn --access-logfile - --workers 3 --limit-request-line 8000 --bind unix:/home/ubuntu/app/socks/ok.sock configuration.wsgi:application
directory=/home/ubuntu/app/onekkom/backend
user=ubuntu
group=www-data
chmod=664
autostart=true
autorestart=true
stderr_logfile=/var/log/ok_prod_gunicorn.err.log
stdout_logfile=/var/log/ok_prod_gunicorn.out.log

Nginx 错误日志

*1 读取时上游超时(110:连接超时) 来自上游的响应标头,客户端:118.179.95.25,服务器: 18.136.204.142,要求$

2019/07/24 18:13:13 [错误] 15221#15221: *1 上游超时 (110: 连接超时)同时从上游读取响应头, 客户端:118.179.95.25,服务器:18.136.204.142,requ$

2019/07/24 18:20:17 [错误] 15485#15485: *1 上游超时 (110: 连接超时)同时从上游读取响应头, 客户端:118.179.95.25,服务器:18.136.204.142,requ$

有人对这个问题有任何想法吗?任何形式的帮助将不胜感激

【问题讨论】:

  • 此处可能重复检查:stackoverflow.com/questions/18740635/…
  • 我已经尝试了所有给定的解决方案,但它不起作用,可能是它的 django 项目和您提供的链接是 php 应用程序的原因

标签: django nginx amazon-ec2 ubuntu-16.04 gunicorn


【解决方案1】:

Gunicorn 默认在 30 秒后超时。这很可能是 gunicorn 超时,而不是 nginx 超时。您可以在 gunicorn 设置中增加超时。通常,您可能希望对超过 30 秒的请求执行一些操作。

http://docs.gunicorn.org/en/stable/settings.html

【讨论】:

  • 添加--timeout INT 其中INT 是秒数
  • /home/ubuntu/env/bin/gunicorn --access-logfile - --workers 4 --timeout INT 30 --limit-request-line 8000 --bind unix:/home/ubuntu /onekkom/app.sock backend.configuration.wsgi:application 在这里,但它不工作
  • 只要使用--timeout 120INT就是在这种情况下用数字代替。此外,30 是默认值,因此将其设置为 30 不会有任何用处。
  • 在添加 '--timeout 120' 后显示 502 Bad Gateway
猜你喜欢
  • 2017-08-02
  • 2011-08-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-13
  • 2011-04-08
  • 2011-10-04
相关资源
最近更新 更多