GrahamDumpleton / mod_wsgi-docker

Docker images for Apache/mod_wsgi.
Apache License 2.0
72 stars 36 forks source link

Context path or SCRIPT_NAME when deployed in docker, and proxied throgh front-end apache #30

Open damooo opened 5 years ago

damooo commented 5 years ago

hello @GrahamDumpleton , when we server through mod_wsgi, apache inside docker, and setup a proxy throgh frontend Apache to this docker, every thing works as expected if it is mounted at root on front-end apache in your article http://blog.dscpl.com.au/2015/06/proxying-to-python-web-application.html , there are ways specified for modifying forwarded headers like scheme, and port.

ProxyPass / http://docker.example.com:8002/

RequestHeader set X-Forwarded-Port 443
RequestHeader set X-Forwarded-Scheme https

but if proxied like below, with custom mount path

ProxyPass /my_api http://docker.example.com:8002/

then url reconstruction inside docker image not working, as SCRIPT_NAME for wsgi environ doesn't preserve frontend's mount path. what is recommonded way to do this?

GrahamDumpleton commented 5 years ago

Use:

ProxyPass /my_api/ http://docker.example.com:8002/my_api/

and then in the image when running mod_wsgi-express use the --mount-point /my_api/ option.

I have used a trailing slash on everything as I can't remember if there is a limitation with leaving it off in this case. Try with and without and see if there are any gotchas that I can't remember.

If you must be able to accept without a trailing slash on the front end, add a RewriteRule which redirects URL without training slash to have trailing slash, which would then match the ProxyPass.