Are you tired of typing IP addresses and port numbers to access your home services Do you want SSL certs that just work? Today we’re going to set up Caddy to easily configure and access all of your services with HTTPS and clean domain names.
I will be doing this on Ubuntu 22.04 so you might need to adjust commands for your distro.
1. Installing Caddy
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
2. Edit Caddyfile
You can find this at /etc/caddy/Caddyfile. Here is an example you can copy and paste:
{
email youremail@domain.com
}
service.example.com {
reverse_proxy :PORT
}
service2.example.com {
reverse_proxy :PORT
}
Make sure to replace the domain and ports with your desired options.
3. Update DNS Registrar
Ensure that you have updated your DNS registrar settings. I use Cloudflare but any provider will work. Make sure to point your domain names to the IP of the server you are hosting these services on.
If you’re using Cloudflare, make sure to disable proxying for your domain until you’ve obtained SSL certificates. Trying to generate these while it’s on will result in a failure.
4. Putting it all together
You can now restart Caddy with sudo service caddy restart and your services should now be accessible at their domain name! If you have issues double check the status with sudo service caddy status to ensure you didn’t miss anything.
Thanks for reading!