You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/06/04 13:51:45 UTC

[GitHub] [apisix] ieayoio commented on issue #4376: request help: How to use proxy-rewrite add multiple regex_uri property

ieayoio commented on issue #4376:
URL: https://github.com/apache/apisix/issues/4376#issuecomment-854739198


   其实我提出这个问题起因并没有这么复杂,只是通过快速入门,想在我原服务的基础上加一个前缀
   
   例如原服务(tomcat):
   
   ```
   http://host2:8080/service/
   ```
   
   加前缀用如下形式替代:
   
   ```
   http://host1:9080/prefix/service/
   ```
   
   我进行了如下配置
   
   ```json
   "proxy-rewrite": {
         "regex_uri": ["^/prefix/service(.*)", "/service$1"]
       }
   ```
   
   当我访问http://host1:9080/prefix/service/,一切正常,我访问到了原服务http://host2:8080/service/的内容
   
   问题出现在我访问http://host1:9080/prefix/service (没有了结尾的"/")
   
   浏览器url却直接跳转到了http://host1:9080/service/,当然这个无法访问的
   
   我分析原因,问题出现在原服务访问http://host2:8080/service会加/跳转到http://host2:8080/service/
   
   因此,我任务最适合我的是配置两个regex_uri
   
   分别为`"regex_uri": ["^/prefix/service", "/service/"]` 直接加/后缀
   
   和`"regex_uri": ["^/prefix/service(.+)", "/service$1"]`
   
   
   
   目前我已经通过配置两条路由解决了,能满足我的要求
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org