简体   繁体   English

ERR_CONNECTION_TIMED_OUT 同时使用 AWS 弹性豆茎部署 django(使用 nginx + gunicorn)

[英]ERR_CONNECTION_TIMED_OUT while deploying django using AWS elastic beanstalk(with nginx + gunicorn)

I'm facing ERR_CONNECTION_TIMED_OUT while deploying django using aws elastic beanstalk.我在使用 aws elastic beanstalk 部署 django 时面临 ERR_CONNECTION_TIMED_OUT。

Current status当前状态

  1. Console shows that it's properly deployed.控制台显示它已正确部署。 (shows OK status to me) (向我显示 OK 状态)
  2. Allow inbound traffic for security group.允许安全组的入站流量。

However, when I tried to connect instance using the url the elastic beanstalk provide, I've been always seeing ERR_CONNECTION_TIMED_OUT on chrome browser.但是,当我尝试使用弹性 beanstalk 提供的 url 连接实例时,我一直在 chrome 浏览器上看到 ERR_CONNECTION_TIMED_OUT。

Things I've tried.我尝试过的事情。

  1. Checked nginx log, and there's nothing printed out.检查了 nginx 日志,没有打印出来。 So I suspect that Load balancer didn't route request to nginx web server.所以我怀疑负载均衡器没有将请求路由到 nginx web 服务器。
tail -f /var/log/nginx/*
  1. Connected ec2 instance using ssh, and checked nginx running with port 80 and gunicorn running with port 8000使用 ssh 连接 ec2 实例,并检查 nginx 使用端口 80 运行和 gunicorn 使用端口 8000 运行
[ec2-user@ip-172-31-0-29 ~]$ sudo lsof -i -P -n | grep LISTEN
rpcbind  2650      rpc    8u  IPv4  16321      0t0  TCP *:111 (LISTEN)
rpcbind  2650      rpc   11u  IPv6  16324      0t0  TCP *:111 (LISTEN)
master   3130     root   13u  IPv4  18639      0t0  TCP 127.0.0.1:25 (LISTEN)
sshd     3328     root    3u  IPv4  20466      0t0  TCP *:22 (LISTEN)
sshd     3328     root    4u  IPv6  20475      0t0  TCP *:22 (LISTEN)
ruby     3475  healthd    6u  IPv4  22081      0t0  TCP 127.0.0.1:22221 (LISTEN)
nginx    4778     root    6u  IPv4 392465      0t0  TCP *:80 (LISTEN)
nginx    4780    nginx    6u  IPv4 392465      0t0  TCP *:80 (LISTEN)
gunicorn 4796   webapp    5u  IPv4 392820      0t0  TCP 127.0.0.1:8000 (LISTEN)
gunicorn 4806   webapp    5u  IPv4 392820      0t0  TCP 127.0.0.1:8000 (LISTEN)
gunicorn 4807   webapp    5u  IPv4 392820      0t0  TCP 127.0.0.1:8000 (LISTEN)
gunicorn 4808   webapp    5u  IPv4 392820      0t0  TCP 127.0.0.1:8000 (LISTEN)

Could anyone please help me to find out the issue?有人可以帮我找出问题吗? Thanks in advance!提前致谢!

Based on the comments.根据评论。

The issue turned out to be due to django setting : django.middleware.security.SecurityMiddleware :问题原来是由于django 设置django.middleware.security.SecurityMiddleware

The django.middleware.security.SecurityMiddleware provides several security enhancements to the request/response cycle. django.middleware.security.SecurityMiddleware 为请求/响应周期提供了多项安全增强功能。 Each one can be independently enabled or disabled with a setting.每个都可以通过设置独立启用或禁用。

Removal of the setting solved the problem.删除设置解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 nginx 设置 gunicorn,同时将 aws elastic beanstalk 用于 django 应用程序 - How to setup gunicorn with nginx while using aws elastic beanstalk for a django app AWS弹性豆茎+ Nginx + Gunicorn - AWS elastic beanstalk + Nginx + Gunicorn 使用 AWS Elastic Beanstalk 部署 Django 应用程序时出现 502 Bad Gateway nginx/1.20.0 错误 - 502 Bad Gateway nginx/1.20.0 Error when Deploying Django app using AWS Elastic Beanstalk 110:连接超时(Nginx/Gunicorn) - 110: Connection timed out (Nginx/Gunicorn) 使用Nginx和Gunicorn将Django应用程序部署到AWS EC2 - Deploying Django app to AWS EC2 using Nginx and Gunicorn 在容器中部署 Django + Vuejs (AWS Elastic Beanstalk) - Deploying Django + Vuejs in containers (AWS Elastic Beanstalk) 在AWS Elastic beantalk上部署Django项目 - Deploying django project on AWS elastic beanstalk 使用gunicorn和nginx部署Django - Deploying Django with gunicorn and nginx 如何在 AWS Elastic Beanstalk 上使用 Nginx、React、Webpack、Gunicorn、PostgreSQL、Django 和 DRF 部署应用程序? 如何使用此应用程序处理静态文件? - How to deploy app with Nginx, React, Webpack, Gunicorn, PostgreSQL, Django & DRF on AWS Elastic Beanstalk? How to handle static files with this app? 将 Django 应用程序部署到 Elastic Beanstalk AWS 502 错误网关 - Deploying a Django application to Elastic Beanstalk AWS 502 Bad Gateway
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM