Nginx - Rewrite the request_uri before uwsgi_pass

落花浮王杯 提交于 2019-11-30 03:09:21
location /one {
  rewrite /one/(.+) /$1 break;
  include uwsgi_params;
  uwsgi_pass unix:///.../one.sock;
}

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!