Reputation: 19762
I'm testing Gunicorn as an alternative to uWSGI. An Nginx reverse-proxy is set up in front of the Gunicorn instance. A consequence of not using uWSGI is I have to resort to using Nginx's proxy_pass
instead of uwsgi_pass
. With uwsgi_pass
I could use uwsgi_param
to overwrite the PATH_INFO
and SCRIPT_NAME
WSGI variables. proxy_pass
has no equivalent directive. How do you set these WSGI variables for proxy_pass
for a WSGI compliant application server such as Gunicorn?
Upvotes: 2
Views: 1543
Reputation: 19762
The Gunicorn documentation suggests that you can specify SCRIPT_NAME
through an HTTP header without any further explanation. Digging through the source code revealed that it accepts a non-standard header actually named SCRIPT_NAME
. The following can be used to set SCRIPT_NAME
for Gunicorn:
proxy_set_header SCRIPT_NAME /myapp;
PATH_INFO
cannot be set. However, in my case PATH_INFO
does not need to be set for Gunicorn because it automatically strips the SCRIPT_NAME
prefix from PATH_INFO
. With uWSGI I had to overwrite PATH_INFO
to strip the SCRIPT_NAME
prefix.
Upvotes: 1