Redirect path to service outsite docker

Hello traefik community,

I'm currently struggling to get a local installed service working together with my docker services.
I have running multiple services on the sub path /app1 and /app2, now I want to set to /app3 an app outside from docker that's currently running under https://[my-ip]:9090.
The app3 is cockpit that can't run under docker.
What I'm getting is only a 404 page not found, like https://[my-ip]/cockpit isn't existing.

Can I achieve this also with the new label config style in the docker compose, but keep in mind this question counts only if we get it previously working?

File: docker-compose.yml

version: '3.7'
services:
  traefik:
    restart: always
    image: traefik:v2.3.2
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    networks:
      - traefik01
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./traefik/traefik.log:/var/log/traefik.log
      - ./traefik/traefik.toml:/traefik.toml
      - ./traefik/traefik_dynamic.toml:/traefik_dynamic.toml
      - ./traefik/acme.json:/acme.json


networks:
  traefik01:
    driver: bridge

File: traefik.toml

[log]
  level = "DEBUG"
  filePath = "/var/log/traefik.log"

[entryPoints]
  [entryPoints.web]
    address = ":80"
    [entryPoints.web.http.redirections.entryPoint]
      to = "websecure"
      scheme = "https"

  [entryPoints.websecure]
    address = ":443"

[api]
  debug = true
  dashboard = true
  insecure = true

[certificatesResolvers.lets-encrypt.acme]
  email = "test@test.de"
  storage = "acme.json"
  caServer = "https://acme-staging-v02.api.letsencrypt.org/directory"
  [certificatesResolvers.lets-encrypt.acme.tlsChallenge]

[providers.docker]
  watch = true
  network = "traefik01"

[providers.file]
  filename = "traefik_dynamic.toml"

FIle: traefik_dynamic.toml

# http routing section
[http]
  [http.routers]
    # Define a connection between requests and services
    [http.routers.cockpit]
      rule = "PathPrefix(`/cockpit{regex:$$|/.*}`)"
      middlewares = ["cockpit-stripprefix"]
      # If the rule matches, forward to the cockpit service (declared below)
      service = "cockpit"
      [http.routers.cockpit.tls]
          certResolver = "lets-encrypt"
    [http.routers.api]
      service = "api@internal"
      [http.routers.api.tls]
          certResolver = "lets-encrypt"

[http.middlewares]
  [http.middlewares.cockpit-stripprefix.stripPrefix]
    prefixes = ["/cockpit"]

  [http.services]
    # Define how to reach an existing service on our infrastructure
    [http.services.cockpit.loadBalancer]
      [[http.services.cockpit.loadBalancer.servers]]
        url = "http://<my-ip>:9090/"

Nobody has a answer for my question?

I think your pathprefix is the cause. To be sure if have traefik access logs you can see what router(if any) is handling the request.

Have your tried just PathPrefix(`/cockpit`) or PathPrefix(`/cockpit/`)

1 Like

I tried it already.
But I need all sub paths redirected to the app is this wrong?

That is what PathPrefix() will do. Otherwise you would use Path()

1 Like

You sir, are my hero for today. Thanks for those responses!

1 Like