I\'m using Django and I have the ALLOWED_HOSTS
setting to include my EC2
\'s private IP as per below:
import requests
EC2_PRIVATE_IP = N
Fetching AWS internal IPs and adding to the ALLOWED_HOST is not the best solution. Since this Fetching will happen only on application reload. ELB IPs can change anytime.
Instead of this, We can set actual host header in the nginx, if this the request is coming from an IP.
Credit goes to: https://www.xormedia.com/django-allowed-hosts-and-amazon-elastic-load-balancer/