caddy

From RaySoft

Caddy 2 is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go.[1]

Caddy simplifies your infrastructure. It takes care of TLS certificate renewals, OCSP stapling, static file serving, reverse proxying, Kubernetes ingress, and more.[1]

Its modular architecture means you can do more with a single, static binary that compiles for any platform.[1]

Caddy runs great in containers because it has no dependencies—not even libc. Run Caddy practically anywhere.[1]

Documentation

Syntax

caddy SUBCOMMAND [PARAMETER ...]

Subcommands & Parameters

file-server
Spins up a simple but production-ready static file server.
NOTE:
This command disables the admin API, making it easier to run multiple instances on a local development machine.
--browse
Will enable directory listings if a directory without an index file is requested.
--domain HOSTNAME
Will only serve files through that HOSTNAME, and caddy will attempt to serve it over HTTPS, so make sure any public DNS is configured properly first if it's a public domain name. The default port will be changed to 443.
--listen ADDRESS
Accepts a listener ADDRESS. Default is :80, unless --domain is used, then :443 will be the default.
--root PATH
Specifies the root file PATH. Default is the current working directory.
reverse-proxy
Spins up a simple but production-ready reverse proxy.
NOTE:
This command disables the admin API, making it easier to run multiple instances on a local development machine.
--from HOST:PORT|URL
Is the address to proxy from.
--to HOST:PORT|URL
Is the address to proxy to.

Examples

Provide a lightweight HTTPS server using a self-signed certificate

Create a self-signed certificate:

openssl req -newkey 'rsa:2048' -x509 -days 365 -nodes \
  -keyout '/home/alex/etc/caddy/key.pem' \
  -out '/home/alex/etc/caddy/cert.pem' \
  -subj '/C=CH/L=Zurich/O=RaySoft/CN=127.0.0.1'

Create a Caddyfile file with the following content:

:8443 {
    file_server browse {
        root /home/alex/files
    }
    tls /home/alex/etc/caddy/cert.pem /home/alex/etc/caddy/key.pem
}

Run caddy:

caddy run

Open the site in the standard browser:

open 'https://localhost:8443/'

References