I have 2 certificates for the same exact domains example.com and *.example.com
one is private self-signed and the other is public cloudflare certificates
how can i set this up so that i can reference the self signed for the services that need to use self-signed and the cloudflare for the services that need to use the cloudflare one?
here is my current setup for the dynamic.yaml file
tls:
certificates:
# cloudflare certs for example.com and *.example.com
- certFile: "/etc/certs/cloudflare-cert.pem"
keyFile: "/etc/certs/cloudflare-key.pem"
# self-signed certs for example.com and *.example.com
- certFile: "/etc/certs/self-signed-cert.pem"
keyFile: "/etc/certs/self-signed-key.pem"
stores:
default:
defaultCertificate:
certFile: "/etc/certs/cloudflare-cert.pem"
keyFile: "/etc/certs/cloudflare-key.pem"
volume mount on traefik.yaml file
using traefik v3.2.5 from traefik dashboard
services:
traefik:
image: "traefik:v3.2"
ports:
- target: 80
published: 80
mode: host
- target: 443
published: 443
mode: host
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "/data/traefik/conf/dynamic.yaml:/etc/traefik/dynamic.yaml:ro"
- "/data/traefik/certs:/etc/certs:ro"
the dir/file permissions on host where traefik container running on
# ls -lha /data/traefik/
total 24K
drwxr-xr-x 6 root root 4.0K Jul 12 04:41 .
drwxr-xr-x 13 root root 4.0K Jul 8 09:01 ..
drwxr-xr-x 2 root root 4.0K Jul 12 04:41 certs
drwxr-xr-x 2 root root 4.0K Jul 12 04:53 conf
drwxr-xr-x 2 root root 4.0K Nov 11 2024 config
# ls -lha /data/traefik/certs/
total 48K
drwxr-xr-x 2 root root 4.0K Jul 12 04:41 .
drwxr-xr-x 6 root root 4.0K Jul 12 04:41 ..
-rw-r--r-- 1 root root 1.7K Mar 18 07:02 cloudflare-cert.pem
-rw-r--r-- 1 root root 1.7K Mar 18 07:02 cloudflare-key.pem
-rwxr-xr-x 1 root root 1.7K Jul 12 04:41 self-signed-cert.pem
-rwxr-xr-x 1 root root 1.7K Jul 12 04:41 self-signed-key.pem
# ls -lha /data/traefik/conf
total 44K
drwxr-xr-x 2 root root 4.0K Jul 12 04:53 .
drwxr-xr-x 6 root root 4.0K Jul 12 04:41 ..
-rw-r--r-- 1 root root 466 Jul 12 10:33 dynamic.yaml
so how do i update these so that app-1.yaml uses cloudflare certs
services:
app-1:
image: "app/app-1:latest"
networks:
- secret
env_file:
- .env.app-1
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.labels.node != server-a
update_config:
parallelism: 1
order: start-first
monitor: 5s
labels:
traefik.enable: "true"
traefik.docker.network: secret
traefik.http.services.app-1.loadbalancer.server.port: "8080"
traefik.http.routers.app-1-http.entrypoints: http
traefik.http.routers.app-1-http.rule: Host(`app-1.example.com`)
traefik.http.routers.app-1-https.entrypoints: https
traefik.http.routers.app-1-https.rule: Host(`app-1.example.com`)
traefik.http.routers.app-1-https.tls: "true"
networks:
secret:
external: true
and app-2.yaml uses self-signed certs?
services:
app-2:
image: "app/app-2:latest"
networks:
- secret
env_file:
- .env.app-2
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.labels.node != server-a
update_config:
parallelism: 1
order: start-first
monitor: 5s
labels:
traefik.enable: "true"
traefik.docker.network: secret
traefik.http.services.app-2.loadbalancer.server.port: "8080"
traefik.http.routers.app-2-http.entrypoints: http
traefik.http.routers.app-2-http.rule: Host(`app-2.example.com`)
traefik.http.routers.app-2-https.entrypoints: https
traefik.http.routers.app-2-https.rule: Host(`app-2.example.com`)
traefik.http.routers.app-2-https.tls: "true"
networks:
secret:
external: true