AWS Elastic Beanstalk - python(AL2 上的 3.7)flask 应用程序的 nginx 配置
AWS Elastic Beanstalk - nginx configuration for python (3.7 on AL2) flask app
我正在尝试在带有 nginx 服务器的弹性 beantalk 上获得一个简单的烧瓶 (python) 应用程序 运行。
在我的 .ebextensions application.config 中使用以下配置,python 应用似乎可以正常启动:
option_settings:
"aws:elasticbeanstalk:container:python":
WSGIPath: application:application
gunicorn 似乎可以将自己绑定到应用程序 - 请参阅:
Nov 30 07:40:00 ip-172-31-19-88 web: [2021-11-30 07:40:00 +0000] [32041] [INFO] Starting gunicorn 20.1.0
Nov 30 07:40:00 ip-172-31-19-88 web: [2021-11-30 07:40:00 +0000] [32041] [INFO] Listening at: http://127.0.0.1:8000 (32041)
Nov 30 07:40:00 ip-172-31-19-88 web: [2021-11-30 07:40:00 +0000] [32041] [INFO] Using worker: gthread
Nov 30 07:40:00 ip-172-31-19-88 web: [2021-11-30 07:40:00 +0000] [32098] [INFO] Booting worker with pid: 32098
当我访问网络 url 时,浏览器挂起很长时间(几分钟),最终超时并显示“响应时间过长”。
我认为这与 NGINX 配置有关,没有正确代理请求 - 所以我尝试将以下内容添加到 .ebextensions/nginx/conf.d/myconf.conf
server {
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
但这似乎没有任何作用。
关于问题可能是什么的任何想法?我不确定它的 NGINX,但它确实出现在出现问题的那一层......网络服务器似乎不知道如何处理我的网络请求。
感谢您的帮助。
.ebextensions/nginx/conf.d/myconf.conf
是 不正确的路径 。在 AL2 上,如果要覆盖整个 nginx.conf.
,nginx should be customized 使用 .platform/nginx/conf.d/
或 .platform/nginx/nginx.conf
我正在尝试在带有 nginx 服务器的弹性 beantalk 上获得一个简单的烧瓶 (python) 应用程序 运行。
在我的 .ebextensions application.config 中使用以下配置,python 应用似乎可以正常启动:
option_settings:
"aws:elasticbeanstalk:container:python":
WSGIPath: application:application
gunicorn 似乎可以将自己绑定到应用程序 - 请参阅:
Nov 30 07:40:00 ip-172-31-19-88 web: [2021-11-30 07:40:00 +0000] [32041] [INFO] Starting gunicorn 20.1.0
Nov 30 07:40:00 ip-172-31-19-88 web: [2021-11-30 07:40:00 +0000] [32041] [INFO] Listening at: http://127.0.0.1:8000 (32041)
Nov 30 07:40:00 ip-172-31-19-88 web: [2021-11-30 07:40:00 +0000] [32041] [INFO] Using worker: gthread
Nov 30 07:40:00 ip-172-31-19-88 web: [2021-11-30 07:40:00 +0000] [32098] [INFO] Booting worker with pid: 32098
当我访问网络 url 时,浏览器挂起很长时间(几分钟),最终超时并显示“响应时间过长”。
我认为这与 NGINX 配置有关,没有正确代理请求 - 所以我尝试将以下内容添加到 .ebextensions/nginx/conf.d/myconf.conf
server {
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
但这似乎没有任何作用。
关于问题可能是什么的任何想法?我不确定它的 NGINX,但它确实出现在出现问题的那一层......网络服务器似乎不知道如何处理我的网络请求。
感谢您的帮助。
.ebextensions/nginx/conf.d/myconf.conf
是 不正确的路径 。在 AL2 上,如果要覆盖整个 nginx.conf.
.platform/nginx/conf.d/
或 .platform/nginx/nginx.conf