Problem with uWSGI and PATH_INFO

Roberto De Ioris roberto at unbit.it
Thu Jul 27 17:45:06 UTC 2017


> Hi Roberto,
>
> That is not effective. My app uses PATH_INFO to resolve a URL (ie:
> /blog/create/) to a callback function.
>
> Could it be possible to just use :
>
> uwsgi_param PATH_INFO $path_info
>
> Assuming $path_info is the request_uri minus the location...
>
> E
>

Nope, as already said there is no way to manage this directly in nginx
(and technically any 'automatic' management could not be so easy to be
'fair'). You have to rewrite PATH_INFO and SCRIPT_NAME in uWSGI itself
following the links i pasted before.

To be more clear:

nginx passes to uWSGI:

PATH_INFO = /foo/bar

uWSGI receives it and rewrite it as

SCRIPT_NAME = /foo
PATH_INFO = /bar

by using something like this (in the config, tune the regexps as required):

[uwsgi]
route = ^/(.+?)/(.+)$ setscriptname:/$1
route = ^/(.+?)/(.+)$ setpathinfo:/$2

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


More information about the nginx mailing list