![invalid host header invalid host header](https://img-blog.csdnimg.cn/20210613181256737.png)
This is what the Domain Name System, or DNS, does.
#Invalid host header software
When a piece of software in a computer tries to communicate with another computer via a domain name, like your browser trying to open a website for you, it first needs to translate the domain name to an IP address. Some backgroundĬomputers communicate on the internet via IP addresses, not domain names. Many people tend to think this is a problem in their Django application, maybe because Django has an ALLOWED_HOSTS setting that determines for which domain names it should accept requests, but in reality, it is most likely due to a misconfiguration of the Nginx server block that proxies requests to your Django backend. To put it simply, Nginx is proxying to your Django application requests that should be either denied (or maybe proxied elsewhere, if, for example, you have multiple backends). If you haven’t, do it and then check back here to make sure you’re doing the Nginx part correctly. Note: my explanation assumes you already configured ALLOWED_HOSTS correctly.
![invalid host header invalid host header](https://chico-shikaku.com/wp-content/uploads/2020/07/788620bdc45c7bf7e9f533c4d5e4485e.png)
TL DR: remove the default_server option from your server configuration block so that Nginx doesn’t reply to all HTTP requests for any Host header, and place a new server block with default_server returning a 444 status (or, if you’re not using Nginx, a 422 status). It’s a fairly common problem but it’s also simple to fix. #devops #django #itsecurity #software developmentĭo you have a Django application running behind Nginx and getting lots of Invalid HTTP_HOST header errors, even though you already configured ALLOWED_HOSTS correctly? ☰ Menu Invalid HTTP_HOST header errors in Django and Nginx