【发布时间】:2021-12-06 05:45:44
【问题描述】:
大家好,我一直在尝试在亚马逊 aws ec2 实例上执行我们的 django 应用程序。一切正常,除了超过 60 秒的请求。这些请求会自动获得504 Gateway Time-out。我在安全组中为我的 EC2 实例配置了所有需要的端口。
我们正在使用 nginx,我的 nginx.conf 看起来像:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 3600s;
client_max_body_size 500M;
client_body_timeout 86400s;
client_header_timeout 86400s;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
proxy_connect_timeout 86400s;
proxy_send_timeout 86400s;
proxy_read_timeout 86400s;
send_timeout 86400s;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
我尝试使用keepalive_timeout,正如许多帖子所建议的那样,但它不起作用。也有很多帖子提到负载均衡器配置,但我什至没有使用负载均衡器,所以这应该与它无关。
如何管理我的实例以处理超过 60 秒的请求?
更新:
通过在 django 容器中搜索 server { } 块来解决(如 @jaygooby 建议的那样)。我修改了/etc/nginx/sites-enabled/mydjango 并将proxy_read_timeout 60m; 添加到我的````location / { }``` 块中。
【问题讨论】:
-
更改后是否重启了nginx?你需要重启它
-
@ErmiyaEskandary 是的,我确实重启了 nginx
标签: django amazon-web-services nginx amazon-ec2