Setup and install Caddy web server on Ubuntu 24.04 in the cloud on Azure, AWS or Google GCP. Deploy using the public image available on any of the cloud marketplaces below. Caddy simplifies serving static and dynamic web content, acting as a reverse proxy, and automatically obtaining and renewing SSL certificates through Let’s Encrypt.
Cloud Caddy Web Server
Caddy Web Server Azure
Deploy Caddy Web Server on Ubuntu 24.04 in Azure
Caddy Web Server AWS
Coming Soon…
Caddy Web Server GCP
Coming Soon…
Caddy Features
Serving static websites with automatic HTTPS setup.
Acting as a reverse proxy for dynamic web applications.
Managing SSL/TLS certificates automatically for multiple domains.
Load balancing traffic across multiple backend servers.
Running self-hosted services securely with HTTPS.
Proxying requests to internal APIs and services.
Getting Started with Caddy Web Server
Once your Caddy server has been deployed, the following links explain how to connect to a Linux VM:
Once connected and logged in, the following section explains how to start using Caddy to setup your web server.
Check Caddy Status and Version
To confirm Caddy is running and the version, run the following commands:
sudo systemctl status caddy
caddy version
Understanding Caddy’s Default Setup
Caddy runs as a service and listens on port 80 by default. When a valid domain name is provided, Caddy will automatically obtain and configure an SSL/TLS certificate for HTTPS through Let’s Encrypt.
Key Configuration Files:
Caddyfile: The configuration file for Caddy is located at /etc/caddy/Caddyfile. This file defines how Caddy should serve your websites.
Logs: Caddy logs can be viewed in the system journal:
sudo journalctl -u caddy
Basic Caddy Configuration (Caddyfile)
The primary configuration file for Caddy is called the Caddyfile. You can edit it to define how Caddy should serve content for your domain or IP address.
To open and edit the Caddyfile:
sudo nano /etc/caddy/Caddyfile
Here’s a simple example of a Caddyfile configuration to serve a static website:
By default, Caddy automatically redirects HTTP traffic to HTTPS. However, if you want to manually control this behavior or redirect from www to non-www (or vice versa), you can explicitly define redirects in your Caddyfile.
For example, redirect www.yourdomain.com to yourdomain.com:
Caddy will now serve both example1.com and example2.com from different directories.
Reverse Proxy with Caddy
Caddy can act as a reverse proxy to route requests to backend servers. This is useful for load balancing or proxying to other web applications.
Here’s a simple reverse proxy configuration for yourdomain.comthat proxies traffic to an internal service running on localhost:8080:
yourdomain.com {
reverse_proxy localhost:8080
}
After saving the configuration, reload Caddy:
sudo systemctl reload caddy
Caddy will now forward traffic from yourdomain.com to the application running on localhost:8080.
Caddy Web Server Access Logs and Monitoring
To monitor Caddy and check for issues, you can inspect the logs:
sudo journalctl -u caddy
This will show the recent logs of Caddy, including any errors or certificate-related messages from Let’s Encrypt.
You can also enable more detailed logging by configuring Caddy’s access logs in the Caddyfile. Add this line within a site configuration to enable access logging:
log {
output file /var/log/caddy/access.log
format json
}
This will log all requests to /var/log/caddy/access.log.
Manage Caddy Service
Caddy is installed as a systemd service, so you can manage it like any other service. Common commands include:
Start Caddy
sudo systemctl start caddy
Stop Caddy
sudo systemctl stop caddy
Restart Caddy
sudo systemctl restart caddy
Reload Caddy (After making configuration changes)
sudo systemctl reload caddy
Check Caddy Status
sudo systemctl status caddy
Updating Caddy Web Server
To update Caddy to the latest version, you can use the following commands:
Update the package list:
sudo apt update
2. Upgrade Caddy Web Server
sudo apt upgrade caddy
Documentation / Support
For further details and documentation refer to the following:
Disclaimer: Caddy® is a registered trademark of Light Code Labs, LLC and is licensed under Apache License 2.0 license. The license comes with a “no warranty” clause, meaning the software is provided “as-is” without any guarantees or liability for issues that may arise.
Cloud Solution Architect. Helping customers transform their business to the cloud. 20 years experience working in complex infrastructure environments and a Microsoft Certified Solutions Expert on everything Cloud.
00votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.