unbit/uwsgi — pull request #728 by peterengstedt (2014-09-27 14:05:00+00:00)
Title: mod_proxy_uwsgi - extract path_info inside uwsgi_canon() and not in uwsgi_handler()

When a uwsgi request is proxied via a balancer the condition for extracting and setting PATH_INFO is different.

If the configuration looks like this (where we have a direct mapping to uwsgi)
ProxyPass /myapp uwsgi://127.0.0.1:3033
and a request /myapp/additional_path comes, uwsgi_handler() will get this data:
url: uwsgi://127.0.0.1:3033/additional_path
worker->s->name: uwsgi://127.0.0.1:3033
r->filename: proxy:uwsgi://127.0.0.1:3033/additional_path
and this is what the code is written to handle. But if we have a balancer mapping like this

BalancerMember uwsgi://127.0.0.1:3033

ProxyPass /myapp balancer://abc/myapp

and we get the same request, /myapp/additional_path, uwsgi_handler() will get this data:
url: uwsgi://127.0.0.1:3033/additional_path
worker->s->name: uwsgi://127.0.0.1:3033
r->filename: proxy:balancer://abc/additional_path
To make things more complex, any search parameters will be added to the url if the request has gone through the balancer (but not otherwise). Passing a parameter that contain a %2f will then fail the check in the call to ap_unescape_url() - (that is why I really started to look into this).

My suggested solution is to extract path info already in the uwsgi_canon(), similar to how it is done in mod_proxy_balancer, proxy_balancer_canon().