Traefik doesn't resolve domain in WSL

Hi everyone,

i have an issue with traefik when i want to use my domain inside WSL..

Some details about my environment :

my host system is windows (11)
i have WSL2 with ubuntu (20.04) inside
and docker is installed in ubuntu

$ docker version

Client: Docker Engine - Community
 Version:           26.1.3
...

Here an example of traefik configuration :

services:
    traefik:
        image: traefik:latest
        restart: no
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - ${PROJECT_PATH}/traefik/traefik.yml:/etc/traefik/traefik.yml
            - ${PROJECT_PATH}/traefik/services.yml:/etc/traefik/services.yml
            - ${PROJECT_PATH}/traefik/certs/:/etc/certs/
        labels:
            - "traefik.enable=true"
            - "traefik.http.routers.dashboard.rule=Host(`test-traefik.dev.localhost`)"
            - "traefik.http.routers.dashboard.entrypoints=http,https"
            - "traefik.http.routers.dashboard.service=api@internal"

on windows, if i try to access to http://test-traefik.dev.localhost/dashboard/#/ with any browser all is ok !
on ubuntu(wsl), if i try:

$ curl http://test-traefik.dev.localhost

curl: (6) Could not resolve host: test-traefik.dev.localhost

Globally, all domains defined with traefik is not available under WSL.
however i confirm that ports are open and listen

docker-pr 253684 root 4u IPv4 1671203 0t0 TCP *:443 (LISTEN)
docker-pr 253690 root 4u IPv6 1671210 0t0 TCP *:443 (LISTEN)
docker-pr 253709 root 4u IPv4 1672237 0t0 TCP *:80 (LISTEN)
docker-pr 253726 root 4u IPv6 1668894 0t0 TCP *:80 (LISTEN)

thanks !

Where did you define the domain to resolve to the IP?

Some browser will resolve any domain with localhost automatically to 127.0.0.1, but I don't think curl will do that.

Hi @bluepuma77 ,

thanks for you answer ! Good point to see !

on windows, my hosts file is fully commented, so probably the domain resolution come from traefik directly no !? for me, traefik listen port 80, recognize the domain and say : "ok it's for me i know the domain in your request and i can return a response...":

...
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

on WSL:

$ cat /etc/hosts

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1       localhost
127.0.1.1       MY_SUPER_ID

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters