Is it possible to use the variable in the regex between routers and services in Traefik 2.0? I saw a similar question for Traefix 1.x, but I didn't know if the feature was added.
routers:
test:
entryPoints:
- "http"
- "https"
rule: "Host(`test.{domain:(app|dev)}.blah.com`) || Host(`test.{domain:(app|dev)}.blah.com`)"
service: test
services:
test:
loadBalancer:
servers:
- url: "https://test.$domain.blah.com:81/"
1 Like
ldez
September 27, 2019, 3:05am
2
Hello,
I recommend to use the redirectRegex middleware: https://docs.traefik.io/v2.0/middlewares/redirectregex/
I implemented the RedirectRegex. It will only work on http commands, but not on https? Is it not possible to redirect on https? Below is my config
http:
middlewares:
https-redirect:
redirectScheme:
scheme: https
dfp-redirect:
redirectRegex:
regex: "^http://(.*).company.com"
replacement: "http://${1}.company.com:81"
dfpssl-redirect:
redirectRegex:
regex: "^https://(.*).company.com"
replacement: "https://${1}.company.com:444"
routers:
test:
entryPoints:
- "http"
- "https"
rule: "HostRegexp(`test.{domain:(app|dev)}.company.com`)"
middlewares:
- dfpssl-redirect
- dfp-redirect
service: anything
services:
anything:
loadBalancer:
servers:
- url: "http://fake/"
ldez
September 27, 2019, 6:37pm
4