Caddy: Web Server for Humans


Caddy is web server that process requests via HTTP but with a complete different goal from other webservers like Apache, Nginx, or lighttpd. Caddy’s primary goal is to be an easy-to-use static file web server so that anyone can host their own websites even with minimal technical knowledge.It is the only web server to serve all live sites over HTTPS by default (with some conditions provided) which is pretty cool.


Why Caddy?


Quick Start:

  1. Download Caddy for your platform and make sure caddy is in your PATH.
  2. `cd` in the folder in which you have website you want to host using terminal.
  3. Run `caddy`.
Now redirect to https://localhost:2015 to see if it is working,make sure your project has index.html.


Get more out of Caddy

First make a `caddyfile`, which is an optional text file through which we can modify caddy’s configurations in the same folder as our website or we can provide the path of caddyfile to caddy using:
caddy -conf=’path/to/caddyfile’

If your website is not in the path of caddy, give the path to your website using `root`
caddy -root=’path/to/website’


To clean your URL and add `ext` to your caddy file
ext .html


To reverse Proxy it to some other port
proxy / http://redirect_url {}


To log the error occurred and show the custom error page
errors {
log ../errors.log # Error log
404 error-404.html # Custom error page
}


To hide the existence of a secret folder
status 404 /secrets


After all these changes, our caddyfile will look like following:
localhost #server address
proxy / http://localhost:8000 {}

ext .html # Clean URLs

errors {
log ../errors.log # Error log
404 error-404.html # Custom error page
}

status 404 /secrets