Caddy – A HTTP/2 Web Server with Automatic HTTPS for Websites

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. We all would be familiar with Apache HTTP Server.

Apache HTTP Server played an important role in designing what web is today. It alone has a market share of 45.9. Nginx comes second in the list having a market share of 39%. Microsoft IIS and LiteSpeed comes at number 3 and 4 having a market share of 9.5% and 3.4% respectively.

Recently, I came across a web server named Caddy. When I tried to inquire it’s features and deployed it to testing, I must say it is amazing. A web server which is portable and do not need any configuration file. I though 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 apache web server with easy to configure and use. Matt Holt – The Project leader of Caddy claims that Caddy is a general-purpose web server, claims to be designed for human 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

  1. Speedy HTTP requests using HTTP/2.
  2. Capable Web Server with least configuration and hassle free deployment.
  3. TLS encryption ensure, encryption between communicating applications and user over Internet. You may use your own keys and certificates.
  4. Easy to deploy/use. Just one single file and no dependency on any platform.
  5. No installation required.
  6. Portable Executables.
  7. Run on multiple CPUs/Cores.
  8. Advanced WebSockets technology – interactive communication session between browser and server.
  9. Server Markdown documents on the fly.
  10. Full support for latest IPv6.
  11. Creates log in custom format.
  12. Serve FastCGI, Reverse Proxy, Rewrite and Redirects, Clean URL, Gzip compression, Directory Browsing, Virtual Hosts and Headers.
  13. Available for All known Platform – Windows, Linux, BSD, Mac, Android.

What make caddy Different?

  1. Caddy aims at serving web as it should be in the year 2017 and not traditional style.
  2. It is designed not only to serve HTTP request but also human.
  3. Loaded with Latest features – HTTP/2, IPv6, Markdown, WebSockets, FastCGI, templates and other out-of-box features.
  4. Run the executables without the need of Installing it.
  5. Detailed documentation with least technical description.
  6. Developed keeping in mind the need and ease of Designers, Developers and Bloggers.
  7. Support Virtual Host – Define as many sites as you want.
  8. Suited for you – no matter if your site is static or dynamic. If you are human it is for you.
  9. You focus on what to achieve and not how to achieve.
  10. Availability of support for most number of platforms – Windows, Linux, Mac, Android, BSD.
  11. Usually, you have one Caddy file per site.
  12. Set up in less than 1 minute, even if you are not that much computer friendly.
Testing Environment

I will be testing it on CentOS server, as well as Debian Server. For both the server I am going to use 64-bit executables.

Operating Systems: CentOS 7 and Debian 8 Jessie
Caddy Version: v0.11.0

Installation of Caddy Web Server in Linux

No matter you are on what platform and which kind of architecture your are using, caddy provides ready to use executable packages, which can be downloaded from the official caddy download page.

Alternatively, you can use following command to download and install into a folder caddy and change current working directory to caddy and list the contents of the directory.

$ mkdir caddy
$ cd caddy
$ sudo curl https://getcaddy.com | bash -s personal   [For Personal Use]
$ sudo curl https://getcaddy.com | bash -s commercial [For Commercial Use]

Now create any html page (you may create your own) and save the page under caddy folder. Now fire the caddy executable and point your browser to localhost at port 2015/index.html and you should be able to see your page.

$ caddy

If the html page is saved as index.html you don’t need to tell your browser to look for the file name as index.html is the primary file, which will be looked automatically.

Caddy Web Server

Caddy Web Server

The default port caddy uses is 2015. You may kill the process ‘caddy‘ once it is done or you may like to run another instance of caddy in the same login session.

$ pkill caddy

Setting Up Domains with Caddy

To setup a domain, first you need to create a web root directory for your website “test-domain.com” under folder caddy as shown.

$ cd caddy
$ mkdir test-tecmint.com

Now create a file called Caddyfile using touch command.

$ vi Caddyfile

Paste the following code to activate your new domain.

test-tecmint.com {
root /caddy/test-tecmint.com
}

Restart the Caddy service to save the changes and obtain new SSL/TLS certificates automatically using Let’s Encrypt.

$ caddy

Activating privacy features... 

Your sites will be served over HTTPS automatically using Let's Encrypt.
By continuing, you agree to the Let's Encrypt Subscriber Agreement at:
  https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf
Please enter your email address to signify agreement and to be notified
in case of issues. You can leave it blank, but we don't recommend it.
  Email address:              

If everything is correctly configured, your domain will be served over an HTTPS protocal indicating that your connection is secure.

Conclusion

If you are newbies and want to setup a webserver without getting your hands dirty with configuration, this tool is for you. Even if you are an experienced user whose need 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 setup a more complex and advanced webserver.

Don’t take Caddy as a replacement of Apache or Nginx. Caddy is not designed to handle high traffic production environment. It is designed for quick web server setup when you concern is speed and reliability.

References

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 don’t need to carry its configuration file everywhere. It aims at providing the best of nginx, lighthttpd, vagrant and websocketd. That’s all from my side. Keep connected to Tecmint. Kudos

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

3 Responses

  1. J.J says:

    Don’t take Caddy as a replacement of Apache or Nginx. Caddy is not designed to handle high traffic production environment. It is designed for quick web server setup when you concern is speed and reliability.

    Totally wrong, Caddy is designed as a replacement.

  2. Redouane says:

    Thank you so much

  3. Plazma says:

    How do you create terminal gifs on linux?

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.