Problem with uWSGI and PATH_INFO

Roberto De Ioris roberto at unbit.it
Thu Jul 27 13:01:22 UTC 2017


> Hi Roberto,
>
> My Django app runs perfectly ok under FastCGI and nginx but is not
> capable of resolving the proper PATH_INFO under uWSGI. In
> fastcgi_params, the value of PATH_INFO and SCRIPT_NAME are set to
> "$fastcgi_script_name". My nginx config looks like this:
>
> location / {
>
>   uwsgi_pass django;
>
> include uwsgi_params;
>
> }
>
> My wsgi app (django-hotsauce) really relay on a HTTP/1.1 compatible
> PATH_INFO value, just like in wsgiref. Why is it not possible to
> implement $uwsgi_script_name variable for nginx?
>
> Best regards,
> Etienne
>
>

Hi,

if the url is something like /foo/bar and you have a location like

location /foo {
    ...
}

the WSGI standard expects SCRIPT_NAME to be /foo and PATH_INFO to be /bar

if you manually set SCRIPT_NAME to /foo in nginx, PATH_INFO will continue
to be /foo/bar.

Obviously having nginx managing it could be useful, but nowadays it is way
more versatile to manage this part in uWSGI itself (using the
manage-script-name or internal routing to manually rewrite apps), or
directly in your WSGI middleware.

your fastcgi adapter (i suppose flup) hardcodes this magic using the
classic apache fastcgi patterns (something we cannot rely on as we need to
support multiple environments)

-- 
Roberto De Ioris
http://unbit.com


More information about the nginx mailing list