May 6th 2026 - How to Add Https to Your Site With Caddy
We can use Caddy to easily set up a server with https enabled to serve our website. Caddy takes care of the https certificates and auto renews them.
First we should create a caddy directory where the TLS data and config will be located.
We can then create a Caddyfile in that directory to define how we want to configure what to serve, set up reverse proxy, etc. See documentation here.
example.com {
root * /srv
file_server
encode gzip zstd
log {
output file /var/log/caddy/access.log
}
}
Then, we just run this Docker command to start it up.
sudo docker run -d --restart unless-stopped --name site \ -p 80:80 -p 443:443 -p 443:443/udp \ -v /home/user/web:/srv:ro \ -v /home/user/caddy/Caddyfile:/etc/caddy/Caddyfile \ -v /home/user/caddy/data:/data \ -v /home/user/caddy/config:/config \ -v /home/user/caddy/logs:/var/log/caddy \ caddy
The caddy/logs directory is where the logs are located with information about visitors and which paths they visited.
Notes
Make sure your domain is configured correctly in DNS and ports 80 and 443 are open. This should be set by default but if you experience issues it may be worth checking.