[Answer]-How can I ambidextrously handle different hosts when Django is running Gunicorn behind Apache?

1👍

Your stack looks kinda crazy.

You want one webserver with Django which can be accessed by multiple domains. Each domain causes the Django application to serve different content. Did i understand you correctly?

If yes, maybe you are successful by replacing Apache by Nginx. It can resolve the requesting hostname and decide how to redirect the request:

What's the difference of $host and $http_host in Nginx

Multiple Domain Hosting With One Django Project

Update

Relevant nginx documentation for distinguishing between different hostnames:
http://nginx.org/en/docs/http/request_processing.html
http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name

Relevant nginx documentation for adding request headers:
http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header

Also see this answer:
Adding and using header (HTTP) in nginx

👤Alp

Leave a comment