0
点赞
收藏
分享

微信扫一扫

Apache Apisix 网关之 路由配置入门篇

云上笔记 2021-09-18 阅读 181
网关研究

1. 需求如下

location /api/ {
  proxy_pass http://localhost:8013/;
}

访问 http://localhost:9080/api/admin
实际访问: http://localhost:8013/admin

由于Apisix 使用的是radixtree 的写法, 导致只支持匹配规则(Full match,Prefix matching) , 并且不会去掉匹配的路径, 这个时候, 为了去掉上面的 /api/ , 需要使用到插件 proxy write.

1. 创建 upstream , 假设我们本地有个服务,端口是8013

2. 创建路由


下一步, 选择upstream,


设置插件重写 路径


保存后, 当我们访问网关的, 这里的路由重写和nginx的写法类型, 非常简单.(apisix 2.1, apisix dashborad 2.2)
访问 http://localhost:9080/api/admin
实际访问到上游: http://localhost:8013/admin

  1. 代理重写 https://github.com/apache/apisix/blob/master/doc/plugins/proxy-rewrite.md
  2. 配置路由规则 https://github.com/apache/apisix/blob/master/doc/router-radixtree.md
举报

相关推荐

0 条评论