regex - How to write PathPrefixStripRegex in Traefik?
问题描述
I have a Docker containers that are running on the ECS Cluster on AWS. I am using Traefik to route certain routes to services. For this I am using DockerLabels option in CloudFormation and one of them is traefik.frontend.rule
and PathPrefixStripRegex
. I had before PathPrefixStrip
rule as
traefik.frontend.rule: "PathPrefixStrip: /api/service-name"
and everything was working without a problem. Now I am trying to expand the api
part to match multiple values like
traefik.frontend.rule: "PathPrefixStripRegex: /{basepath:(?:api|docs)}/service-name"
The problem is what ever url I call the whole path is stripped. So for example, if I call
https://my.example.org/api/service-name/health
the Traefik is stripping everything. So /api/service-name/health
part is removed and the service is being called at the /
(root) path.
Does anyone have any clue why the whole path is being stripped? Is the regex part wrong, I know the Traefik is using Gorilla mux under the hood and frankly I do not have any experience with Go nor mux.
I have tried to use /(api|docs)/service-name
as regex. On regex101 site, it works as expected, when I tried to use it as a rule in Traefik, it does not. The version of Traefik is 1.7.
解决方案
推荐阅读
- javascript - setState 也在更新其他状态
- vba - 通过 VBA 发送时如何从已发送文件夹中删除电子邮件
- android-studio - 当覆盖应用程序处于活动状态时,后退箭头被禁用
- java - 如何从 for 循环值创建单个数组
- go - go-containerregistry 包列出了来自所有项目/组织的 GCR 存储库
- ruby-on-rails - 在 Ruby 中从 .map 中排除数据
- python - 使用 Windows 终端而不是命令提示符运行 python.exe
- java - 在 CompletableFuture 的 whenComplete() 之前返回的方法
- javascript - 我需要通过按下 Javascript 中的按钮来修改和更新值
- parameters - 在报表生成器中,如何将值列表传递给参数,以便允许多个值或空值?