Can't get proxying to external server to work with Docker

I'm not sure what I'm doing wrong here. Basically, what I want (to begin with) is a simple reverse proxy from our external server (say, with the URL www.foobar.com and the IP 1.2.3.4 to an internal server with the IP 192.168.2.31 which is running a webserver listening on port 80.

For this simple example, I don't want to putz around with TLS or anything else. Just an incoming request to 1.2.3.4:80 which is then routed to 192.168.2.31:80

Problem is that Traefik always yields a 404 and I'm not seeing any errors in the logs (or even if I'm looking at the correct logs).

So, this is the docker-compose.yml:

version: '3'

services:
  traefik:
    image: traefik:v2.9
    container_name: traefik
    restart: unless-stopped
    network_mode: "host"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./data/traefik.yml:/etc/traefik/traefik.yml
      - /etc/localtime:/etc/localtime:ro

I also tried the default network_mode and exposed port 80 - didn't make any difference. Also note that if I try to do wget 192.168.2.31 from inside the docker container with docker exec -it traefik bin/sh I do indeed get the proper index.html with the correct content.

The traefik.yml looks like this (and according to the logs it is indeed loaded - after all, the dashboard at www.foobar.com:8080 is loading!):

api:
  dashboard: true
  insecure: true
  debug: true

entryPoints:
  http:
    address: ":80"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

http:
  routers:
    test:
      entryPoints:
        - "http"
      rule: "Host(`www.foobar.com`)"
      service: test

services:
  test:
    loadBalancer:
      servers:
        - url: "http://192.168.2.31:80"

log:
  level: DEBUG

I do not understand where the problem lies - it also doesn't help that I'm not seeing any errors. Any ideas?

Routers and services are dynamic configuration and can not be placed in static configuration traefik.yml. You need to create an additional file, for example traefik-dynamic.yml, and load it via provider.file in your static config.

Hello @Rhywden Is you issue fixed? I created the dynamic configuration and loaded it. I still run into the 404 Page Not Found.

Check simple Traefik external example. Note it uses Swarm, so labels are placed under deploy section.

Enable and check Traefik dashboard and debug log.