CTFd Setup Guide (Docker & HTTPS)
Fresh Ubuntu server to a live CTFd instance with HTTPS. Replace ctf.example.com and you@example.com with your real domain and email everywhere below.
1. Remove old Docker packages
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove -y $pkg; done2. Install Docker
# add Docker's GPG key
sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# add Docker's apt repo
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
# install docker
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# check it works
sudo docker run hello-world3. Run Docker without sudo
4. Clone CTFd and set a real SECRET_KEY
Clone the repo first, but don't start it yet — set a proper secret key so you only need to start the containers once.
The default docker-compose.yml ships a placeholder secret key. Replace it — weak key = forgeable sessions/cookies. Copy the output above, open the file, paste it as the SECRET_KEY value under services.ctfd.environment:
5. Start CTFd
Check http://<server-ip> in a browser — CTFd setup wizard should load. 4 containers should be running: ctfd, db, cache, nginx.
6. Point your domain at the server
In your DNS provider (not on the server), add:
A
ctf.example.com
your server's public IP
Confirm it resolves:
If using Cloudflare: keep the record DNS-only (grey cloud) until after step 7 — the cert challenge needs to reach your server directly.
7. Get an HTTPS certificate
Cert saved to /etc/letsencrypt/live/ctf.example.com/. Certbot auto-renews it going forward.
8. Turn on HTTPS in nginx
Replace conf/nginx/http.conf:
Then update docker-compose.yml so nginx exposes port 443 and can read the cert files:
9. Restart and verify
CTFd is now live at https://ctf.example.com.
10. Troubleshooting
Cloudflare shows 521
Proxy on, no cert on origin yet
Finish steps 7-8, or set Cloudflare SSL mode to Flexible
Certbot challenge fails
DNS not propagated, or port 80 blocked
dig +short ctf.example.com, check security group allows 80/443
nginx won't start
Wrong cert path in http.conf
docker compose logs nginx
Cert about to expire
Renewal timer broken
systemctl status certbot.timer
Manual renew + reload if needed:
Last updated