Automatic Https With Caddy - Extremely Easy

Today I had a chance to try Caddy for dev purpose, and you guess what, it was extremely easy and funny. Only two steps and boom, you got a secured website almost instantly.
Here are the steps I followed:

Install Caddy on Ubuntu/Debian

Check their documentation for another OS/installation method.

1sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
2curl -1sLf '' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
3curl -1sLf '' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
4sudo apt update
5sudo apt install caddy

Edit Caddyfile and restart the service

1sudo vim /etc/caddy/Caddyfile
1sudo systemctl restart caddy
2# or
3sudo caddy reload

That's it, you can now browse
In my case, a REST API service was running on port 8000 and I configured Caddy as a reverse proxy.
Configuring Caddy should be easy for other use cases as well, I'm pretty sure.

If you were to configure multiple domains: {
2  reverse_proxy
4 {
6  reverse_proxy

Happy coding!

comments powered by Disqus