From 2f2dc038d4176ae2310f8f94a06dbda9c07689b9 Mon Sep 17 00:00:00 2001 From: Employee 427 Date: Tue, 21 Apr 2026 17:38:42 +0000 Subject: [PATCH] docs: add runnable getting-started examples to README Quick start The Quick start section previously only linked out to external tutorials. Add a short Examples subsection with copy-pasteable commands for the most common entry points: file-server, reverse-proxy, Caddyfile run, validate/reload, and admin API inspection. Generated-By: PostHog Code Task-Id: 182a3d0a-ffdd-4706-802f-9102ffb8fdd0 --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index 508352c5620..8458ba5ff29 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,53 @@ The [Caddy website](https://caddyserver.com/docs/) has documentation that includ If you've only got a minute, [the website has several quick-start tutorials](https://caddyserver.com/docs/quick-starts) to choose from! However, after finishing a quick-start tutorial, please read more documentation to understand how the software works. 🙂 +### Examples + +Once `caddy` is on your `PATH`, the snippets below cover the most common ways to run it. They are intentionally minimal — see the linked docs above for full tutorials. + +**Serve the current directory as a static file server** on `http://localhost:8080`: + +```bash +$ caddy file-server --listen :8080 +``` + +**Run an ad-hoc reverse proxy** that forwards `:8080` to a local backend on `:3000`: + +```bash +$ caddy reverse-proxy --from :8080 --to 127.0.0.1:3000 +``` + +**Run from a Caddyfile.** Create a file named `Caddyfile` in your working directory: + +```caddyfile +localhost { + respond "Hello, Caddy!" +} +``` + +Then start Caddy in the foreground — it picks up `./Caddyfile` automatically: + +```bash +$ caddy run +``` + +Use `caddy start` instead to run it in the background. + +**Validate and hot-reload a config** without restarting the server: + +```bash +$ caddy validate --config Caddyfile +$ caddy reload --config Caddyfile +``` + +**Inspect the live config over the admin API** (enabled by default on `localhost:2019`): + +```bash +$ curl http://localhost:2019/config/ +``` + +See [the admin API docs](https://caddyserver.com/docs/api) for the full surface — the same endpoint accepts `POST`/`PATCH` to change config at runtime. +