Can't serve content, 404 error

I'm trying to put Gogs behind a reverse proxy using Traefik and Docker. I've swapped out the sensitive information.

docker-compose.yml

version: "3.9"
services:
  gogs:
    image: gogs/gogs
    #ports:
    #  - "10880:3000"
    expose:
      - 3000
    restart: unless-stopped
    volumes:
      - ./gogs/data:/data
    labels:
      - "traefik.http.routers.gogs.rule=Host(`internal.example.com`) && Path(`/gogs`)"
      - "traefik.http.routers.gogs.tls=true"
      - "traefik.http.services.gogs.loadbalancer.server.port=3000"
      #- "traefik.http.routers.gogs.entrypoints=websecure"
      - "traefik.http.routers.gogs.tls.certresolver=le"
  traefik:
    image: traefik:v2.6
    ports:
      - "80:80"
      - "443:443"
    restart: unless-stopped
    labels:
      # Dashboard
      - "traefik.http.routers.traefik.rule=Host(`internal.example.com`)"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.middlewares=admin"
      - "traefik.http.routers.traefik.tls.certresolver=le"
      - "traefik.http.routers.traefik.entrypoints=websecure"
      - "traefik.http.middlewares.admin.basicauth.users=admin:XXX"
    
    command:
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --providers.docker
      - --api
      - --certificatesresolvers.le.acme.email=me@example.com
      - --certificatesresolvers.le.acme.storage=/acme.json
      - --certificatesresolvers.le.acme.tlschallenge=true
      
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik/acme.json:/acme.json

Going to the Traefik dashboard works fine, there are no errors shown. Trying to go to Gogs at [ https://internal.example.com/gogs redirects to the Gogs login at [ https://internal.example.com/gogs/user/login as it should, but only gives a "404 page not found" error.

I'm totally at a loss of what to do from here.

Try using PathPrefix instead of Path.

Path matches exactly. Right now you're likely getting the redirect from the landing page but no route matches /gogs/user/login .

I think it was a slight improvement, but I'm not out of the woods. I'm now getting a fancier 404 message. Rather than a plain text message, I'm getting a more formal "No webpage was found for the web address" message.

Which would indicate you're getting the 404 from the backend service.

If the service is not serving on /gogs path then you're likely going to use stripPrefix middleware with the router. Sometimes it is enough to update configuration for the service itself to run behind a rev proxy with a path prefix.

1 Like