Learning repo for an example Git-backed Portainer Implementation
Setting up Smallstep's open-source Certificate Authority (step-ca
) on Portainer and routing with Traefik as a Reserve Proxy for SSL certs on .local
domains.
THESE ARE PRIMARILY JUST NOTES AND NEED TO BE FULLY TESTED.
-
This assumes Portainer is running on a VM
- in my case it was a Debian 11 VM on VMware ESXi v7.3
-
Set up the Portainer server:
sudo su mkdir -p "/etc/traefik" mkdir -p "/etc/step" chown 777 "/etc/step"
-
Make sure your host is running the latest version of
docker-compose
. -
Create the
shared
network of typebridge
- For this I used
172.20.0.0/16
and172.20.0.11
; other configurations will probably work. - Note I am no networking expert.
- For this I used
-
In Portainer, create the
ca
stack (Certificate Authority) forstep-ca
usingdocker-compose.step-ca.yaml
- Add
PASSWORD
environment variable and a good password in thestep-ca
Portainer stack:- I used
password
because this is just a proof-of-concept
- I used
- Capture CA administrative username (
step
?), password (password
?) and Root Fingerprint from the Step CA container logs into a safe place such as your Password Manager.
- Add
-
Download file from https://step-ca.local:9000/roots.pem
-
Run
step ca bootstrap --ca-url https://step-ca.local:9000 --install --fingerprint <fingerprint>
on macOS to point to Step CA running on Debian 11 VM: -
Download
roots.pem
and install on macOS usingstep certificate install ~/Downloads/roots.pem
. -
In Portainer, create the
rp
stack (Reverse Proxy) fortraefik
usingdocker-compose.traefik.yaml
. -
In the
Traefik
container do this (CRITICAL!):
cd /etc/step/certs
cp root_ca.crt /etc/ssl/certs
update-ca-certificates
In the following screenshot m3
at the top is a Bash Macro which runs the command docker exect -it rp-traefik.local-1 sh
.
You can see what m3
is defined to be at the bottom of the screenshot.
12. In the
Portainer
VM do this:
sudo cp root_ca.crt /etc/ssl/certs
sudo update-ca-certificates
See: How to make Traefik trust our company CA for letsencrypt cert generation?.
- Google (or at least Bing) doesn't appear to index Traffic Community forums (verify this first)
- Apparently the ACME request has to go through Traffic in order to work; i.e. you can't just use internal Docker DNS names (verify).
Run sudo visudo
then add to /etc/sudoers
:
<username> ALL=(ALL) NOPASSWD: /usr/bin/rsync
To add a new domain from a new container — e.g. example.local
— you need to do at least these things:
- Add labels to Docker Compose, i.e.:
- "traefik.enable=true" - "traefik.http.routers.wordpress.rule=Host(`example.local`)" - "traefik.http.routers.wordpress.service=example@docker" - "traefik.http.routers.wordpress.entrypoints=websecure,web" - "traefik.http.routers.wordpress.tls.certresolver=default" - "traefik.http.routers.wordpress.tls.domains[0].main=example.local" - "traefik.http.services.wordpress.loadbalancer.server.port=80"
- Add entries for
example.local
with IP address192.168.1.110
to:services.step-ca.extra_hosts
indocker-compose.step-ca.yaml
services.traefik.extra_hosts
indocker-compose.traefik.yaml
- Restart all stacks and containers using Portainer
- Run
publish-traefik-mdns.sh
to update mDNS.