Running a self-hosted app over plain HTTP is a non-starter: browsers flag it, login cookies travel unencrypted, and reverse proxies refuse to sit in front of it. The fix is free and takes about ten minutes. This guide shows how to get free SSL certificates for Docker apps with Let’s Encrypt using three setups that work on a VPS: certbot on the host, Nginx Proxy Manager, and Traefik. It also covers wildcard certificates via the DNS-01 challenge and renewal automation, so you never wake up to an expired certificate.
Pick your path: one or two containers behind your own Nginx config means certbot on the host is the most transparent. If you want a web UI and zero CLI certificate work, use Nginx Proxy Manager. If everything you run is containerized, Traefik’s built-in ACME support is the cleanest option.
What you need to get free SSL certificates for Docker apps
All three methods share the same prerequisites. First, a domain whose A record points at your VPS IP. Check it with dig +short app.example.com and confirm it returns your server’s address before touching any certificate command. Second, ports 80 and 443 must be reachable from the internet; Let’s Encrypt’s validation servers connect to them directly. Third, you need Docker and Docker Compose installed. If you have not set that up yet, see this Docker Compose install guide for Ubuntu 24.04 first, then come back.
HTTP-01 vs DNS-01: how Let’s Encrypt verifies your domain
Let’s Encrypt never asks for a password. Instead, it issues a challenge to prove you control the domain. The HTTP-01 challenge places a token file at /.well-known/acme-challenge/ on your server and asks Let’s Encrypt to fetch it over port 80. It works for single hostnames like app.example.com but cannot issue wildcards. The DNS-01 challenge instead asks you to create a DNS TXT record. It works behind firewalls and CDNs and is the only way to get a wildcard certificate. Both are free, and certificates last 90 days, so check the official Let’s Encrypt docs for current rate limits before scripting anything at scale.
Method 1: certbot on the host (standalone)
A docker certbot setup on the host is the most transparent option: certbot lives outside your containers, and certificates get mounted in as read-only files. Install certbot, then stop anything currently listening on port 80. Standalone mode needs port 80 free for the few seconds validation takes:
sudo apt update && sudo apt install -y certbot
sudo certbot certonly --standalone
-d app.example.com
--email [email protected]
--agree-tos --no-eff-email
Certbot writes the certificate to /etc/letsencrypt/live/app.example.com/. Mount the two files your app needs into the container read-only:
services:
app:
image: myapp:latest
ports:
- "8443:443"
volumes:
- /etc/letsencrypt/live/app.example.com/fullchain.pem:/certs/fullchain.pem:ro
- /etc/letsencrypt/live/app.example.com/privkey.pem:/certs/privkey.pem:ro
Point your app’s TLS config (Nginx, Caddy, or the app’s own HTTPS listener) at /certs/fullchain.pem and /certs/privkey.pem. The downside: every renewal rewrites those files, so your container must reload or restart to pick up the new certificate. That reload is what the renewal hook in the automation section handles.
Method 2: Nginx Proxy Manager (no CLI certificate work)
If you would rather click than type, Nginx Proxy Manager bundles Let’s Encrypt issuance into its UI. Deploy it with Compose:
services:
npm:
image: jc21/nginx-proxy-manager:latest
restart: unless-stopped
ports:
- "80:80"
- "81:81"
- "443:443"
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
Open the admin panel on port 81 (default login [email protected] / changeme; change it immediately), then go to Proxy Hosts → Add Proxy Host. Enter your domain plus your app’s container hostname and port (for example app:8080 on the shared Docker network). Switch to the SSL tab, choose Request a new SSL Certificate, enter your email, tick Force SSL and HTTP/2 Support, and save. NPM requests the certificate, installs it, and renews it automatically — no cron job needed. NPM is the friendliest of the three options in this reverse proxy comparison for self-hosted apps, and the one I recommend to anyone who manages their VPS through a browser.
Method 3: Traefik with built-in ACME
With traefik acme ssl issuance handled inside the proxy, your app containers need zero TLS configuration. Traefik terminates HTTPS and fetches certificates automatically when the first request arrives. A minimal Compose setup:
services:
traefik:
image: traefik:v3
command:
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --providers.docker=true
- [email protected]
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
- --certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./letsencrypt:/letsencrypt
app:
image: myapp:latest
labels:
- "traefik.http.routers.app.rule=Host(`app.example.com`)"
- "traefik.http.routers.app.entrypoints=websecure"
- "traefik.http.routers.app.tls.certresolver=myresolver"
Two details trip up almost everyone. First, create the storage file yourself and lock its permissions before starting Traefik: touch ./letsencrypt/acme.json && chmod 600 ./letsencrypt/acme.json. Traefik refuses to write to a file with loose permissions. Second, while testing, point the resolver at the staging server (--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory) so failed attempts don’t burn your weekly rate limit, then remove the flag once it works.
Wildcard certificates with the DNS-01 challenge
A single dns-01 wildcard certificate covers app1.example.com, app2.example.com, and any subdomain you invent next month — no reissuing. That makes it ideal when you keep adding services: after you self-host Vaultwarden, then add a second app on the same domain. The trade-off: your DNS provider needs an API, and you must store an API token on the server.
With certbot and Cloudflare DNS, install the plugin and request the certificate:
sudo apt install -y python3-certbot-dns-cloudflare
printf 'dns_cloudflare_api_token = YOUR_TOKENn' > ~/.secrets/cloudflare.ini
chmod 600 ~/.secrets/cloudflare.ini
sudo certbot certonly --dns-cloudflare
--dns-cloudflare-credentials ~/.secrets/cloudflare.ini
-d example.com -d '*.example.com'
--email [email protected] --agree-tos --no-eff-email
Traefik supports the same challenge natively. Replace the HTTP challenge flags with --certificatesresolvers.myresolver.acme.dnschallenge.provider=cloudflare and pass the token as an environment variable (CF_DNS_API_TOKEN). Keep that token in a .env file never committed to git, and scope it to DNS edit on the single zone if your provider allows it.
Automate renewal so certificates never expire
For docker ssl renewal with certbot, the package ships a systemd timer that runs certbot renew twice a day. Verify it exists with systemctl list-timers | grep certbot. Certificates only renew when fewer than 30 days remain. The missing piece is telling your container about the new files: add a deploy hook.
sudo mkdir -p /etc/letsencrypt/renewal-hooks/deploy
sudo tee /etc/letsencrypt/renewal-hooks/deploy/restart-app.sh > /dev/null <<'EOF'
#!/bin/sh
cd /opt/myapp && docker compose restart app
EOF
sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/restart-app.sh
sudo certbot renew --dry-run
The --dry-run uses the staging server and proves the whole chain — validation, issuance, hook — works without touching your live certificate. Nginx Proxy Manager and Traefik handle renewal internally and need no hooks; Traefik checks expiry on every request and renews in the background. One habit worth keeping: a monthly calendar reminder to glance at your certificates. Automation fails silently, and a 30-second check beats explaining downtime.
Fix the failures you will actually hit
Port 80 blocked. HTTP-01 validation connects from the public internet. If you hardened the server with a UFW firewall setup, confirm ports 80 and 443 are allowed, and check your cloud provider’s security group too. UFW means nothing if the provider firewall drops the packets first.
Rate limit errors. Let’s Encrypt allows 50 certificates per registered domain per week. Repeated failed attempts during testing count against it — that is why the staging server exists. If you hit the limit, wait it out: there is no override, and no support ticket lifts it.
Traefik never issues. Nine times out of ten it is acme.json: the file must exist before the container starts and must be mode 600. The tenth time, the container cannot reach the Docker socket or DNS has not propagated. dig +short from an outside network settles that argument.
Start with the method matching how you already run things, get one hostname working end to end, then expand to wildcards or more apps. Free SSL stopped being a project years ago. It is ten minutes of setup and a timer you never think about again.