About Avoiding Error Reports Referring to Wrong Domains

When an unknown domain is assigned to your server's IP address and it is accessed in a browser, Django raises and error about the domain name not being in ALLOWED_HOSTS.

To catch all unknown domains, before accessing the Django project, put this at the beginning of your nginx domain configuration:

server {
    listen 80 default_server;
    listen 443 ssl default_server;
    server_name _;
    include /etc/nginx/snippets/snakeoil.conf;
    return 444;
}

Tips and Tricks Dev Ops nginx