How do I route to http://host.docker.internal:3000?

Hi, I am trying to trying to switch my setup from nginx to traefik for a more flexible HTTPS web solution. Is it possible to route traffic to an app that is not running in docker? I am able to do that with nginx via proxy_pass to http://host.docker.internal:3000. nginx is running in a docker container with custom conf. However, I don't know how to set up something of sort with traefik.

services:
  traefik:
    image: traefik:v3.0
    ports:
      - 80:80
      - 443:443
    networks:
      - traefik
    volumes:
      - ./letsencrypt:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro
    command:
      - --api.dashboard=true
      - --api=true
      - --log.level=DEBUG

      - --entrypoints.http.address=:80
      - --entrypoints.https.address=:443

      - --providers.docker=true

      # LetsEncrypt Staging Server 
      - --certificatesResolvers.letsencrypt.acme.caServer=https://acme-staging-v02.api.letsencrypt.org/directory

      - --certificatesresolvers.letsencrypt.acme.httpchallenge=true
      - --certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=http
      - --certificatesresolvers.letsencrypt.acme.email=${EMAIL}
      - --certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json
    labels:
      # Dashboard
      - "traefik.enable=true"
      - "traefik.http.routers.dashboard.rule=Host(`traefik.${DOMAIN}`) && PathPrefix(`/dashboard`)"
      - "traefik.http.routers.dashboard.service=api@internal"
      - "traefik.http.routers.dashboard.tls=true"

  whoami:
    image: traefik/whoami:v1.8
    labels:
      - traefik.http.routers.https.rule=Host(`${DOMAIN}`)
      - traefik.http.routers.https.entrypoints=https
      - traefik.http.routers.https.tls=true
      - traefik.http.routers.https.tls.certresolver=${CERT_RESOLVER}

Basically, how do I route traffic to DOMAIN from host_app:3000 with this?

Thanks!
:grinning:

Note that host.docker.internal is only available with Docker Desktop, not regular Docker.

To route to an external service, you need to create a dynamic config file with router and service, which is loaded with providers.file in static config:

http:
  routers:
    plex:
      rule: Host(`plex.example.com`)
      service: plex

  services:
    plex:
      loadBalancer:
        servers:
          - url: http://192.168.0.144:32400