簡體   English   中英

ERR_CONNECTION_TIMED_OUT 同時使用 AWS 彈性豆莖部署 django(使用 nginx + gunicorn)

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

我在使用 aws elastic beanstalk 部署 django 時面臨 ERR_CONNECTION_TIMED_OUT。

當前狀態

  1. 控制台顯示它已正確部署。 (向我顯示 OK 狀態)
  2. 允許安全組的入站流量。

但是,當我嘗試使用彈性 beanstalk 提供的 url 連接實例時,我一直在 chrome 瀏覽器上看到 ERR_CONNECTION_TIMED_OUT。

我嘗試過的事情。

  1. 檢查了 nginx 日志,沒有打印出來。 所以我懷疑負載均衡器沒有將請求路由到 nginx web 服務器。
tail -f /var/log/nginx/*
  1. 使用 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)

有人可以幫我找出問題嗎? 提前致謝!

根據評論。

問題原來是由於django 設置django.middleware.security.SecurityMiddleware

django.middleware.security.SecurityMiddleware 為請求/響應周期提供了多項安全增強功能。 每個都可以通過設置獨立啟用或禁用。

刪除設置解決了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM