# Using local domain in loadBalancer url

**URL:** <https://community.traefik.io/t/using-local-domain-in-loadbalancer-url/20907>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [December 29, 2023, 2:43am UTC](https://community.traefik.io/t/using-local-domain-in-loadbalancer-url/20907 "2023-12-29T02:43:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PassiveLemon](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/passivelemon/32/8037_2.png) [@PassiveLemon](https://community.traefik.io/u/PassiveLemon)\
**Post date:** [December 29, 2023, 2:43am UTC](https://community.traefik.io/t/using-local-domain-in-loadbalancer-url/20907/1 "2023-12-29T02:43:38Z")

</div>

I have 2 different hosts:  
A: Raspberry Pi 4. This is where Traefik, Pi-hole, etc, where all the ingress networking to my setup comes in from.  
B: Desktop. This is running services like Jellyfin, Navidrome, etc. This host is not reverse proxied. The services ports are exposed directly in Docker.

I tried Docker swarm networking to get Traefik to work across hosts and couldn't figure it out so I'm resorting to using http routers to access them. They look something like this:

```auto
http:
  routers:
    jellyfin-http:
      entryPoints:
        - "http"
      rule: "Host(`jellyfin.domain.com`)"
      service: "jellyfin"
      middlewares: "http-to-https"
    jellyfin-https:
      entryPoints:
        - "https"
      rule: "Host(`jellyfin.domain.com`)"
      service: "jellyfin"
      tls:
        certresolver: "http-cha"
  services:
      jellyfin:
        loadBalancer:
          servers:
            - url: "http://192.168.1.177:50096"
  middlewares:
    http-to-https:
      redirectscheme:
        scheme: "https"

```

This works well enough and saved me a lot of headaches when dealing with Docker swarm however I would like to use the local domain silver.lan instead of the IP address. I already have host A set up to use Pi-hole local DNS and resolve silver.lan to 192.168.1.177. This works fine everywhere except when used in Traefik like below:

```auto
...
services:
    jellyfin:
      loadBalancer:
        servers:
          - url: "http://silver.lan:50096"
...

```

Attaching to the container and pinging silver.lan from inside also does not work. I believe I had something similar work when I used Nginx Proxy Manager but I can't remember entirely.  
Am I missing something?

---

<div class="post-metadata">

**Author:** ![PassiveLemon](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/passivelemon/32/8037_2.png) [@PassiveLemon](https://community.traefik.io/u/PassiveLemon)\
**Post date:** [December 29, 2023, 4:08am UTC](https://community.traefik.io/t/using-local-domain-in-loadbalancer-url/20907/3 "2023-12-29T04:08:05Z")

</div>

I found 2 solutions.  
1: Add a Docker-compose extra\_hosts: entry. It works but isn't ideal.

2: Put Traefik a same user-created network as Pi-hole (which has a static IP) and, in Docker-compose for Traefik, add a dns: entry which points to the Pi-hole container static IP on the shared network. This is a much better solution. Example below:

```auto
services:
  traefik:
    image: docker.io/traefik:v2.10
    container_name: traefik
    restart: always
    ports:
      - 80:80/tcp
      - 443:443/tcp
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /home/docker/Containers/Networking/Traefik/traefik.yaml:/traefik.yaml:ro
      - /home/docker/Containers/Networking/Traefik/configs/:/configs/:ro
      - /home/docker/Containers/Networking/Traefik/acme.json:/acme.json:rw
      - /home/docker/Containers/Networking/Traefik/logs/:/logs/:rw
    read_only: true
    security_opt:
      - no-new-privileges=true
    networks:
      traefik-net:
      pihole-net:
    dns:
      - 192.168.0.2
    labels:
      traefik.enable: true
      traefik.http.routers.traefik-http.service: 'api@internal'
      traefik.http.routers.traefik-http.rule: 'Host(`xxxxx.xxxxx.xxxxx`)'
      traefik.http.routers.traefik-http.entrypoints: 'http'
      traefik.http.routers.traefik-http.middlewares: 'http-to-https'
      traefik.http.routers.traefik-https.service: 'api@internal'
      traefik.http.routers.traefik-https.rule: 'Host(`xxxxx.xxxxx.xxxxx`)'
      traefik.http.routers.traefik-https.entrypoints: 'https'
      traefik.http.routers.traefik-https.tls: true
      traefik.http.routers.traefik-https.tls.certresolver: 'http-cha'
      traefik.http.routers.traefik-https.middlewares: 'traefik-auth'
      traefik.http.middlewares.http-to-https.redirectscheme.scheme: 'https'
      traefik.http.middlewares.traefik-auth.basicauth.users: 'xxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

  pihole:
    image: docker.io/pihole/pihole:latest
    container_name: pihole
    restart: always
    ports:
      - 53:53/tcp
      - 53:53/udp
      - 40180:80/tcp
    volumes:
      - /home/docker/Containers/Networking/PiHole/dns_config/:/etc/dnsmasq.d/
      - /home/docker/Containers/Networking/PiHole/pihole/:/etc/pihole/
    environment:
      TZ: 'America/New_York'
      WEBPASSWORD: 'xxxxxxxxxxxxxxxx'
      FTLCONF_REPLY_ADDR4: '192.168.1.178'
      PIHOLE_DNS_1: '127.0.0.1#40153' # I use Unbound
    networks:
      pihole-net:
        ipv4_address: 192.168.0.2
    cap_add:
      - NET_ADMIN
      - SYS_NICE

networks:
  traefik-net:
    name: traefik-net
    driver: bridge

  pihole-net:
    name: pihole-net
    ipam:
      driver: default
      config:
        - subnet: 192.168.0.0/24
          gateway: 192.168.0.1

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [January 1, 2024, 4:09am UTC](https://community.traefik.io/t/using-local-domain-in-loadbalancer-url/20907/4 "2024-01-01T04:09:00Z")

</div>

Closed on January 1, 2024, 4:09am UTC

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