From 265db05dee7e786f49a94ea64903565d0064a2f4 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 9 Jun 2022 17:54:16 -0600 Subject: [PATCH] doc(caddy): add reverse_proxy + redirect --- caddy/README.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/caddy/README.md b/caddy/README.md index 14134ab..123c1b4 100644 --- a/caddy/README.md +++ b/caddy/README.md @@ -48,9 +48,11 @@ example.com { # turn on standard streaming compression encode gzip zstd - + # reverse proxy /api to :3000 - reverse_proxy /api/* localhost:3000 + handle_path /api/* { + reverse_proxy localhost:3000 + } # reverse proxy some "well known" APIs reverse_proxy /.well-known/openid-configuration localhost:3000 @@ -73,12 +75,28 @@ example.com { } ``` -And here's how you run caddy with it: +### How to rewrite and reverse proxy + +```txt +example.com { + # ... + + # reverse proxy /api/new/ to http://localhost:3100/api/ + handle_path /api/new/* { + rewrite * /api{path} + reverse_proxy localhost:3100 + } +} +``` + +### How to run caddy ```bash caddy run --config ./Caddyfile ``` +Note: `run` runs in the foreground, `start` starts a service (daemon) in the background. + ### How to start Caddy as a Linux service Here are the 3 things you need to do to start Caddy as a system service: