【发布时间】:2020-01-18 19:56:32
【问题描述】:
我想将所有具有/api/ (http://example.com/api/) 的请求重定向到我的代理应用程序,并在此过程中删除/api。我已经尝试过了,但是在卷曲时我得到了 404。它没有到达应用程序,我认为这与rewrite 有关,但我不确定它是否正确。
location ~ ^/api {
rewrite ^/api/(.*) /$1 break;
proxy_pass http://127.0.0.1:8070;
}
以下内容在硬编码时有效。它会将我重定向到我的应用程序/error。
location = /api/error {
proxy_pass http://127.0.0.1:8070/error;
}
例如,我希望http://example.com/api/login 像http://example.com/login 那样访问我的代理应用程序。
【问题讨论】: