Requests with https lead to 404, traefik v2.10 and a simple docker-compose file

Hello everybody.

I'm trying to get https requests to route to a docker container.
I have a very simple docker-compose file with the following configuration. No other config file.

version: "3"

services:
  reverse-proxy:
    image: traefik:v2.10
    command:
      --api.insecure=true
      --api.dashboard=true
      --api.debug=true
      --providers.docker
      --entryPoints.web.address=:80
      --entryPoints.websecure.address=:443
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - traefik
  whoami:
    image: traefik/whoami
    labels:
      - "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
      - "traefik.http.routers.whoami.entrypoints=websecure"
      - "traefik.http.routers.whoami.tls=true"
    networks:
      - traefik

  api:
    build: # ...
    labels:
      - "traefik.http.routers.api.rule=Host(`api.localhost`)"
      - "traefik.http.routers.api.entrypoints=websecure"
      - "traefik.http.routers.api.tls=true"
    networks:
      - traefik

networks:
  traefik:
    name: traefikExt
    driver: bridge

Calling the api with http requests returns an OK response, but https returns 404.

Curl with http:

$ curl -H Host:api.localhost http://127.0.0.1
API IS LIVE

Curl with https:

$ curl --insecure -H Host:api.localhost https://127.0.0.1
404 page not found

Curiously, the whoami service does work with https, even though they seem to have the exact same tags in the docker-compose file.

$ curl --insecure -H Host:whoami.docker.localhost https://127.0.0.1
Hostname: 079b95fbd67f
...

On the contrary, whoami actually returns 404 when queried with http.

Could you help me understand why this happens and how could I get https routing correctly to my service? I'm very new to traefik and there are some very similar topics already, but probably none with quite as simple of a case as mine, so sorry if I'm missing something very obvious.

You enable TLS on router, but have no certs loaded nor a certresolver declared.

I recommend to declare TLS globally on https entrypoint and then use either a certresolver or load certs in a dynamic config file.

Maybe compare with simple Traefik example.

Thank you,
No longer getting 404 after mounting a local directory to a volume at /letsencrypt and adding the lines:

      - "--entrypoints.websecure.http.tls.certresolver=myresolver"
      - "--certificatesresolvers.myresolver.acme.email=my@email.com"
      - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"

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