# Attempt to rewrite minimal Traefik example to use TLS does not work

**URL:** <https://community.traefik.io/t/attempt-to-rewrite-minimal-traefik-example-to-use-tls-does-not-work/15361>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [August 6, 2022, 2:58pm UTC](https://community.traefik.io/t/attempt-to-rewrite-minimal-traefik-example-to-use-tls-does-not-work/15361 "2022-08-06T14:58:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![uweschmitt](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/uweschmitt/32/5715_2.png) [@uweschmitt](https://community.traefik.io/u/uweschmitt)\
**Post date:** [August 6, 2022, 2:58pm UTC](https://community.traefik.io/t/attempt-to-rewrite-minimal-traefik-example-to-use-tls-does-not-work/15361/1 "2022-08-06T14:58:46Z")

</div>

(also posted at [docker compose - Attempt to rewrite minimal Traefik example to use TLS does not work - Stack Overflow](https://stackoverflow.com/questions/73248930/))

The minimal example from  
[https://doc.traefik.io/traefik/user-guides/docker-compose/basic-example/](https://doc.traefik.io/traefik/user-guides/docker-compose/basic-example/)  
works on my local machine. However, when I try to adapt this to use TLS I run into an issue. I'm a Traefik newbie, so I might be doing a stupid mistake.

This is my attempt:

```auto
version: "3.3"

services:

  traefik:
    image: "traefik:v2.8"
    container_name: "traefik"
    command:
      - "--log.level=DEBUG"
      - "--accesslog=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
    ports:
      - "443:443"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

  whoami:
    image: "traefik/whoami"
    container_name: "simple-service"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`127.0.0.1`)"
      - "traefik.http.routers.whoami.entrypoints=websecure"

```

So the major modification is to use `"traefik.http.routers.whoami.entrypoints=websecure"` instead of `"traefik.http.routers.whoami.entrypoints=web"`

Running

```auto
$ curl -k https://127.0.0.1

```

I get

```auto
404 page not found

```

The traefik log shows no routing related issues and the internal traefik setup for routing etc shown using `curl https://127.0.0.1:8080/api/rawdata | jq .` looks the same as the one of the working example, except the changed port.

---

<div class="post-metadata">

**Author:** ![swiver](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@swiver](https://community.traefik.io/u/swiver)\
**Post date:** [August 7, 2022, 10:36pm UTC](https://community.traefik.io/t/attempt-to-rewrite-minimal-traefik-example-to-use-tls-does-not-work/15361/2 "2022-08-07T22:36:00Z")

</div>

You must explicitly define a network for your docker containers, just add:

```auto
    networks:
      - rproxy

```

to both your traefik container and your whoami container

then define the network at the bottom of dockercompose.yml

```auto
networks:
  rproxy:
    name: rproxy
    external: true

```

---

<div class="post-metadata">

**Author:** ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)\
**Post date:** [August 7, 2022, 11:02pm UTC](https://community.traefik.io/t/attempt-to-rewrite-minimal-traefik-example-to-use-tls-does-not-work/15361/3 "2022-08-07T23:02:24Z")

</div>

Without a network defined in the compose a project wide default network is created and all service are connected to it.

This looks really straight forward, it should be working as far as I can tell.

---

<div class="post-metadata">

**Author:** ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)\
**Post date:** [August 7, 2022, 11:19pm UTC](https://community.traefik.io/t/attempt-to-rewrite-minimal-traefik-example-to-use-tls-does-not-work/15361/4 "2022-08-07T23:19:05Z")

</div>

TLS is not enabled on the entrypoint. So you can add that on the entrypoint OR on the router.

---

<div class="post-metadata">

**Author:** ![uweschmitt](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/uweschmitt/32/5715_2.png) [@uweschmitt](https://community.traefik.io/u/uweschmitt)\
**Post date:** [August 8, 2022, 8:08am UTC](https://community.traefik.io/t/attempt-to-rewrite-minimal-traefik-example-to-use-tls-does-not-work/15361/5 "2022-08-08T08:08:37Z")

</div>

Thanks! Setting TLS on the router fixed it. Setting the network did not fix it, also would have surprised me because the example without TLS worked.

---

<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:** [August 11, 2022, 8:09am UTC](https://community.traefik.io/t/attempt-to-rewrite-minimal-traefik-example-to-use-tls-does-not-work/15361/6 "2022-08-11T08:09:25Z")

</div>

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