【问题标题】:Traefik - redirect not work with PathPrefixStrip without slashTraefik - 重定向不适用于没有斜杠的 PathPrefixStrip
【发布时间】:2019-03-04 13:23:23
【问题描述】:

我需要重定向一个特定的/path,我写了这个:

web1:
    image: httpd
    labels:
      - "traefik.backend=httpd"
      - "traefik.frontend.rule=Host:www.example.com"
      - "traefik.port=80"
web2:
    image: nginx
    labels:
      - "traefik.backend=nginx"
      - "traefik.frontend.rule=Host:www.foobar.com"
      - "traefik.port=80"   
app:
    image: custom/image
    labels:
      - "traefik.backend=app"
      - "traefik.frontend.rule=Host:www.example.com,www.foobar.com; PathPrefixStrip:/app"
      - "traefik.port=80"

当我转到 http://www.example.com/apphttp://www.foobar.com/app 时,我需要进入容器 app,但只有在 URL 末尾插入 / 时才能工作:

http://www.example.com/app 不工作

http://www.foobar.com/app 不工作

http://www.example.com/app/工作

http://www.foobar.com/app/工作

我已经有一个使用 apache 别名的应用程序版本,我想这不是应用程序的问题

谢谢

【问题讨论】:

    标签: traefik


    【解决方案1】:

    我在这里找到了解决方案:https://github.com/containous/traefik/issues/563#issuecomment-421360934

    labels:
      - "traefik.frontend.redirect.regex=^(.*)/path$"
      - "traefik.frontend.redirect.replacement=$1/path/"
      - "traefik.frontend.rule=PathPrefix:/path;ReplacePathRegex: ^/path/(.*) /$1"
    

    【讨论】:

      猜你喜欢
      • 2015-02-09
      • 1970-01-01
      • 2018-12-07
      • 2016-01-10
      • 2010-12-08
      • 1970-01-01
      • 2018-08-04
      • 2015-09-20
      • 1970-01-01
      相关资源
      最近更新 更多