前提・実現したいこと
djangoでWebアプリケーションを作りました。
AWS ELBにEC2をぶら下げて、そこにデプロイ(Nginx, gunicorn, postgresql)しましたが、
ヘルスチェックでエラーが発生してしまいます。
まずは、このエラーをなくして、AWS上でdjangoアプリを動かしたいです。
発生している問題・エラーメッセージ
AWSのEC2 マネジメントコンソール
登録済みターゲットのステータス=「unhealthy」
Health checks failed with these codes: [502]
bad gatewayのエラーのようです。
/var/log/nginx/access.log は以下の内容です。
10.0.1.56 - - [25/Nov/2018:07:36:30 +0000] "GET / HTTP/1.1" 502 3738 "-" "ELB-HealthChecker/2.0" "-" 10.0.0.168 - - [25/Nov/2018:07:36:33 +0000] "GET / HTTP/1.1" 502 3738 "-" "ELB-HealthChecker/2.0" "-"
該当のソースコード
/etc/nginx/nginx.conf
http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; index index.html index.htm; upstream app_server { server 127.0.0.1:8000 fail_timeout=0; } server { listen 80 ; server_name (ドメイン:example.com); client_max_body_size 6G; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } location /static { alias /home/ec2-user/myproject/static; }
settings.py
ALLOWED_HOSTS = ['127.0.0.1','ドメイン(example.com)',]
ヘルスチェックの設定
プロトコル : HTTP パス : / ポート : トラフィックポート 正常のしきい値 : 5 非正常のしきい値 : 2 タイムアウト : 5 間隔 : 30 成功コード : 200
wsgiサーバーと接続するときは以下のコマンドを実施しています。
gunicorn project_name.wsgi --bind=0.0.0.0:8000
以上となります。
原因がお分かりになる方、何卒宜しくお願い致します。
回答1件
あなたの回答
tips
プレビュー