Access service by hostname

Hello forum,
First of all: I am relative new dealing with Traefik.
Nevertheless, I was able to google a few things together and have already written a docker-compose with which I can address my services:

version: "3.3"

services:
  traefik_reverseproxy:
    container_name:  traefik_rp
    image:           traefik:v2.2
    command:
      -              --entrypoints.web.address=:80
      -              --entrypoints.websecure.address=:443
      -              --providers.docker
      -              --api.insecure
      -              --certificatesresolvers.leresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
      -              --certificatesresolvers.leresolver.acme.email=lutz.lustig@lummerland.de
      -              --certificatesresolvers.leresolver.acme.storage=/acme.json
      -              --certificatesresolvers.leresolver.acme.tlschallenge=true
    ports:
      -              "80:80"
      -              "443:443"
      -              "8080:8080"
    volumes:
      -              /var/run/docker.sock:/var/run/docker.sock
      -              ./acme.json:/acme.json
    networks:
      -              sh_trfk

  whoami_1:
    container_name:  who1
    image:           containous/whoami
    labels:
      -              "traefik.http.routers.whoami_1.rule=Host(`who1.localhost`) || (Host(`localhost`) && Path(`/who1`))"
    networks:
      -              sh_trfk

  whoami_2:
    container_name:  who2
    image:           containous/whoami
    labels:
      -              "traefik.http.routers.whoami_2.rule=Host(`who2.localhost`) || (Host(`localhost`) && Path(`/who2`))"
      -              "traefik.http.routers.whoami_2.entrypoints=websecure"
      -              "traefik.http.routers.whoami_2.tls.certresolver=leresolver"
    networks:
      -              sh_trfk

networks:
  sh_trfk:

now my services can be reached with localhost

curl http://who1.localhost
curl http://localhost/who1
curl -k https://who2.localhost
curl -k https://localhost/who2

But actually I want to be able to address the services via their HOSTNAME,

curl http://who1.theNameOfMyHost
curl http://theNameOfMyHost/who1
curl -k https://who2.theNameOfMyHost
curl -k https://theNameOfMyHost/who2

or in the last instance they should be accessible via a DNS that I have set up at SPDNS.

curl http://who1.xyz.spdns.de
curl http://xyz.spdns.de/who1
curl -k https://who2.xyz.spdns.de
curl -k https://xyz.spdns.de/who2

How do I get it done?

TIA
Andreas

1 Like