Nginx - Rewrite the request_uri before uwsgi_pass

I just met the same problem, and here is a solution

location /one {
    include uwsgi_params;
    uwsgi_pass unix:///.../one.sock;
    uwsgi_param SCRIPT_NAME /one;
    uwsgi_modifier1 30;
}

You can found more about uwsgi_modifier1 here: http://uwsgi-docs.readthedocs.org/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info


I know this thread is old, but there is another way to solve this if you are using uWSGI to run your python app.

[uwsgi]
route-uri = ^/one/(.*) rewrite:/$1

location /one {
  rewrite /one/(.+) /$1 break;
  include uwsgi_params;
  uwsgi_pass unix:///.../one.sock;
}