Redirect to path

Hi,

I have a tomcat server and when I use the domain name it adds /admin/login ie: in a browser the link server.docker.localhost changes to *server.docker.localhost/admin/login.

I've expose the port 8080 in compose file for the web server and works fine ie: http://localhost:8080

Traefik docker compose:

reverse-proxy:
    image: traefik
    container_name: traefik
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    ports:
      - 80:80
      - 443:443
    volumes:
      # Map the docker socket into the container
      - /var/run/docker.sock:/var/run/docker.sock:ro
      # Map the static configuration into the container
      - ./config/traefik.yaml:/etc/traefik/traefik.yaml:ro
      # Map the dynamic configuration into the container
      - ./dynamic:/etc/traefik/dynamic:ro
      # Map the certificates into the container
      - ./certs:/etc/certs:ro
    # networks:
    #   - traefik
    labels:
      traefik.enable: "true"
      traefik.http.routers.traefik_https.rule: Host(`traefik.docker.localhost`)
      traefik.http.routers.traefik_https.tls: "true"
      traefik.http.routers.traefik_https.service: api@internal
      traefik.http.routers.traefik_https.middlewares: dashboard-auth
      traefik.http.middlewares.dashboard-auth.basicauth.users: eu:$$apr1$$ag8QYLef$$FxAeaJ4OFaTVnPZv/u8RL/
 

Traefik conf:

# yaml-language-server: $schema=https://www.schemastore.org/traefik-v3.json
global:
  sendAnonymousUsage: false

################################################################
# API and dashboard configuration
################################################################
api:
  insecure: false
  dashboard: true

################################################################
# Entrypoint
################################################################
entryPoints:
  web:
    address: ":80"
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https
          permanent: true

  websecure:
    address: ":443"

################################################################
# Providers
################################################################
providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
  file:
    directory: /etc/traefik/dynamic
    watch: true

################################################################
# Traefik Logging
################################################################
log:
  level: DEBUG

################################################################
# Access Logging
################################################################
accessLog: {}

 web_app:
    image: web_app
    container_name: web_app
    restart: unless-stopped
    ports:
      - 8080:8080

Dynamic configuration for the tomcat web server:

# yaml-language-server: $schema=https://www.schemastore.org/traefik-v3.json
http:
  routers:
    web_app:
      rule: Host(`server.docker.localhost`)
      tls: true
      service: web_app
     
  services:
    web_app:
      loadbalancer:
        servers:
          - url: http://server:8080

Can anyone guide me for the solution? don't give me the answer, just a direction.

Tanks

Check RedirectRegex middleware (doc).

Hi

I',m trying to configure with RedirectRegex with no success. My url adds /domibus in path but it does't goes to /login:

If i access the expossed port http://localhost:8080/domibus it will add /login:

My new dynamic file:

http:
  middlewares:
    test-redirectregex:
      redirectRegex:
        regex: "^http://gateway.docker.localhost/(.*)"
        replacement: "http://gateway.docker.localhost/domibus/"

  routers:
    gateway_app: 
      rule: Host(`gateway.docker.localhost`)
      entrypoints: 
        - web
      service: gateway_app
      middlewares:
        - test-redirectregex
     
  services:
    gateway_app:
      loadbalancer:
        servers:
          - url: http://gateway_app:8080