geeek
October 7, 2020, 9:01am
1
Hi I am using docker-compose for Traefik and for a domain I want to redirect it to different url. There is no service running in short I want to use Traefik to forward the URL to a different URL.
I am getting error too many redirects. Can someone help please?
labels:
- "traefik.http.routers.catchall.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.catchall.entrypoints=web"
- "traefik.http.routers.catchall.middlewares=redirect-to-https"
- "traefik.http.middlewares.domain.redirectregex.regex=^https://abc[.]com/(.*)"
- "traefik.http.middlewares.domain.redirectregex.replacement=https://xyz.com"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
- "traefik.http.routers.traefik.rule=Host(`dashboard.abc.com`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.tls.certresolver=myhttpchallenge"
- "traefik.http.routers.traefik.entrypoints=websecure"
ldez
October 8, 2020, 1:07am
2
Hello,
I created a small example, with self-signed certificates and some local domains.
The Traefik dashboard is on https://traefik.localhost
There is a redirection from https://abc.localhost (or http://abc.localhost ) to https://xyz.localhost
I added a whoami to simulate the xyz.localhost, it's just to have a working example.
version: '3.7'
services:
traefik:
image: traefik:v2.3.1
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
command:
- --log.level=INFO
- --api
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.websecure.address=:443
- --entrypoints.websecure.http.tls=true
labels:
traefik.enable: 'true'
# Dashboard
traefik.http.routers.traefik.rule: Host(`traefik.localhost`)
traefik.http.routers.traefik.service: api@internal
# Redirection from https://abc.localhost (or http://abc.localhost) to https://xyz.localhost
traefik.http.routers.domain.rule: Host(`abc.localhost`)
traefik.http.routers.domain.service: noop@internal
traefik.http.routers.domain.middlewares: to_xyz
traefik.http.middlewares.to_xyz.redirectregex.regex: ^https?://abc\.localhost/(.*)
traefik.http.middlewares.to_xyz.redirectregex.replacement: https://xyz.localhost/$$1
# just to have xyz.localhost
whoami:
image: containous/whoami:v1.5.0
labels:
traefik.enable: 'true'
traefik.http.routers.whoami.rule: Host(`xyz.localhost`)
1 Like
geeek
October 8, 2020, 5:11am
3
Thank you so much Idez. This I would not have been able to figure out without adding a dummy service.
system
Closed
October 11, 2020, 5:11am
4
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.