Removing "Invalid HTTP_HOST header" msgs with nginx.conf default server NOT working

36 views
Skip to first unread message

cseb...@gmail.com

unread,
Jun 24, 2022, 5:00:23 PM6/24/22
to Django users
I constantly get the errors below in my Django server logs.  To try to remove this,
I added this to my  Nginx server's nginx.conf file but it didn't work....

        server {

                listen 80 default_server;

                return 444;

        }

What else can I do to remove these errors below this line???

Invalid HTTP_HOST header: '3.208.32.109'. You may need to add '3.208.32.109' to ALLOWED_HOSTS.

Invalid HTTP_HOST header: '3.208.32.109'. You may need to add '3.208.32.109' to ALLOWED_HOSTS.

Invalid HTTP_HOST header: '3.208.32.109'. You may need to add '3.208.32.109' to ALLOWED_HOSTS.

Invalid HTTP_HOST header: '3.208.32.109'. You may need to add '3.208.32.109' to ALLOWED_HOSTS.

Invalid HTTP_HOST header: '3.208.32.109'. You may need to add '3.208.32.109' to ALLOWED_HOSTS.

Invalid HTTP_HOST header: '3.208.32.109'. You may need to add '3.208.32.109' to ALLOWED_HOSTS.

Invalid HTTP_HOST header: '3.208.32.109:443'. You may need to add '3.208.32.109' to ALLOWED_HOSTS.

Invalid HTTP_HOST header: '3.208.32.109'. You may need to add '3.208.32.109' to ALLOWED_HOSTS.

Mr.Teapot

unread,
Jun 26, 2022, 5:50:02 PM6/26/22
to Django users
Please take a look on the ALLOWED_HOSTS documentation https://docs.djangoproject.com/en/4.0/ref/settings/#allowed-hosts.

A list of strings representing the host/domain names that this Django site can serve. This is a security measure to prevent HTTP Host header attacks, which are possible even under many seemingly-safe web server configurations.

Assuming 3.208.32.109 is your server IP you should add it to ALLOWED_HOSTS.

cseb...@gmail.com

unread,
Jun 28, 2022, 1:50:14 PM6/28/22
to Django users
Thanks so much.  I'll try it.  And your solution has no need for Nginx tweaking.  I love it.

cs

Reply all
Reply to author
Forward
0 new messages