add webi dat dat dat
[webi-installers/.git] / caddy / README.md
index f7f4ae56d8dc344f193170848007ef615969ee9e..db52f692e523bb257e4a9fc2661bb2deca0150e7 100644 (file)
@@ -3,10 +3,62 @@ title: Caddy
 homepage: https://github.com/caddyserver/caddy
 tagline: |
   Caddy is a fast, multi-platform web server with automatic HTTPS.
-description: |
-  Caddy makes it easy to use Let's Encrypt to handle HTTPS (TLS/SSL) and to reverse proxy APIs and WebSockets to other apps - such as those written node, Go, python, ruby, and PHP.
 ---
 
+## Updating `caddy`
+
+```bash
+webi caddy@stable
+```
+
+Use the `@beta` tag for pre-releases, or `@x.y.z` for a specific version.
+
+## Cheat Sheet
+
+> Caddy makes it easy to use Let's Encrypt to handle HTTPS (TLS/SSL) and to
+> reverse proxy APIs and WebSockets to other apps - such as those written node,
+> Go, python, ruby, and PHP.
+
+### How to serve a directory
+
+```bash
+caddy file-server --browse --listen :4040
+```
+
+### How to redirect and reverse proxy
+
+Here's what a fairly basic `Caddyfile` looks like:
+
+```txt
+# redirect www to bare domain
+www.example.com {
+    redir https://example.com{uri} permanent
+}
+
+example.com {
+    # turn on standard streaming compression
+    encode gzip zstd
+
+    # reverse proxy /api to :3000
+    reverse_proxy /api/* localhost:3000
+
+    # serve static files from public folder, but not /api
+    @notApi {
+        file {
+            try_files {path} {path}/ /index.html
+        }
+        not path /api/*
+    }
+    route {
+      rewrite @notApi {http.matchers.file.relative}
+    }
+    root * /srv/example.com/public/
+    file_server
+}
+```
+
+And here's how you run caddy with it:
+
 ```bash
-caddy start
+caddy run --config ./Caddyfile
 ```