microsoft / service-fabric-traefik

service-fabric-traefik contains services to fetch endpoint information from Service Fabric and expose Traefik endpoints.
MIT License
14 stars 15 forks source link

sf-stripprefixregex_nonpartitioned #21

Open tony-gamble-asos opened 2 years ago

tony-gamble-asos commented 2 years ago

It appears that middleware is automatically assigned to any routes which are picked up from the traefik labels.

the middleware assigned is :

sf-stripprefixregex_nonpartitioned:

      stripPrefixRegex:
        regex:
        - ^/[^/]*/[^/]*/*

for the following traefik labels

<Label Key="traefik.http.api">true</Label>
<Label Key="traefik.http.api.router.entrypoints">websecure</Label>
<Label Key="traefik.http.api.router.rule">PathPrefix(`/part1/part2/`)</Label>
<Label Key="traefik.http.api.router.tls.options" />
<Label Key="traefik.http.api.service.loadbalancer.passhostheader">true</Label>
<Label Key="traefik.http.api.service.loadbalancer.healthcheck.path">/part1/part2/v1/healthcheck</Label>
<Label Key="traefik.http.api.service.loadbalancer.healthcheck.interval">10s</Label>
<Label Key="traefik.http.api.service.loadbalancer.healthcheck.scheme">https</Label>

This results in the path being stripped and any request to ,for example, /part1/part2/v1/healthcheck is re-written to be v1/healthcheck which no longer matches a valid route.

The only solution found so far to prevent the rewriting is to specify a specific middleware rule which does not match. for example

<Label Key="traefik.http.api.middlewares.ignoreStrip.stripPrefix.prefixes">/nomatch</Label>

This ensures the path is not re-written using the sf-stripprefixregex_nonpartitioned middleware rule but is obviously not very elegant

sergiojrdotnet commented 4 months ago

Same issue here, I don't want to strip any prefix