95.3 Caddy Web Server
20220603
Caddy is a fast and simple to configure web server supporting https and handling the Let’s Encrypt certificates seamlessly.
wajig install debian-keyring debian-archive-keyring apt-transport-https
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
wajig update
wajig install caddy
To enable Caddy and to ensure it is started on boot, start it up, and check its status:
Browse to your server with as http://example.org (replacing example.org with your own domain which has an A Record with the IP address to your server) and you should now see the default Caddy home page.
You can check the current version of caddy with:
The default Caddy configuration file is in /etc/caddy/Caddyfile
and
only sets up a http (non-encrypted) server based on files from
/usr/share/caddy
.
:80 {
root * /usr/share/caddy
file_server
}
A more common configuration is to support http with automatic redirect
to the secure https using your own domain name, with files served from
/var/www/html/
. You can replace the whole contents of the default
Caddyfile with the following. Be sure to replace example.org
with your own domain name.
Create a new web page at /var/www/html/index.html
:
sudo mkdir -p /var/www/html
echo "Welcome" | sudo tee /var/www/html/index.html
sudo systemctl reload caddy
Visit your web site again to ensure https://example.org now works.
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0