A web server is a server-side application designed to process HTTP requests between client and server. HTTP is the basic and very widely used network protocol.
Apache HTTP Server played an important role in designing what the web is today. It alone has a market share of 37.3%. Nginx comes second in the list having a market share of 32.4%. Microsoft IIS and LiteSpeed come at numbers 3 and 4 having a market share of 7.8% and 6.9% respectively.
Recently, I came across a web server named Caddy. When I tried to inquire about its features and deployed it to testing, I must say it is amazing. A web server that is portable and does not need any configuration file. I thought it is a very cool project and wanted to share it with you. Here we have given Caddy a try!
What is Caddy?
Caddy is an alternative to an apache web server with easy to configure and use. Matthew Holt – The Project leader of Caddy claims that Caddy is a general-purpose webserver, claims to be designed for humans and it is probably the only of its kind.
Caddy is the only first web server that can acquire and renew SSL/TLS certificates automatically using Let’s Encrypt.
Features of Caddy
- Speedy HTTP requests using HTTP/2.
- Capable Web Server with least configuration and hassle-free deployment.
- TLS encryption ensures, encryption between communicating applications and users over the Internet. You may use your own keys and certificates.
- Easy to deploy/use. Just one single file and no dependency on any platform.
- No installation required.
- Portable Executables.
- Run-on multiple CPUs/Cores.
- Advanced WebSockets technology – interactive communication session between browser and server.
- Server Markdown documents on the fly.
- Full support for the latest IPv6.
- Creates a log in a custom format.
- Serve FastCGI, Reverse Proxy, Rewrite and Redirects, Clean URL, Gzip compression, Directory Browsing, Virtual Hosts, and Headers.
- Available for All known Platform – Windows, Linux, BSD, Mac, Android.
What makes caddy Different?
- Caddy aims at serving the web as it should be in the year 2020 and not traditional style.
- It is designed not only to serve HTTP requests but also to humans.
- Loaded with the Latest features – HTTP/2, IPv6, Markdown, WebSockets, FastCGI, templates, and other out-of-box features.
- Run the executables without the need of Installing it.
- Detailed documentation with the least technical description.
- Developed keeping in mind the need and ease of Designers, Developers, and Bloggers.
- Support Virtual Host – Define as many sites as you want.
- Suited for you – no matter if your site is static or dynamic. If you are human it is for you.
- You focus on what to achieve and not how to achieve it.
- Availability of support for most platforms – Windows, Linux, Mac, Android, BSD.
- Usually, you have one Caddy file per site.
- Set up in less than 1 minute, even if you are not that much computer friendly.
I will be testing it on the CentOS server, as well as Debian Server, but the same instructions also work on RHEL and Debian based distributions. For both the server I am going to use 64-bit executables.
Operating Systems: CentOS 8 and Debian 10 Buster Caddy Version: v2.0.0
Installation of Caddy Web Server in Linux
No matter you are on what platform and which kind of architecture you are using, caddy provides ready to use binary packages, that can be installed using your default package manager as shown.
Install Caddy in Fedora, RedHat, CentOS
We will be installing the latest version of the Caddy web server from the CORP repository under Fedora or RHEL/CentOS 8.
# dnf install 'dnf-command(copr)' # dnf copr enable @caddy/caddy # dnf install caddy
On RHEL/CentOS 7 use the following commands.
# yum install yum-plugin-copr # yum copr enable @caddy/caddy # yum install caddy
Install Caddy in Debian and Ubuntu
$ echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" \ | sudo tee -a /etc/apt/sources.list.d/caddy-fury.list $ sudo apt update $ sudo apt install caddy
Once installed caddy web server, you can start, enable, and check the status of the service using following systemctl commands.
# systemctl start caddy # systemctl enable caddy # systemctl status caddy
Now open your browser and point your browser to the following address and you should be able to see the caddy welcome page.
http://Server-IP OR http://yourdomain.com
Setting Up Domains with Caddy
To set up a domain, first, you need to point your domain’s A/AAAA DNS records at this server in your DNS control panel. Next, create a document root directory for your website
"example.com" under folder
/var/www/html as shown.
$ mkdir /var/www/html/example.com
If you’re using SELinux, you need to change the file security context for web content.
# chcon -t httpd_sys_content_t /var/www/html/example.com -R # chcon -t httpd_sys_rw_content_t /var/www/html/example.com -R
Now open and edit the caddy configuration file at
# vim /etc/caddy/Caddyfile
:80 with your domain name and change the site root to
/var/www/html/example.com as shown.
Reload the Caddy service to save the configuration change.
# systemctl reload caddy
Now create any HTML page (you may create your own) and save the page under document root directory for your website.
# touch /var/www/html/example.com/index.html
Add the following sample Html code to your website’s index page.
# echo '<!doctype html><head><title>Caddy Test Page at TecMint</title></head><body><h1>Hello, World!</h1></body></html>' | sudo tee /var/www/html/index.html
Now visit again your site to see your page.
If everything is correctly configured, your domain will be served over an HTTPS protocol indicating that your connection is secure.
If you are newbies and want to set up a webserver without getting your hands dirty with configuration, this tool is for you. Even if you are an experienced user who needs is instant and simple web server Caddy is worth a try. With a little configuration, you may also set folder permission, control authentication, error pages, Gzip, HTTP redirect, and others, if you need to set up a more complex and advanced webserver.
Don’t take Caddy as a replacement for Apache or Nginx. Caddy is not designed to handle high traffic production environment. It is designed for a quick webserver setup when your concern is speed and reliability.
Complete user Guide / Full Documentation of Caddy Web Server
We have brought this documentation which aims at quick review and installation instructions with images where ever necessary. If you come across any pros/cons of the project or any suggestion, you may give it to us in our comment section.
For me this project is too young still works flawlessly and seems powerful and promising. The biggest plus point I see is caddy doesn’t need to carry its configuration file everywhere. It aims at providing the best of Nginx, Lighttpd, vagrant, and Websocketd. That’s all from my side. Keep connected to Tecmint. Kudos