Jump Start Help - Traefik and SABnzbd (as an example)

Hi,

I am totally new to Docker and Traefik, but would like to do a reverse proxy for services inside Docker and using Traefik. After a little success I'm stuck and might only need a little jump start.

I've installed a test VM using Debian 12. Installed Docker (and Docker Compose) on the VM and then Traefik (now 3.x) and whoami as a docker containers through compose file. Looked into the Docker side: listing, starting (docker compose up), stopping the container, changes in the compose file, opening a shell inside Traefik container. Also inspected the Docker networks that got created (automatically) and did an explicit docker network create. Made sure I get output of http://localhost:80/api/rawdata from inside the VM as well as http://:80/api/rawdata from the host on which the VM runs.

After that I created a SABnzbd container (another compose file) and connected this container to the Docker default bridge, the formerly created docker network for Traefik, an new SABNZBD docker network and finally to the Traefik and SABnzbd network. Did a lot of name resolution and ping tests from the shell inside the Traefik and SABnzbd container and from the host. Made sure that the containers can ping each other by IPs and names and that they each have an IP on the same subnet in Docker.

Finally made SABnzbd port available to the outside and tested, that I can reach SABnzbd web page by http

  • localhost:8080 from VM
  • container-IP:8080 from VM
  • VM-IP:8080 from Host of VM

But I didn't succeed in exposing SABnzbd through Traefik. Trying to do so I get 404. The browser address bar changes from /loader to /sabnzbd/wizard though.

Here are my compose files:

services:
  traefik:
    image: "traefik:latest"
    container_name: "traefik"
    networks:
      - public
      - proxy
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
    ports:
      - "80:80"
      - "8090:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    labels:
      - "traefik.enable=true"

  whoami:
    image: "traefik/whoami"
    container_name: "traefik-whoami"
    networks:
      - public
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.entrypoints=web"

networks:
  public:
    name: public-web
    external: true
  proxy:
    name: internal-proxy
    external: true
services:
  sabnzbd:
    image: lscr.io/linuxserver/sabnzbd:latest
    container_name: sabnzbd
    restart: unless-stopped
    ports:
      - 8080:8080
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.sab.rule=PathPrefix(`/loader`)"
      - "traefik.http.services.sab.loadbalancer.server.port=8080"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.sab.entrypoints=web"
      - "traefik.http.middlewares.sab-strip.stripprefix.prefixes=/loader"
      - "traefik.http.routers.sab.middlewares=sab-strip"

networks:
  proxy:
    name: internal-proxy
    external: true

Kind regards

Compare to simple Traefik example.

Enable and check Traefik dashboard and debug log.

You can’t place any GUI web app under a path, even when using StripPrefix. The initial page usually includes absolute paths (like /static/script.js), which won’t be matched with prefix. That only works when you can set a "base path" in the web app config.

Thank you for your reply.

It's getting late and I've been scratching my head all day. I will try to understand and follow your comments tomorrow. Is the Dashboard thing from the simple example important? Traefik dashboard is already working with my compose files.

Turning on DEBUG logging is definitely the path to go.

Als I will look at SABnzbd if there is an option to set a base path. If not I understand, that I have to go for subdomain (hostname) instead of path? Can there be an intermediate config in Traefik so I can call <anything.domain>/sanzbd from the outside and Traefik will route to SABnzbd.domain and the GUI web app will work?

Yes, just use Host(`sub.example.com`), like in example.

Got it.

SABnzbd has a base path option and it is set to /sabnzbd as default - so change the path prefix in Traefik accordingly and don't strip.

Also, I want to be able to connect to SABnzbd from internet network without Traefik - expose ports in docker compose.

Traefik compose file:

services:
  traefik:
    image: "traefik:latest"
    container_name: "traefik"
    networks:
      - public
      - proxy
    command:
      - --log.level=DEBUG  # optional
      - --log.filepath=/var/log/traefik.log  # optional
      - --accesslog=true  # optional
      - --accesslog.filepath=/var/log/traefik-access.log  # optional
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
    ports:
      - "80:80"
      - "8090:8080"  # SABNzbd is running on 8080 exposed
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - ./log:/var/log  # optional
    labels:
      - "traefik.enable=true"
      - traefik.http.routers.mydashboard.entrypoints=web
      - traefik.http.routers.mydashboard.rule=Host(`portal.example.com`)
      - traefik.http.routers.mydashboard.service=api@internal
      - traefik.http.routers.mydashboard.middlewares=myauth
      - traefik.http.middlewares.myauth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/
      

  whoami:
    image: "traefik/whoami"
    container_name: "traefik-whoami"
    networks:
      - public
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.entrypoints=web"

networks:
  public:
    name: public-web
    external: true
  proxy:
    name: internal-proxy
    external: true

SABnzbd compose file:

services:
  sabnzbd:
    image: lscr.io/linuxserver/sabnzbd:latest
    container_name: sabnzbd
    ports:
      - 8080:8080 # optional - if SABnzbd should be reachable without Traefik 
    networks:
      - proxy
    volumes:
      - ./config:/config
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.sab.rule=PathPrefix(`/sabnzbd`)"
      #- "traefik.http.services.sab.loadbalancer.server.port=8080"  # not needed for SABnzbd exposes just one port
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.sab.entrypoints=web"

networks:
  proxy:
    name: internal-proxy
    external: true

Thanks for help.

1 Like