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
sharednetwork of typebridge- For this I used
172.20.0.0/16and172.20.0.11; other configurations will probably work. - Note I am no networking expert.
- For this I used
-
In Portainer, create the
castack (Certificate Authority) forstep-causingdocker-compose.step-ca.yaml- Add
PASSWORDenvironment variable and a good password in thestep-caPortainer stack:- I used
passwordbecause 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 the following on macOS to point to Step CA running on Debian 11 VM:
step ca bootstrap --ca-url https://step-ca.local:9000 --install --fingerprint <fingerprint>
-
Download
roots.pemand install on macOS usingstep certificate install ~/Downloads/roots.pem. -
In Portainer, create the
rpstack (Reverse Proxy) fortraefikusingdocker-compose.traefik.yaml. -
In the
Traefikcontainer 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.localwith IP address192.168.1.110to:services.step-ca.extra_hostsindocker-compose.step-ca.yamlservices.traefik.extra_hostsindocker-compose.traefik.yaml
- Restart all stacks and containers using Portainer
- Run
publish-traefik-mdns.shto update mDNS.


