Caddy a modern web server supporting HTTP/2

The web server market has been dominated by Apache, Nginx, and IIS. With changes in the web server market, such as HTTP/2 and security, there are always opportunities for new players to enter the market. One such web server is the open source project Caddy.

Section of Caddy Homepage A section of the Caddy homepage to help different users get to what they need quickly.

Caddy has some notable features that caught my eye:

  • HTTP/2 support out of the box.
  • Direct integration with Let’s Encrypt.
  • FastCGI, so you can use it with PHP, Python, and other languages.
  • Out of the box websocket support.
  • Leverages multiple cores to handle the workload.
  • And, the normal features like virtual hosts, Gzip, and the usual cast of features.

Caddy is written in Go and it uses Travis CI to handle automated testing. The documentation, formatting, linting, and cyclomatic complexity are come out looking quite nice.

Installing

You can install Caddy a few different ways. It’s a singe binary that you can download. If you are on a mac and use homebrew you can install it with brew install caddy. It’s available as a Docker container. And, you can always build it from source.

Simple Development Usage

The first time I used Caddy was for a simple static site. Rather than opening a file I needed to serve it over http. With Caddy I just fired up terminal, changed into the top level directory for the project, and ran caddy. It started serving the site at an address I could access for local development.

Caddyfile

Configuration for a site happens through a Caddyfile containing directives and keywords. For example, the following Caddyfile will serve a site on localhost port 8080 with gzip compression turned on and logging.

localhost:8080
gzip
log ../access.log

Caddyfiles can configure multiple sites, handle redirects, and deal with all the options for serving a site.

Worth Giving A Try

In my never ending quest for a better and faster web server that’s easy to use I’m finding Caddy to be something worth poking at.