Traefik not routing to internal DNS

Hi, I'm new to Traefik and I was wondering if someone can help with the following issue.

Currently I'm trying to run Traefik with a CoreDNS private server, both in the same compose file:

networks:
  main:
    driver: bridge
    external: false

services:
  # ---
  # TRAEFIK PROXY
  # ---
  traefik:
    image: traefik:v3.2
    container_name: traefik
    restart: unless-stopped
    ports:
      - '80:80'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik/traefik.yml:/etc/traefik/traefik.yml
      - ./traefik/dynamic/:/etc/traefik/dynamic/
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: '512M'
    networks:
      - main
  # ---
  # CORE DNS
  # ---
  dns:
    container_name: dns
    image: coredns/coredns:1.11.3
    restart: unless-stopped
    volumes:
      - ./coredns/Corefile:/etc/coredns/Corefile
      - ./coredns/zones:/etc/coredns/zones
    command: -conf /etc/coredns/Corefile
    ports:
      - '53:53/tcp'
      - '53:53/udp'
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: '512M'
    labels:
      - traefik.enable=false
    networks:
      - main

I have defined my DNS records on a zone file as shown in my Corefile and my-server-com.zone

Corefile

.:53 {
    forward . 1.1.1.1 1.0.0.1
    log
    errors
}

athena.com:53 {
    file /etc/coredns/zones/my-server-com.zone
    log
    errors
}

my-server-com.zone

$TTL 86400

$ORIGIN athena.com.

@               IN      SOA     ns.my-server.com. admin.my-server.com. (
                                2024103001 ; Serial
                                12h        ; Refresh
                                15m        ; Retry
                                3w         ; Expire
                                2h)        ; Minimum TTL

                IN      NS      ns.my-server.com.

ns              IN      A       192.168.10.31

; ---
; A RECORDS
; ---

mercury         IN      A       192.168.10.30
venus           IN      A       192.168.10.31

; ---
; CNAME RECORDS
; ---

gitea           IN      CNAME   mercury.my-server.com.

The issue comes when I setup my DNS Server in my personal machine to access my domains, I don't need the to have HTTPS for now, and try to enter the domain gitea.my-server.com it doesn't works, but when I do mercury.my-server.com:3000 it works perfectly.

This is my traefik.yml file:

log:
  level: DEBUG

entryPoints:
  web:
    address: ':80'

providers:
  docker:
    exposedByDefault: false
  file:
    directory: '/etc/traefik/dynamic/'

And this is the file inside my dynamic folder:

http:
  routers:
    gitea:
      rule: "Host(`gitea.athena.com`)"
      service: gitea
      entryPoints:
        - web

  services:
    gitea:
      loadBalancer:
        servers:
          - url: "http://192.168.10.30:3000"

I know traefik is working, but it's not routing my requests. I'd be grateful if someone can help me with this.

Are you running on Linux?

What does that mean? What’s the error message? Can the domain name be resolved to an IP? Can it connect to the IP? Is the target service found?

Yes I'm running that Docker container in Linux

There's no output on the logs, like I do the request to the domain and it doesn't print anything. Also inside my container if I do

curl http://192.168.10.30:3000

The response is an HTML with the Gitea installation page. Also if I do

docker compose logs traefik

I get this:

traefik  | 2024-11-27T00:06:24Z INF github.com/traefik/traefik/v3/cmd/traefik/traefik.go:103 > Traefik version 3.2.1 built on 2024-11-20T17:39:47Z version=3.2.1
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/cmd/traefik/traefik.go:110 > Static configuration loaded [json] staticConfiguration={"entryPoints":{"web":{"address":":80","forwardedHeaders":{},"http":{"maxHeaderBytes":1048576},"http2":{"maxConcurrentStreams":250},"transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s","readTimeout":"1m0s"}},"udp":{"timeout":"3s"}}},"global":{"checkNewVersion":true},"log":{"format":"common","level":"DEBUG"},"providers":{"docker":{"defaultRule":"Host(`{{ normalize .Name }}`)","endpoint":"unix:///var/run/docker.sock","watch":true},"file":{"directory":"/etc/traefik/dynamic/","watch":true},"providersThrottleDuration":"2s"},"serversTransport":{"maxIdleConnsPerHost":200},"tcpServersTransport":{"dialKeepAlive":"15s","dialTimeout":"30s"}}
traefik  | 2024-11-27T00:06:24Z INF github.com/traefik/traefik/v3/cmd/traefik/traefik.go:626 >
traefik  | Stats collection is disabled.
traefik  | Help us improve Traefik by turning this feature on :)
traefik  | More details on: https://doc.traefik.io/traefik/contributing/data-collection/
traefik  |
traefik  | 2024-11-27T00:06:24Z INF github.com/traefik/traefik/v3/pkg/server/configurationwatcher.go:73 > Starting provider aggregator *aggregator.ProviderAggregator
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/server/server_entrypoint_tcp.go:231 > Starting TCP Server entryPointName=web
traefik  | 2024-11-27T00:06:24Z INF github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:202 > Starting provider *file.Provider
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:203 > *file.Provider provider configuration config={"directory":"/etc/traefik/dynamic/","watch":true}
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/provider/file/file.go:122 > add watcher on: /etc/traefik/dynamic/
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/provider/file/file.go:122 > add watcher on: /etc/traefik/dynamic/gitea.yml
traefik  | 2024-11-27T00:06:24Z INF github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:202 > Starting provider *traefik.Provider
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:203 > *traefik.Provider provider configuration config={}
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/server/configurationwatcher.go:227 > Configuration received config={"http":{"serversTransports":{"default":{"maxIdleConnsPerHost":200}},"services":{"noop":{}}},"tcp":{"serversTransports":{"default":{"dialKeepAlive":"15s","dialTimeout":"30s"}}},"tls":{},"udp":{}} providerName=internal
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/server/configurationwatcher.go:227 > Configuration received config={"http":{"routers":{"gitea":{"entryPoints":["web"],"rule":"Host(`gitea.athena.com`)","service":"gitea"}},"services":{"gitea":{"loadBalancer":{"passHostHeader":true,"responseForwarding":{"flushInterval":"100ms"},"servers":[{"url":"http://192.168.10.30:3000"}]}}}},"tcp":{},"tls":{},"udp":{}} providerName=file
traefik  | 2024-11-27T00:06:24Z INF github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:202 > Starting provider *docker.Provider
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:203 > *docker.Provider provider configuration config={"defaultRule":"Host(`{{ normalize .Name }}`)","endpoint":"unix:///var/run/docker.sock","watch":true}
traefik  | 2024-11-27T00:06:24Z INF github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:202 > Starting provider *acme.ChallengeTLSALPN
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:203 > *acme.ChallengeTLSALPN provider configuration config={}
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/provider/docker/pdocker.go:90 > Provider connection established with docker 27.3.1 (API 1.47) providerName=docker
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/provider/docker/config.go:184 > Filtering disabled container container=dns-homelab-2e7d74df49078abdd82eb74b0895251d96b5fe28d237eece28d743f4a4f666be providerName=docker
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/provider/docker/config.go:184 > Filtering disabled container container=traefik-homelab-798498a4924d19da5e1f92add18259df259f327988c2aadd99242369a21148af providerName=docker
traefik  | 2024-11-27T00:06:24Z DBG github.com/traefik/traefik/v3/pkg/server/configurationwatcher.go:227 > Configuration received config={"http":{},"tcp":{},"tls":{},"udp":{}} providerName=docker
traefik  | 2024-11-27T00:06:25Z DBG github.com/traefik/traefik/v3/pkg/tls/tlsmanager.go:321 > No default certificate, fallback to the internal generated certificate tlsStoreName=default
traefik  | 2024-11-27T00:06:25Z DBG github.com/traefik/traefik/v3/pkg/tls/tlsmanager.go:321 > No default certificate, fallback to the internal generated certificate tlsStoreName=default
traefik  | 2024-11-27T00:06:25Z DBG github.com/traefik/traefik/v3/pkg/server/service/service.go:318 > Creating load-balancer entryPointName=web routerName=gitea@file serviceName=gitea@file
traefik  | 2024-11-27T00:06:25Z DBG github.com/traefik/traefik/v3/pkg/server/service/service.go:355 > Creating server entryPointName=web routerName=gitea@file serverName=4f8a039f448f08d7 serviceName=gitea@file target=http://192.168.10.30:3000
traefik  | 2024-11-27T00:06:25Z DBG github.com/traefik/traefik/v3/pkg/middlewares/recovery/recovery.go:25 > Creating middleware entryPointName=web middlewareName=traefik-internal-recovery middlewareType=Recovery

And when call the domain I get this on my CoreDNS Logs:

dns  | [INFO] 192.168.10.17:56246 - 50961 "A IN gitea.my-server.com. udp 45 false 4096" NOERROR qr,aa,rd 153 0.000215679s

Enable and check Traefik access log in JSON format and check during request.

It was just a configuration issue, I didn't set up the DNS correctly. Because my DNS server was calling the IP of the VM and not the Reverse Proxy

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.