Redirect URL Path

Hi everybody
I ´m using traefik v2 with a dspace container and I would like to redirect the URL teste.teste.org to teste.teste.org:8080/jspui

Blockquote
labels:
- "traefik.http.routers.dsapce.rule=Host(test.test.org)"
- "traefik.enable=true"
- "traefik.http.services.dspace.loadbalancer.server.port=8080"
- "traefik.docker.network=frontend"

Can anyone help me with this ?
Thanks for all the help

Sounds like a job for RedirectRegex Middleware.

Hi zespri
First of all .. Thanks for your help
I even found this code on the Internet. I tested it but it didn't work

 - "traefik.http.middlewares.add-context.redirectregex.regex=^https:\\/\\/([^\\/]+)\\/?$"
 - "traefik.http.middlewares.add-context.redirectregex.replacement=https://$1/xyz"

I tried to put

 - "traefik.http.middlewares.add-context.redirectregex.regex=^http:\\/\\/([^\\/]+)\\/?$"
 - "traefik.http.middlewares.add-context.redirectregex.replacement=http://$1/jspui"

But not working (for me)
It's clearly something with regular expressions that I don't understand

In the simplest form this might work:

      - "traefik.http.middlewares.redirect.redirectregex.regex=http://teste.teste.org"
      - "traefik.http.middlewares.redirect.redirectregex.replacement=http://teste.teste.org:8080/jspui"

However, be mindful, that this needs to go to the router that is attached to the entry point where your request for "http://teste.teste.org" would arrive to, that is the one that corresponds port 80.

I also have a suspicion that this may be XY-Problem, in particular I'm assuming from your post that:

  • You want traefik to handle all your incoming requests, that is no request goes directly to dspace
  • Therefore you configured traefik to listen on both 80 and 8080
  • You configured you router that routes to dspace server to use the entry point that is associated with 8080 port
  • You want to issue a client side redirect (30x) from 80 to 8080 as you described in your original post.

If this is not true, than you might not be looking at the right solution right now