Re: #29752 Adding a ALLOWED_HOSTS_IGNORABLE_URLS setting

2018-10-28 Thread Peter Baumgartner
I implemented something for this in the django-alive package via a middleware that will bypass the host checking: https://github.com/lincolnloop/django-alive/#disabling-allowed_hosts-for-healthchecks https://github.com/lincolnloop/django-alive/blob/master/django_alive/middleware.py On Fri, Sep

Re: #29752 Adding a ALLOWED_HOSTS_IGNORABLE_URLS setting

2018-09-14 Thread Adam Johnson
The snippet Matt posted is the same technique I've used for ages, albeit using the ec2-metadata library. I think it's perfectly fine as-is, the Host header EC2 uses is actually predictable as the EC2 Private IP. I don't think Django needs another

Re: #29752 Adding a ALLOWED_HOSTS_IGNORABLE_URLS setting

2018-09-14 Thread Mattia Procopio
What I usually do is rewriting the Host value at webserver level using one of the allowed when receiving healthchecks from a load balancer. This is not optimal and having a whitelist for some uris to allow requests without a valid host could make this specific thing easier -- You received

Re: #29752 Adding a ALLOWED_HOSTS_IGNORABLE_URLS setting

2018-09-14 Thread Collin Anderson
You might be able to handle this by a middleware that gets called early enough in the process (before CommonMiddleware) to avoid calling request.get_host(). A simple if request.path == '/statuscheck/': return HttpResponse() should work. As long as you never call request.get_host(), django doesn't

Re: #29752 Adding a ALLOWED_HOSTS_IGNORABLE_URLS setting

2018-09-14 Thread Matt Pegler
AWS will send a request to a specific path and make sure it receives a status 200 response. If the response status is not 200, it will consider that instance unhealthy and will not route traffic to that instance. The path can be anything that can be used as a signal that the application is running

Re: #29752 Adding a ALLOWED_HOSTS_IGNORABLE_URLS setting

2018-09-14 Thread Tim Graham
Sorry, I still don't understand what "whitelisting the health check path" looks like. Here's the snippet for anyone reading the thread after the pastebin expires. ALLOWED_HOSTS = ['ourdomain.com']EC2_PRIVATE_IP = Nonetry: # AWS provided magic service that returns metadata about the instance

Re: #29752 Adding a ALLOWED_HOSTS_IGNORABLE_URLS setting

2018-09-14 Thread Matt Pegler
We would find this valuable for the reason Jonas outlined. Health checks from AWS are sent without a host header, which causes the request to fail the host check. By whitelisting the health check path, it would simplify deployments to AWS and possibly others. Here's the workaround we use in

Re: #29752 Adding a ALLOWED_HOSTS_IGNORABLE_URLS setting

2018-09-14 Thread Tim Graham
What would be the value of that setting for your use case? On Friday, September 14, 2018 at 11:52:46 AM UTC-4, Jonas H wrote: > > Hi, > > I've started a discussion on https://code.djangoproject.com/ticket/29752 > to add a new ALLOWED_HOSTS_IGNORABLE_URLS setting. > > The setting can become handy

#29752 Adding a ALLOWED_HOSTS_IGNORABLE_URLS setting

2018-09-14 Thread Jonas H
Hi, I've started a discussion on https://code.djangoproject.com/ticket/29752 to add a new ALLOWED_HOSTS_IGNORABLE_URLS setting. The setting can become handy if you can't control the Host header sent to your application but still want to accept the request. An example of this is health checks