Skip to content

Instantly share code, notes, and snippets.

@NIXKnight
Last active May 14, 2020 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NIXKnight/0c522eb108d3c4649f5a216d26b701e3 to your computer and use it in GitHub Desktop.
Save NIXKnight/0c522eb108d3c4649f5a216d26b701e3 to your computer and use it in GitHub Desktop.
ELB HealthCheck with Django ALLOWED_HOSTS on EC2
import requests
AWS_ELB_META_IPV4_URL = "http://169.254.169.254/latest/meta-data/local-ipv4"
ELB_HEALTHCHECK_HOSTNAME = requests.get(AWS_ELB_META_IPV4_URL, timeout=5).text
ALLOWED_HOSTS += [ELB_HEALTHCHECK_HOSTNAME]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment