Route website using masking

Is there a way I can for abc.xyz.com -> .xyz Domain Names | Join Generation XYZ with masking so users address in browser would stay abc.xyz.com. I know some dns allows to forward with masking.

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.

Thanks

Hello @geeek,

If you use the AddPrefix Middleware (AddPrefix - Traefik), you can add the prefix to the path, and route to a new domain.

abc.foo.bar -> addprefix -> abc.foo.bar/abc -> route to -> foo.bar/abc

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"

Hello @geeek,

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).

Not working spent hours trying to figure. Below one did not work.

 - "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.middlewares=xyz-add-prefix,xyzhost" # Add the path prefix, and change the host
  - "traefik.http.middlewares.xyz-add-prefix.addprefix.prefix=/xyz" # Add the path prefix
  - "traefik.http.middlewares.xyzhost.headers.customrequestheaders.Host=foo.bar" #change the host

This one worked but only directs to the main page.

 - "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.middlewares=xyzhost" # Add the path prefix, and change 
  - "traefik.http.middlewares.xyzhost.headers.customrequestheaders.Host=foo.bar" #change the hos