Created
December 8, 2015 09:33
-
-
Save nikoladang/12ecdcabdb6aa2238111 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hosts/domain names that are valid for this site; required if DEBUG is False | |
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts | |
ALLOWED_HOSTS = [ | |
'yourdomain.tld', | |
'.compute-1.amazonaws.com', # allows viewing of instances directly | |
] | |
import requests | |
EC2_PRIVATE_IP = None | |
try: | |
EC2_PRIVATE_IP = requests.get('http://169.254.169.254/latest/meta-data/local-ipv4', timeout = 0.01).text | |
except requests.exceptions.RequestException: | |
pass | |
if EC2_PRIVATE_IP: | |
ALLOWED_HOSTS.append(EC2_PRIVATE_IP) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment