Reverse proxy with subfolder: 404 on all assets except index.html

Hi everyone,

I am asking for help as I'm trying to set up Traefik as a reverse proxy for Sonarr. The server is on the local network and Sonarr is normally reachable with the addres:

http://server.fritz.box:8989

I am trying to have sonarr reachable by following the path:

http://server.fritz.box/sonarr

Within Sonarr I have added the URL Base setting:


But unfortunately whenever I connet to http://server.fritz.box/sonarr I can only download the index.html while all the other resources give me 404:

I am pretty sure I am doing something wrong in setting up the router or perhaps I have to add a middleware.

Can someone help me?

Traefik compose file:

version: '2'

services:
  traefik:
    container_name: traefik
    image: traefik
    hostname: traefik
    domainname: fritz.box
    command: 
      - --accesslog=true
      - --api.insecure=true 
      - --providers.docker
      - --providers.docker.exposedbydefault=false
      - --entrypoints.web.address=:80
      - --providers.docker.network=reverse_proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - reverse_proxy
    ports:
      - 8080:8080
      - 80:80
    restart: unless-stopped
networks:
  reverse_proxy:
    external:
      name: reverse_proxy

sonarr compose file

---
version: "2"  
services:
  sonarr:
    image: linuxserver/sonarr
    container_name: sonarr
    environment:
      - PUID=1001
      - PGID=100
      - TZ=Europe/Rome
    volumes:
      - /etc/localtime:/etc/localtime
      - /path/to/config/sonarr:/config
    ports:
      - 8989:8989
    restart: unless-stopped
    networks:
      - reverse_proxy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.sonarr.rule=Path(`/sonarr`)"
networks:
  reverse_proxy:
    external:
      name: reverse_proxy

Hello,

you have to replace:

      - "traefik.http.routers.sonarr.rule=Path(`/sonarr`)"

by

      - "traefik.http.routers.sonarr.rule=PathPrefix(`/sonarr`)"

Thank you! it worked!
Hoiwever this only seems to work if the application I run is able to configure the "base URL path".

Other applications that are natively accessed in a fashion http://host.domain.com/ (like Netdata) does not allow to set the base path.
If I use:
- "traefik.http.routers.netdata.rule=PathPrefix(/netdata)"
then I get a 404 as the service cannot find /netdata/index.html
I tried using
- "traefik.http.middlewares.netdata-strip.stripprefix.prefixes=/netdata"
but then all the resources are not loaded.

192.168.178.38 - - [22/Mar/2020:08:18:12 +0000] "GET /netdata HTTP/1.1" 200 20184 "-" "-" 63 "netdata@docker" "http://172.27.0.4:19999" 12ms
192.168.178.38 - - [22/Mar/2020:08:18:12 +0000] "GET /main.css?v=5 HTTP/1.1" 404 19 "-" "-" 68 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:12 +0000] "GET /main.js?v20190905-0 HTTP/1.1" 404 19 "-" "-" 69 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:12 +0000] "GET /images/netdata-logomark.svg HTTP/1.1" 404 19 "-" "-" 70 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:12 +0000] "GET /dashboard.js?v20190902-0 HTTP/1.1" 404 19 "-" "-" 71 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:46 +0000] "GET /main.css?v=5 HTTP/1.1" 404 19 "-" "-" 72 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:46 +0000] "GET /images/netdata-logomark.svg HTTP/1.1" 404 19 "-" "-" 74 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:46 +0000] "GET /dashboard.js?v20190902-0 HTTP/1.1" 404 19 "-" "-" 75 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:46 +0000] "GET /main.js?v20190905-0 HTTP/1.1" 404 19 "-" "-" 76 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:46 +0000] "GET /netdata HTTP/1.1" 200 20184 "-" "-" 73 "netdata@docker" "http://172.27.0.4:19999" 11ms
192.168.178.38 - - [22/Mar/2020:08:18:46 +0000] "GET /main.css?v=5 HTTP/1.1" 404 19 "-" "-" 77 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:46 +0000] "GET /main.js?v20190905-0 HTTP/1.1" 404 19 "-" "-" 78 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:46 +0000] "GET /images/netdata-logomark.svg HTTP/1.1" 404 19 "-" "-" 79 - - 0ms
192.168.178.38 - - [22/Mar/2020:08:18:46 +0000] "GET /dashboard.js?v20190902-0 HTTP/1.1" 404 19 "-" "-" 80 - - 0ms

I sense that the main request comes in a form http://host.domain.com/netdata but then the page refers all the other resources as /main.css, so traefik is receiving requests like:
http://host.domain.com/main.css which is not present of course.
Is there any way to apply the /netdata to all the requests coming from that page?