If there is anyother way to do it. I have a section on website lets say abc. I want users to see abx.xyz.com when we route rather .xyz Domain Names | Join Generation XYZ. I do not want to write new service for this.
hi @daniel.tomcej thank you for your response. How do I route to and what would the address bar say. Will it say xyz.foo.bar.
Can you please share an example? With the example below it redirects so link is update in browser address bar. I tried your suggestion but could not get it to work. The lines are in comments.
Goal: xyz.foo.bar(user types) -> foo.bar/xyz(redirects) -> xyz.foo.bar (browser address bar still have)
- "traefik.http.routers.foo.rule=Host(`foo.bar`)"
- "traefik.docker.network=net"
- "traefik.http.routers.foo.entrypoints=websecure"
- "traefik.http.routers.foo.tls.certresolver=myhttpchallenge"
- "traefik.http.services.foo.loadbalancer.server.port=3001"
- "traefik.http.routers.xyz.rule=Host(`xyz.foo.bar`)"
- "traefik.http.routers.xyz.service=noop@internal"
# - "traefik.http.services.xyz.loadbalancer.server.port=3008" # is this even needed
# - "traefik.http.routers.xyz.middlewares=xyz-add-prefix"
# - "traefik.http.middlewares.xyz-add-prefix.addprefix.prefix=/xyz"
You are correct with the addprefix middle, but you will also need to change the host using the Headers middleware too. somethieng like this:
- "traefik.http.routers.foo.rule=Host(`xyz.foo.bar`)"
- "traefik.docker.network=net"
- "traefik.http.routers.foo.entrypoints=websecure"
- "traefik.http.routers.foo.tls.certresolver=myhttpchallenge"
- "traefik.http.routers.foo.middlewares=xyz-add-prefix,foohost" # Add the path prefix, and change the host
- "traefik.http.middlewares.xyz-add-prefix.addprefix.prefix=/xyz" # Add the path prefix
- "traefik.http.middlewares.foohost.headers.customrequestheaders.Host=foo.bar" #change the host
- "traefik.http.services.foo.loadbalancer.server.port=3001"
You will note that this configuration only modifies the request coming in, and does not redirect at all. This will allow the URL in the address bar to be unmodified. Please note that your application may not be aware of the original URL, and as such may reference URLS and files and generate redirects based on the request it receives (foo.bar/xyz).