4

So Django is sending me mail with this info:

[Django] ERROR: Invalid HTTP_HOST header: '<my server IP here>'.You may need to add u'<my server IP here>' to ALLOWED_HOSTS.

No stack trace available

Request repr() unavailable.

The problem is... You can't access my website with the server IP because I only allowing domain that already is in the ALLOWED_HOST setting.

So... What should I do?

Edit: I am using Nginx -> Gunicorn. This error only happens sometimes, like 1-2 times per week.

Spindel
  • 279
  • 5
  • 18
  • Probably because you didn't set the header before proxying to django, please add your virtual host config file and describe your server structure if it has anything special. – Mohammad AbuShady Jan 21 '14 at 17:55
  • This is not happening very often, so it's hard to find the reason for the error message. Anywat, I am using Nginx -> Gunicorn -> Django – Spindel Jan 21 '14 at 18:05

1 Answers1

5

Found the reason.

It was when someone tried to access the server via IP over HTTPS, as in https:// (and the server-ip)

The solution is to disable that option.

Solution for Nginx:

server {
    listen      80;
    listen      443 ssl;
    ssl_certificate    /etc/ssl/example.crt;
    ssl_certificate_key    /etc/ssl/example.key;
    return      444;
}
Spindel
  • 279
  • 5
  • 18