简体   繁体   中英

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.

Current status

  1. Console shows that it's properly deployed. (shows OK status to me)
  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.

Things I've tried.

  1. Checked nginx log, and there's nothing printed out. So I suspect that Load balancer didn't route request to nginx web server.
tail -f /var/log/nginx/*
  1. Connected ec2 instance using ssh, and checked nginx running with port 80 and gunicorn running with port 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 :

The django.middleware.security.SecurityMiddleware provides several security enhancements to the request/response cycle. Each one can be independently enabled or disabled with a setting.

Removal of the setting solved the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM