# Access service by hostname

**URL:** <https://community.traefik.io/t/access-service-by-hostname/5875>\
**Category:** Traefik v2\
**Tags:** cli, docker\
**Created:** [May 4, 2020, 1:21pm UTC](https://community.traefik.io/t/access-service-by-hostname/5875 "2020-05-04T13:21:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ariedel](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@ariedel](https://community.traefik.io/u/ariedel)\
**Post date:** [May 4, 2020, 1:21pm UTC](https://community.traefik.io/t/access-service-by-hostname/5875/1 "2020-05-04T13:21:54Z")

</div>

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:

```auto
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

```auto
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,

```auto
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.

```auto
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
