Problem with uWSGI and PATH_INFO

Francis Daly francis at daoine.org
Fri Jul 28 07:17:04 UTC 2017


On Thu, Jul 27, 2017 at 12:06:42PM -0400, Etienne Robillard wrote:
> Le 2017-07-27 à 11:25, Francis Daly a écrit :
> >On Thu, Jul 27, 2017 at 07:45:28AM -0400, Etienne Robillard wrote:

Hi there,

> >The uwsgi_params values are an example of what can be done. The
> >combination of SCRIPT_NAME and PATH_INFO in that file is consistent, and
> >is valid in some cases (that is, cases where the application corresponds
> >to the "root" of the server).

> Actually my problem is that SCRIPT_NAME is not defined in
> uwsgi_params. SCRIPT_NAME is a mandatory environment variable as per
> HTTP/1.1 spec.

?

HTTP/1.1 does not care about uwsgi, no?

I can see what appears to be the WSGI spec at
https://www.python.org/dev/peps/pep-0333/

My initial reading of that says that SCRIPT_NAME is optional.

Is there a uWSGI spec which says something different?

If you want SCRIPT_NAME set to a particular value, you can set SCRIPT_NAME
to a particular value in your config.

> >No-one has reported that there is a problem and provided a fix.

> That's a major issue. A standard WSGI application should be able to
> use a uWSGI upstream server within the "/" location block without
> the need to define any "mountpoints".

So configure your nginx to send whatever parameters your uWSGI upstream
expects for your WSGI application to work the way you want it to.

> >In general, only the administrator knows what SCRIPT_NAME and PATH_INFO
> >values are appropriate in any one case, so that's the person who should
> >configure the two to match their particular case.
> 
> Correct. Attempting to rewrite PATH_INFO as DOCUMENT_URI seems not a
> reliable solution for my simple use-case.

The defaults do not work for your use case.

What settings do you want for your use case?

> >(Actually: perhaps fastcgi_split_path_info can be used directly, even
> >in a location{} which does not do fastcgi_pass? It should be easy enough
> >to test whether that can work.)

> Note that I don't use fastcgi_split_path_info. The only modification
> I did to fastcgi_params is:
> fastcgi_param SCRIPT_NAME $fastcgi_script_name
> fastcgi_param PATH_INFO $fastcgi_script_name

What I meant there was that you could possibly use fastcgi_split_path_info
to define how you want your $request_uri to be split into parts for your
SCRIPT_NAME and PATH_INFO as uwsgi_param values.

So your eventual config could include

  uwsgi_param SCRIPT_NAME $fastcgi_script_name;
  uwsgi_param PATH_INFO $fastcgi_path_info;

after you have defined the first directive appropriately.

It all comes down to: for one specific http request, what values do
you want SCRIPT_NAME and PATH_INFO to have when they are sent to the
uwsgi upstream?

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list