Simple PathPrefix rule results in "Gateway Timeout"

I've set up a simple router with rule PathPrefix(`/me`) but requests are not routed and instead I get

Gateway Timeout

(E.g. by calling http://my-server-name.com/me/)
Does anyone have an idea why it is not working? Any suggestions are welcome :slight_smile:

What is working is http://my-server-name.com:8000/me/ so the service (nginx server) is up and running correctly; only the routing is not working.

A minimal (non-)working example is: docker-compose.yml:

version: '3'

services:
  traefik:
    image: traefik:v2.0.5
    ports:
    - 80:80
    - 443:443
    - 8080:8080  # traefik GUI
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - ./traefik.yml:/etc/traefik/traefik.yml
    restart: always
    networks:
      - webgateway
      
  nginx:
    image: nginx
    ports:
      - 8000:80
    volumes:
      - /home/user/html/:/usr/share/nginx/html:ro
    restart: always
    labels:
      # traefik basic
      - "traefik.enable=true"
      - "traefik.docker.network=webgateway"
      # traefik actual router
      - "traefik.http.routers.testr.entrypoints=web"
      - "traefik.http.routers.testr.rule=PathPrefix(`/me`)"
      # traefik service
      - "traefik.http.services.tests.loadbalancer.server.port=80"

networks:
  webgateway:
    driver: bridge

traefik.yml:

entryPoints:
  web:
    address: ':80'
  web-secure:
    address: ':443'
  traefik:
    address: ':8080'

providers:
  docker:
    watch: true
    exposedByDefault: false

api:
  insecure: true
  dashboard: true
  debug: true

log:
  level: DEBUG

(I've also tried playing with port like traefik.http.services.tests.loadbalancer.server.port=8000 etc, but it was pointed out to me in "Non-existent resolver: using docker + letsencrypt in static config" that it should be 80)

Seems to work without the network.

version: '3'

services:
  traefik:
    image: traefik:v2.0.5
    restart: always
    ports:
    - 80:80
    - 443:443
    - 8080:8080  # traefik GUI
    # networks:
    #   - webgateway
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    command:
      - --entrypoints.web.address=:80
      - --entrypoints.web-secure.address=:443
      - --providers.docker
      - --providers.docker.exposedbydefault=false
      - --api.insecure
      - --log.level=DEBUG

  nginx:
    image: nginx
    # restart: always
    # volumes:
      # - /home/user/html/:/usr/share/nginx/html:ro
    labels:
      # traefik basic
      traefik.enable: true
      # traefik.docker.network: webgateway

      # traefik actual router
      traefik.http.routers.testr.entrypoints: web
      traefik.http.routers.testr.rule: PathPrefix(`/me`)

      # traefik service
      traefik.http.services.tests.loadbalancer.server.port: 80

# networks:
#   webgateway:
#     driver: bridge
$curl localhost/me

<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.17.4</center>
</body>
1 Like

Thanks, indeed. And indeed adding

    networks:
      - webgateway

to every container solved this issue.

See also "Gateway Timeout" with docker · Issue #1254 · traefik/traefik · GitHub