Skip to main content

Command Palette

Search for a command to run...

Automatic HTTPS with Caddy

Updated
1 min read

Nginx is a popular web server that can act as reverse proxy, load balancer etc. And to serve the content over HTTPS, the nginx config needs to be updated with SSL configuration. Certbot is a great tool for generating Free SSL certificate from Let's encrypt to enable HTTPS.

What about a server that automatically provisions a SSL certificate and enables HTTPS out of the box. If your requirement is similar to this, then I would recommend to give Caddy V2 a try. Caddy 2 is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go. It is also free to use in commercial projects.

Here is an example of a domain configured with reverse_proxy.

{
     admin off
     email you@example.com
}

example.com {
     reverse_proxy http://localhost:3000
     encode gzip
}

Pretty simple, isn't it? And your domain to served with https. Now you don't have to use certbot or setup cronjob to periodically check for expiry date to renew the certificate.

Note:

  • make sure to point the A record for the domain to the correct IP.

Adding virtual hosts

Adding server blocks is pretty straightforward.

example.com {
     reverse_proxy http://localhost:3000
}

api.example.com {
     reverse_proxy http://localhost:4000
}

This will provision a certificate to api.example.com and you can access the endpoint with https protocol.

https://caddyserver.com/

46 views
M

Reading through your blog on Automatic HTTPS with Caddy—such a well-explained guide! The simplicity of setting up Caddy 2 for automatic SSL provisioning was really helpful.

While researching, I found this resource on Caddy’s security features and automatic HTTPS, which dives into how Caddy ensures secure website deployment: 🔗 https://mobisoftinfotech.com/resources/blog/secure-website-caddy-automatic-https-security-features.

It’s a solid guide for anyone looking to enhance their web server security. I’d love to hear your thoughts on further improving Caddy’s security configurations! 🚀

A

I just read your blog on Automatic HTTPS with Caddy—excellent read! The fact that Caddy automatically provisions SSL certificates and enables HTTPS out of the box is such a game-changer. It really simplifies the process compared to Nginx, which often requires additional tools like Certbot and manual configuration for SSL renewal.

While researching more about Caddy, I came across a detailed resource on Secure with Caddy for HTTPS: https://mobisoftinfotech.com/resources/blog/secure-website-caddy-automatic-https-security-features . This explores Caddy's security features and automatic SSL setup, which complements your explanation really well.

It’s great to see how Caddy is positioned as an enterprise-ready web server that doesn’t require extra steps for SSL management. Given your expertise in Caddy, I’d love to hear your thoughts on its scalability for large production environments compared to traditional solutions like Nginx or Apache!

1