Search code examples
djangoapacheenvironment-variablesmod-proxygunicorn

Passing Apache Environment variables to gunicorn through mod_proxy


I'm not entirely sure this is the right way to skin this cat, so feel free to propose completely alternate solutions.

I have a Django site running on gunicorn behind apache's mod_proxy (with the ProxyPass and ProxyPassReverse directives). I'm also using AMFLiteDetectionFilter to detect mobile users. When I was serving the site with mod_wsgi, I could find the environment variable AMF_DEVICE_IS_MOBILE as request.META['AMF_DEVICE_IS_MOBILE']

So what I am looking for is how to push that AMF_DEVICE_IS_MOBILE variable into the request sent to gunicorn.


Solution

  • I solved this with mod_header:

    RequestHeader set X-AMF-DEVICE-IS-MOBILE %{AMF_DEVICE_IS_MOBILE}e
    RequestHeader set X-AMF-DEVICE-IS-TABLET %{AMF_DEVICE_IS_TABLET}e
    

    And can find the values with request.META['X-AMF-DEVICE-IS-MOBILE'] == 'true'