Home > Enterprise >  Can I stop the significant amount of [Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header from str
Can I stop the significant amount of [Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header from str

Time:09-17

Since adding the option to email me (the admin) when there are problems with my Django server, I keep getting a LOT of the following emails (20 in the last hour alone).

[Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header: 'staging.menthanhgiadalat.com'. You may need to add 'staging.menthanhgiadalat.com' to ALLOWED_HOSTS.

I've set my server up to have the following at the top of the file in my sites-enabled nginx config as I read (somewhere on SO) that this would may prevent me from getting these types of emails:

server {
    server_name _;
    return 444;
}

But it hasn't done anything.

In the next server block I have the IP address and domain names for my site. Could this be causing the problem?

This 'staging' site isn't the only domain I'm being asked to add to my ALLOWED_HOSTS. But it is, by far, the most frequent.

Can I stop this type of alert being sent? Can I stop it from being raised? Is there something I've configured incorrectly on my server (I'm ashamed to admit I'm pretty new at this).

Thanks for any help you might be able to give.

CodePudding user response:

You can configure LOGGING in your settings.py to silence django.security.DisallowedHost as directed at https://docs.djangoproject.com/en/3.2/topics/logging/#django-security

  • Related