'Traefik serving SSL certificate as invalid

Traefik is setup, redirecting to https and seems to be configured correctly. However, when I try to access my project in the browser, the certificate is untrusted with a NET::ERR_CERT_INVALID error:

enter image description here

enter image description here

I can SSH into the container and cat the certificate files and it looks like docker is mounting the files and carrying over permissions as expected.


Locally, I've generated my certificate:

openssl req -x509 -newkey rsa:4096 -keyout infrastructure/certs/mysite-dev.com.key -out infrastructure/certs/mysite-dev.com.crt -days 10000 -nodes -subj "/C=US/ST=State/L=City/O=cicd/CN=mysite-dev.com"

Adjusted permissions using:

chmod 644 infrastructure/certs/*.crt 
chmod 600 infrastructure/certs/*.key

traefik-conf.yml

tls:
  certificates:
    - certFile: /certs/mysite-dev.com.crt
      keyFile:  /certs/mysite-dev.com.key
      stores:
        - default

  stores:
    default: { }

Here's my relevant compose configuration:

services:

  web:
    build:
      context: .
      dockerfile: infrastructure/web/Dockerfile
    image: registry.gitlab.com/my-org/my-project:web
    env_file: .env
    volumes:
      - ./:/var/www/html
      - ./infrastructure/web:/etc/nginx/conf.d
    depends_on:
      - redis
      - db
    labels:
      traefik.enable: true
      traefik.http.routers.mysite-web.entrypoints: web,websecure
      traefik.http.middlewares.mysite-web.redirectscheme.scheme: https
      traefik.http.middlewares.mysite-web.redirectscheme.permanent: true
      traefik.http.routers.mysite-web.tls: true
      traefik.http.routers.mysite-web.rule: Host(`mysite-dev.com`)
      traefik.http.services.mysite-web.loadbalancer.server.port: 80
  traefik:
    command:
      - --api.dashboard=true
      - --api.insecure=true
      - --accesslog=true
      - --providers.docker.exposedbydefault=false
      - --providers.docker=true
      - --entryPoints.web.address=:80
      - --entryPoints.websecure.address=:443
      - --providers.file.filename=/conf/dynamic.yml
    image: traefik:2.7
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./infrastructure/certs:/certs:ro
      - ./infrastructure/traefik-conf.yml:/conf/dynamic.yml:ro


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source