我想在api.example.com/example下访问一个docker-compose服务。因此我有以下docker-compose.yml

  example:
    image: example
    labels:
            - "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/"
            - "traefik.enable=true"
            - "traefik.protocol=http"
            - "traefik.frontend.entryPoints=https"

我可以通过这条路径来获得服务。但是页面中的所有链接都路由到错误的网址,例如api.example.com/link而不是api.example.com/example/link
另外,由于此路径问题,css无法正确加载。
什么是使此工作正确的路径配置?

从文档中读取,X-Forwarded-Prefix应该是解决方案,但没有相关文档。

最佳答案

如果我理解正确,则只希望将与api.example.com/example/*匹配的请求路由到此example服务。然后,您应该使用PathPrefix:/example/

所期望的是:PathPrefixStrip,顾名思义,尝试匹配路径,然后在将流量路由到服务之前将其删除。

关于docker - Traefik路径路由,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53280683/

10-16 07:15