title: Django Invalid HTTP_HOST header on Apache - fix using Require?
body: <p>A couple weeks ago, I had a wonderful time setting up an Apache and Django configuration to work while forcing SSL and operating behind an AWS load balancer. </p>
  
  <p>Now that it is all working nicely, I'm still constantly receiving the common "Invalid HTTP_HOST header" error, and trying to figure out the right way to go about fixing it.  </p>
  
  <p>Searching has brought me to the following answer regarding the Apache configuration:</p>
  
  <p><a href="https://stackoverflow.com/questions/18220519/how-to-disable-djangos-invalid-http-host-error/18792080#18792080">How to disable Django&#39;s invalid HTTP_HOST error?</a></p>
  
  <p>Which recommends placing the following settings inside the <code>&lt;Directory&gt;&lt;/Directory&gt;</code> block in the VirtualHost file:</p>
  
  <pre><code>SetEnvIfNoCase Host .+ VALID_HOST
  Order Deny,Allow
  Deny from All
  Allow from env=VALID_HOST}
  </code></pre>
  
  <p>This works, but according to Apache (<a href="https://httpd.apache.org/docs/2.4/howto/access.html" rel="noreferrer">https://httpd.apache.org/docs/2.4/howto/access.html</a>) this method is deprecated.</p>
  
  <p>I've read through the Apache docs but when I tried using the following code it just shut down access to the site and gave me a "Not Authorized" error.  </p>
  
  <pre><code>&lt;RequireAll&gt;
      Require host example.org
  &lt;/RequireAll&gt;
  </code></pre>
  
  <p>Not entirely sure what I'm missing. I know I can solve the problem using the first answer, just trying to figure out the "right" way using code that isn't deprecated.  Site is using WSGIDaemonProcess to run the Django App and has the following set to force the SSL through AWS</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteCond %{HTTP:X-Forwarded-For} !=""
  RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}
  </code></pre>