I'm sooo close to getting Traefik to route PathPrefix to a port on the server!

I'm trying to forward home.example.com/storj to port 14002 where the Storj Node dashboard lives. I think I'm close, but it's still not working. Here's what I've got:

traefik.yml

entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"
api:
  dashboard:true
providers:                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  docker:                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    endpoint: "unix:///var/run/docker.sock"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    exposedByDefault: false                                                                                                                                                                                                                                  
    watch: true

traefik docker-compose.yml

version: '3'

services:
  reverse-proxy:
    image: traefik:v2.11
    ports:
      - "80:80"
      - "443:443"
    networks:
      - traefik-proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./traefik.yml:/traefik.yml:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.api.rule=Host(`home.example.com`) || Host(`192.168.1.22`)"
      - "traefik.http.routers.api.entrypoints=http"
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
      - "traefik.http.routers.api.middlewares=redirect-to-https"
      - "traefik.http.routers.api-secure.rule=Host(`home.example.com`) || Host(`192.168.1.22`)"
      - "traefik.http.routers.api-secure.service=api@internal"
      - "traefik.http.routers.api-secure.middlewares=auth"

      - "traefik.http.middlewares.auth.basicauth.users=username:$$apr1$$kFRH3MG5$$e3d6.gCHkXKMJus84Yv1e1"
      - "traefik.http.routers.api-secure.entrypoints=https"
      - "traefik.http.routers.api-secure.tls=true"

networks:
  traefik-proxy:
    external: true

storj docker-compose.yml

version: "3.8"

services:
  storj:
    image: storjlabs/storagenode
    container_name: storagenode
    restart: unless-stopped
    ports:
      - 28967:28967/tcp
      - 28967:28967/udp
      - 14002:14002
    environment:
      - WALLET="0xthisismywallethash"
      - EMAIL="username@email.com"
      - ADDRESS="home.example.com:28967"
      - STORAGE="2TB"
    volumes:
      - type: bind
        source: /home/username/.local/share/storj/identity/storagenode
        target: /app/identity
      - type: bind
        source: /mnt/storj
        target: /app/config
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.storj.rule=(Host(`home.example.com`) || Host(`192.168.1.22`)) && PathPrefix(`/storj`)"
      - "traefik.http.services.storj.loadbalancer.server.port=14002"
      - "traefik.http.middlewares.storj-stripprefix.stripprefix.prefixes=/storj"
      - "traefik.http.routers.storj.middlewares=storj-stripprefix"
    networks:
      - traefik-proxy

networks:
  traefik-proxy:
    external: true

Everything in the Traefik dashboard says Success, but it's still not loading the page. I'm not getting an error, the page just doesn't load. It even loads the favicon! When I click on the corresponding entry in the Traefik dashboard, I see that its final routing is to the Docker internal IP, http://172.21.0.4:14002. Is that what should be happening? What am I missing?! I'm soo close!!

This belongs into the top 10 FAQs.

You can not simply place a GUI web app under a path, even if you use strip-prefix middleware.

The first page might load, but it usually contains links, script and images with absolute path names, so they can’t be loaded from the browser.

Check your browser developer tools network tab, you will see many load errors.

It only works when some kind of "base path" can be set in the GUI web application.

Best practice is to use a sub-domain instead, so the web application can run on root (/) path.

So there's no way to route to webapps using a subdir? I was trying to use PathPrefix because that seemed to be what it was for. Is a subdomain the only way for this work?

For a custom path, not root:

Wordpress for example has this option, Traefik Dashboard only works on root.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.