First time with Traefik... and fails!

Hi,

I try to use traefik to fill my needs for one project, I'm making a PoC.

To be simple, I have a server whith :

  • A Rundeck runing on port 4440 (directly installed)
  • A Wireguard WebUI running on port 8080 (docker)

I want to bring up Traefik with a dashboard, locked with a basic auth, and I want to have another basic auth to access Wireguard WUI.

So, I make this docker-compose file :

version: '3.6'
services:
  wg-gen-web:
    image: vx3r/wg-gen-web:latest
    container_name: wg-gen-web
    restart: unless-stopped
    environment:
    - WG_CONF_DIR=/data
    - WG_INTERFACE_NAME=wg0.conf
    volumes:
    - /etc/wireguard:/data
    labels:
    - "traefik.http.routers.wg-gen-web.entrypoints=http"
    - "traefik.enable=true"
    - "traefik.http.middlewares.wg-gen-web.basicauth.users=admin:$$apr1$$61HG58iz$$U9BVx0k/faOMv5xYm3/5d/"
    - "traefik.http.routers.wg-gen-web.rule=(Host(`10.0.0.17`) && PathPrefix(`/wg-ui`))"
    - "traefik.http.services.wg-gen-web.loadbalancer.server.port=8080"
    - "traefik.http.middlewares.strip-wg-gen-web.stripprefix.prefixes=/wg-ui"
    - "traefik.http.routers.wg-gen-web.middlewares=strip-wg-gen-web"

  reverse-proxy:
    restart: always
    image: traefik:v2.0
    ports:
    - "80:80"
    volumes:
    - /srv/traefik.toml:/etc/traefik/traefik.toml
    - /var/run/docker.sock:/var/run/docker.sock
    - /srv/services.toml:/etc/traefik/services.toml
    labels:
    - "traefik.http.routers.api.rule=Host(`10.0.0.17`)"
    - "traefik.http.routers.api.service=api@internal"
    - "traefik.http.routers.api.entrypoints=http"
    - "traefik.http.routers.api.middlewares=auth"
    - "traefik.http.middlewares.auth.basicauth.users=admin:$$apr1$$61HG58iz$$U9BVx0k/faOMv5xYm3/5d/"


My traefik.toml :

[entryPoints]
  [entryPoints.http]
  address = ":80"

[api]

[providers.docker]
  endpoint = "unix:///var/run/docker.sock"

[providers.file]
  filename = "/etc/traefik/services.toml"

[http.routers]
  [http.routers.my-router]
    rule = "Path(`/rundeck`)"
    service = "rundeck"

And, my services.toml :

[http]
  [http.services]
    [http.services.rundeck]
      [http.services.rundeck.loadBalancer]
        [[http.services.rundeck.loadBalancer.servers]]
          url = "http://127.0.0.1:4440/"

Dashboard is OK with basic auth working. But none of other service works. For wg-gen-web, if I use "PathPrefix", I get a "Bad Gateway" response, if I use "Path", a 404 error.

If anyone can help me...

Thank you!

Routers and Services are both dynamic config, they both need to go into a dynamic config file which is loaded via provider.file in static config.

Routing with PathPrefix and StripPrefix often fails with apps, because they are not path-aware. They will respond with redirects and links that are not according to your setup. Use sub-domains instead. Locally you can place them in hosts file or your DSL router DNS config.

Here is a simple Traefik example configuration.

PS: Traefik v2.0 is really old, use v2.9.