X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=caddy%2FREADME.md;fp=caddy%2FREADME.md;h=db52f692e523bb257e4a9fc2661bb2deca0150e7;hb=c77b2afba8be0e2aca21ad2647e7e847e4a8aa14;hp=f7f4ae56d8dc344f193170848007ef615969ee9e;hpb=1a7a851e3fa8779ce488db62c7c24255b906044c;p=webi-installers%2F.git diff --git a/caddy/README.md b/caddy/README.md index f7f4ae5..db52f69 100644 --- a/caddy/README.md +++ b/caddy/README.md @@ -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 ```