简体   繁体   中英

AWS Elastic Beanstalk Django application health check problem

I am having a very similar problem to the one described here . As that question wasn't answered and there are some differences between my problem and the one described there I decided to ask a new question.

I managed to deploy my Django backend API to the AWS Elastic Beanstalk Amazon Linux 2 Python 3.7 platform. However, the health status of the EB instance is "Severe". It shows the message:

Following services are not running: release.

The overall health status is "Degraded" and the message is

Impaired services on all instances.

Sometimes a message saying that all responses are 4xx appears. This message comes and goes. The weird thing is that I have 2 load balancers configured (one for http and the other one for https) and both have a health check path url of a valid url in the application.

The only relevant logs I could find are the following:

daemon.log

F, [2020-11-05T00:07:40.486088 #15846] FATAL -- : /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.6.0/gems/puma-4.3.5/lib/puma/launcher.rb:432:in `block in setup_signals': SIGTERM (SignalException)
    from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.6.0/gems/puma-4.3.5/lib/puma/single.rb:117:in `join'
    from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.6.0/gems/puma-4.3.5/lib/puma/single.rb:117:in `run'
    from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.6.0/gems/puma-4.3.5/lib/puma/launcher.rb:172:in `run'
    from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.6.0/gems/puma-4.3.5/lib/puma/cli.rb:80:in `run'
    from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.6.0/gems/healthd-1.0.6/bin/healthd:112:in `block in <top (required)>'
    from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.6.0/gems/healthd-1.0.6/bin/healthd:19:in `chdir'
    from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.6.0/gems/healthd-1.0.6/bin/healthd:19:in `<top (required)>'
    from /opt/elasticbeanstalk/lib/ruby/bin/healthd:23:in `load'
    from /opt/elasticbeanstalk/lib/ruby/bin/healthd:23:in `<main>'

web.stdout.log

(...)
Nov  5 09:26:18 ip-172-31-94-128 web: Invalid HTTP_HOST header: '52.86.81.51'. You may need to add '52.86.81.51' to ALLOWED_HOSTS.
Nov  5 09:26:18 ip-172-31-94-128 web: Bad Request: /
Nov  5 09:33:11 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 09:33:11 ip-172-31-94-128 web: Bad Request: /console/
Nov  5 09:33:12 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 09:33:12 ip-172-31-94-128 web: Bad Request: /index.php
Nov  5 09:33:16 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 09:33:16 ip-172-31-94-128 web: Bad Request: /
Nov  5 09:33:16 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 09:33:16 ip-172-31-94-128 web: Bad Request: /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
Nov  5 09:33:17 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 09:33:17 ip-172-31-94-128 web: Bad Request: /api/jsonws/invoke
Nov  5 09:33:20 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 09:33:20 ip-172-31-94-128 web: Bad Request: /solr/admin/info/system
Nov  5 09:33:22 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 09:33:22 ip-172-31-94-128 web: Bad Request: /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
Nov  5 09:33:24 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 09:33:24 ip-172-31-94-128 web: Bad Request: /wp-content/plugins/wp-file-manager/readme.txt
Nov  5 09:33:25 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 09:33:25 ip-172-31-94-128 web: Bad Request: /
Nov  5 09:35:29 ip-172-31-94-128 web: Not Found: /boaform/admin/formLogin
Nov  5 09:35:55 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.212.192.113'. You may need to add '18.212.192.113' to ALLOWED_HOSTS.
Nov  5 09:35:55 ip-172-31-94-128 web: Bad Request: /
Nov  5 09:41:21 ip-172-31-94-128 web: Invalid HTTP_HOST header: '54.243.237.110'. You may need to add '54.243.237.110' to ALLOWED_HOSTS.
Nov  5 09:41:21 ip-172-31-94-128 web: Bad Request: /remote/login
Nov  5 09:46:37 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.212.192.113'. You may need to add '18.212.192.113' to ALLOWED_HOSTS.
Nov  5 09:46:37 ip-172-31-94-128 web: Bad Request: /
Nov  5 09:49:41 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.212.192.113'. You may need to add '18.212.192.113' to ALLOWED_HOSTS.
Nov  5 09:49:41 ip-172-31-94-128 web: Bad Request: /
Nov  5 09:58:26 ip-172-31-94-128 web: Not Found: /
Nov  5 09:59:35 ip-172-31-94-128 web: Invalid HTTP_HOST header: '34.236.195.107'. You may need to add '34.236.195.107' to ALLOWED_HOSTS.
Nov  5 09:59:35 ip-172-31-94-128 web: Bad Request: /
Nov  5 09:59:35 ip-172-31-94-128 web: Invalid HTTP_HOST header: '34.236.195.107'. You may need to add '34.236.195.107' to ALLOWED_HOSTS.
Nov  5 09:59:35 ip-172-31-94-128 web: Bad Request: /
Nov  5 10:09:52 ip-172-31-94-128 web: Invalid HTTP_HOST header: '52.86.81.51'. You may need to add '52.86.81.51' to ALLOWED_HOSTS.
Nov  5 10:09:52 ip-172-31-94-128 web: Bad Request: /
Nov  5 10:10:35 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.212.192.113'. You may need to add '18.212.192.113' to ALLOWED_HOSTS.
Nov  5 10:10:35 ip-172-31-94-128 web: Bad Request: /
Nov  5 10:10:38 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.212.192.113'. You may need to add '18.212.192.113' to ALLOWED_HOSTS.
Nov  5 10:10:38 ip-172-31-94-128 web: Bad Request: /
Nov  5 10:20:03 ip-172-31-94-128 web: Invalid HTTP_HOST header: '52.86.81.51'. You may need to add '52.86.81.51' to ALLOWED_HOSTS.
Nov  5 10:20:03 ip-172-31-94-128 web: Bad Request: /
Nov  5 10:23:53 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 10:23:53 ip-172-31-94-128 web: Bad Request: /remote/login
Nov  5 10:36:49 ip-172-31-94-128 web: Invalid HTTP_HOST header: '34.236.195.107'. You may need to add '34.236.195.107' to ALLOWED_HOSTS.
Nov  5 10:36:49 ip-172-31-94-128 web: Bad Request: /
Nov  5 10:38:39 ip-172-31-94-128 web: Invalid HTTP_HOST header: '54.243.237.110'. You may need to add '54.243.237.110' to ALLOWED_HOSTS.
Nov  5 10:38:39 ip-172-31-94-128 web: Bad Request: /
Nov  5 10:42:26 ip-172-31-94-128 web: Not Found: /
Nov  5 10:42:49 ip-172-31-94-128 web: Invalid HTTP_HOST header: '52.86.81.51'. You may need to add '52.86.81.51' to ALLOWED_HOSTS.
Nov  5 10:42:49 ip-172-31-94-128 web: Bad Request: /
Nov  5 10:42:49 ip-172-31-94-128 web: Invalid HTTP_HOST header: '52.86.81.51'. You may need to add '52.86.81.51' to ALLOWED_HOSTS.
Nov  5 10:42:49 ip-172-31-94-128 web: Bad Request: /
Nov  5 11:05:54 ip-172-31-94-128 web: Invalid HTTP_HOST header: '18.210.4.127'. You may need to add '18.210.4.127' to ALLOWED_HOSTS.
Nov  5 11:05:54 ip-172-31-94-128 web: Bad Request: /

I have no clue what the error in the daemon.log means. I have googled the error and found nothing relevant. On the other hand, I don't understand why the requests that appear in the web.stdout.log are being made. The IP addresses that originated the request are all from Virginia US (region where my server is hosted), so I'm guessing the requests where made by some AWS resource. The weird thing is the routes to which the requests were made: none of them exists in my application.

Any help is very much appreciated. Thank you in advance.

Quick solution:

You need to add * in project's settings.pyALLOWED_HOSTS

ALLOWED_HOSTS = ['*']

Long solution:

Looks like your IP address is dynamic so you need to access by domain name and not IP or you need to allow all IPs, what means Quick solution .

Explanation here
Same 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