Redirect domains to specific URLs with Traefik v2
Rewritten on Jan 7, 2020.
This enables Traefik to redirect for example, foo.birkhoff.me to https://www.google.com. The TLS section is required for a full HTTPS setup.
The below is a dynamic configuration, refer to the Traefik docs for the info.
http: routers: redirections: service: dummyservice tls: certResolver: acme middlewares: - "foo-redirectregex" - "bar-redirectregex" rule: "Host(`foo.birkhoff.me`) || Host(`bar.birkhoff.me`)" middlewares: foo-redirectregex: redirectRegex: regex: "^https?://foo.birkhoff.me" replacement: "https://www.google.com" permanent: true bar-redirectregex: redirectRegex: regex: "^https?://bar.birkhoff.me" replacement: "https://www.twitter.com" permanent: true services: dummyservice: loadBalancer: servers: - url: "http://126.96.36.199:80"