当第一个路径参数不固定时,nginx 代理传递重写规则
nginx proxy pass rewrite rule when the first path parameter is not fixed
需要以下 nginx proxy/rewrite 规则的帮助 -
请求:https://domain1.com/{cc}-{lc}/news/article
--需要代理转发如下--
目标:https://domain2.com/{cc}-{lc}/info/article
示例-
请求:https://domain1.com/us-en/news/welcome_2020
--需要代理转发如下--
目标:https://domain2.com/us-en/info/welcome_2020
请求:https://domain1.com/fr-fr/news/welcome_2020
--需要代理转发如下--
目标:https://domain2.com/fr-fr/info/welcome_2020
使用
location ... { # your location
rewrite ^(/[^/]+)/news(/.*) /info break;
... # all the other proxy setup
proxy_pass ...
}
需要以下 nginx proxy/rewrite 规则的帮助 -
请求:https://domain1.com/{cc}-{lc}/news/article
--需要代理转发如下--
目标:https://domain2.com/{cc}-{lc}/info/article
示例-
请求:https://domain1.com/us-en/news/welcome_2020
--需要代理转发如下--
目标:https://domain2.com/us-en/info/welcome_2020
请求:https://domain1.com/fr-fr/news/welcome_2020
--需要代理转发如下--
目标:https://domain2.com/fr-fr/info/welcome_2020
使用
location ... { # your location
rewrite ^(/[^/]+)/news(/.*) /info break;
... # all the other proxy setup
proxy_pass ...
}