Django Invalid HTTP_HOST header on Apache - fix using Require?

So, after messing with this for a long time I figured out that the problem I was dealing with may have something to do with the hostname reverse DNS lookup failing, since the IP address was pointing to an AWS EC2 instance instead of my domain.

After finally giving up on getting it right I returned to the post on how to disable the log error, and tried using the env variable, which seems to be working.

Apparently the correct format for Require is:

<Directory /var/www/html/>
    SetEnvIfNoCase Host example\.com VALID_HOST
    Require env VALID_HOST
    Options
</Directory>

These guys had it right, just need to update it for the current "Require" directive.

How to disable Django's invalid HTTP_HOST error?


No need to use mod_setenvif as HTTP_HOST is already a variable and you can evaluate it directly.

<Directory /var/www/html/>
    Require expr %{HTTP_HOST} == "example.com"
    Options
</Directory>