3

I am running a Django Project on DigitalOcean (using Nginx, Gunicorn and Postgres), and I have specified the "allowed hosts" in the settings.py like this:

ALLOWED_HOSTS = ['sub.domain.tld']

Based on what DigitalOcean already set themselves, and based on a blog post I found, I also modified my Nginx settings for the page (/etc/nginx/sites-available/django) to this:

if ($host !~* ^(sub.domain.tld)$ ) {
    return 444;
}

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;
}

I still keep on receiving emails from my Django project, like this one:

"Invalid HTTP_HOST header: '1111.ip138.com'. You may need to add u'1111.ip138.com' to ALLOWED_HOSTS."

When I access the site from my browser, everything seems fine though. Could you let me know where the problem with my configuration is?

Thanks, Tobias

Tobi
  • 139

0 Answers0