AWS-错误504-网关超时-烧瓶应用程序 [英] AWS - Error 504 - Gateway timeout - Flask Application
本文介绍了AWS-错误504-网关超时-烧瓶应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
昨天,我在Amazon弹性豆茎上部署了我的第一个Fask应用程序。 APP正在工作,但当我按下启动刮除过程的按钮时出现问题。 此过程相当长,可能需要大约3/4分钟,很明显,从我按下按钮开始的一分钟后,我收到了504错误。
我在网上看了很多关于如何解决这个问题的文章,和nginx有关,但都不起作用。
这是我尝试过的内容:
1.EC2负载均衡 我已经创建了一个链接到我的实例的负载均衡器,并将空闲超时增加到300s。但是什么都没有改变。
2.向我的项目添加.eb扩展名 我还尝试在
内部使用my_name.conf修改nginx参数.ebextensions -> nginx -> conf.d -> my_name.conf
my_name.conf
keepalive_timeout 240s
proxy_read_timeout 240s;
proxy_send_timeout 240s;
proxy_connect_timeout 240s;
且仅在.ebextensions
proxy.config
container_commands:
01_reload_nginx:
command: 'sudo service nginx reload'
此解决方案均不起作用。
所以我尝试了另一种方法
在.ebextensions
中我创建了此文件,但未起作用,然后我尝试放入.ebextensions -> nginx
,但问题仍然存在。
proxy.config
files:
"/etc/nginx/conf.d/01-timeout.conf":
mode: "000644"
owner: root
group: root
content: |
keepalive_timeout 240s;
proxy_connect_timeout 240s;
proxy_send_timeout 240s;
proxy_read_timeout 240s;
fastcgi_send_timeout 240s;
fastcgi_read_timeout 240s;
container_commands:
nginx_reload:
command: "sudo service nginx reload"
我的项目结构是:
my_app
-> .ebextensions
->project (where there are python file with all the code)
->application.py (python file wiith main used to load all the file and launch the app)
->requirements.txt
你知道怎么解决这个问题吗? 提前感谢
推荐答案
您尝试使用的nginx
设置(/etc/nginx/conf.d/01-timeout.conf`)适用于Amazon Linux 1。
您可能使用的是Amazon Linux 2,其nginx设置应该在.platform/nginx/conf.d/
中,而不是在.ebextentions
中(请参阅docs)。
因此,您可以尝试以下.platform/nginx/conf.d/mytimeout.conf
内容:
keepalive_timeout 240s;
proxy_connect_timeout 240s;
proxy_send_timeout 240s;
proxy_read_timeout 240s;
fastcgi_send_timeout 240s;
fastcgi_read_timeout 240s;
这篇关于AWS-错误504-网关超时-烧瓶应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文