This is my nginx virtual host configuration.
debian:~# cat /etc/nginx/sites-enabled/mybox server { listen 8080; root /www; index index.html index.htm; server_name mybox; location /foo { uwsgi_pass unix:/tmp/uwsgi.sock; include uwsgi_params; uwsgi_param SCRIPT_NAME /foo; uwsgi_modifier1 30; } }
This is the source code of my WSGI application.
debian:~# cat /www/app.py def application(environ, start_response): path_info = script_name = request_uri = None if 'PATH_INFO' in environ: path_info = environ['PATH_INFO'] if 'SCRIPT_NAME' in environ: script_name = environ['SCRIPT_NAME'] if 'REQUEST_URI' in environ: request_uri = environ['REQUEST_URI'] output = 'PATH_INFO: ' + repr(path_info) + '\n' + \ 'SCRIPT_NAME: ' + repr(script_name) + '\n' + \ 'REQUEST_URL: ' + repr(request_uri) + '\n' start_response('200 OK', [('Content-Type','text/plain')]) return [output.encode()]
I serve the WSGI application with these two commands:
service nginx restart uwsgi -s /tmp/uwsgi.sock -w app --chown-socket=www-data:www-data
This is the result that I see when I try to visit my web application.
debian:~# curl http://mybox:8080/foo/bar PATH_INFO: '/foo/bar' SCRIPT_NAME: '/foo' REQUEST_URL: '/foo/bar'
Since I mentioned uwsgi_modifier1 30; in my nginx virtual host configuration, I expected PATH_INFO to be only '/bar' , as described in the following two URLs:
Quoting the corresponding part from the first article:
The parameter uwsgi_modifier1 30 sets the modifier uWSGI UWSGI_MODIFIER_MANAGE_PATH_INFO . This modifier for each request tells the uWSGI server to overwrite the value of PATH_INFO, removing SCRIPT_NAME from it.
Quoting the corresponding part from the second article:
A standard WSGI request followed by an HTTP request body. PATH_INFO automatically changes, removing SCRIPT_NAME from it.
But I see that my PATH_INFO remains untouched as '/foo/bar' . Part of SCRIPT_NAME, i.e. '/foo' , not removed from it. Why?
python wsgi nginx uwsgi
Lone learningner
source share