title: How to dynamically add EC2 ip addresses to Django ALLOWED_HOSTS
body: <p>We've recently changed our deployment strategy to use AWS auto scaling group. </p>
  
  <p>One problem we have in production is with the newly created EC2s.<br>
  Our Application starts to return:</p>
  
  <pre><code>Invalid HTTP_HOST header: 
      &lt;ip_address&gt;. You may need to add &lt;ip_address&gt; to ALLOWED_HOSTS`
  </code></pre>
  
  <p>because these EC2s are not in the original Django <code>ALLOWED_HOSTS</code>. </p>
  
  <p>It doesn't make sense for each newly created EC2 to have to redeploy; that contradicts the sense of "auto scale". <br>
  Also, we don't want to use wildcards or IP range for security reasons.</p>
  
  <p>What can we do?</p>