Caddy is an open-source, powerful, extensible platform written in Go that can be used to serve your sites, services, and apps. It is not a simple web server. It can be used as a reverse proxy, load balancer, gateway, ingress controller, task scheduler, and more. Caddy is lightweight and operates primarily at L4 (transport layer) and L7 (application layer) of the OSI model. Whether you’re hosting a simple website or running a production-ready web app, Caddy is a great place to start when looking for alternatives to your current configurations. To get started with installing Caddy on Ubuntu, follow the steps below:

Install from the official Repository

There are many ways to install Caddy in Ubuntu. One way is to install Caddy from its official repository. To do that, use the steps below: First, run the commands below to install supported packages. After that, add the Caddy package repository key to Ubuntu by running the commands below: When you’re done, create a repository file by running the commands below: Finally, run the commands below to update Ubuntu package lists and install Caddy. Installing this package automatically starts and runs Caddy for you as a systemd service named caddy using our official caddy. service unit file. After installing Caddy, the commands below can be used to stop, start and enable the Caddy service to automatically start up when the server boots. To verify that Caddy is running, run the commands below: That should display similar lines as shown below: Caddy is running the function. Open the browser on the server and browse to the server hostname or IP address. You should see Caddy’s default web page message.

Configure Caddy

To serve web pages via Caddy, you must define the root directory to serve the files. By default Caddy configuration file is located at /etc/caddy/Caddyfile. Run the commands below to open the Caddy default configuration file. Then add the lines below to reference the website files you want to serve on the server. This is a basic Caddy config and declares that all HTTP traffic to your server should be served with files file_server from /var/www and compressed using gzip to reduce page loading times on the client side. Save the file and exit. Reload the Caddy service and browse the domain to test. That should do it! Conclusion: This post showed you how to install the Caddy server on Ubuntu. If you find any error above, please use the comment form below to report.