TIL how to use caddy as automatic https reverse proxy

1 minute read Published:

Short howto: download and configure caddy - an automatic https (!!!) webserver

Hey Blog! Long time no see…

Today I will show you how to download and execute caddy - an automatic https web server and reverse proxy written in Go!

be me.
browse the interwebs.
see caddy - a fully automatic https server
write script to download caddy from their cdn
and create a Caddyfile on a spare server
best day ever - free ssl certs with auto renewal

You can download caddy here. Give it a try with a spare (sub-)domain you find laying around.

My download and setup script:



echo "downloading caddy"
wget -O $TARBALL "https://caddyserver.com/download/build?os=linux&arch=amd64"

echo "creating target directory"
sudo mkdir -p $TARGET

echo "extracting caddy"
sudo tar -xvzf $TARBALL -C $TARGET &&

echo "allow non privileged users to run caddy and bind to privileged ports"
sudo setcap "cap_net_bind_service=+ep" $TARGET/caddy

echo "removing tarball"

Configuring caddy

$ sudo su
$ mkdir /var/log/caddy
$ mkdir /var/caddy/ && cd $_
$ mkdir www
$ echo "it's working!" > www/index.html
$ vim Caddyfile


yourdomain.com {
	root /var/caddy/www
	log / /var/log/caddy/access.log "{combined}"
	tls admin@yourdomain.com


$ cd /opt/caddy
$ ./caddy -agree -conf /var/caddy/Caddyfile

Try it out in your browser by typing: https://yourdomain.com!