From 97e815547a793bae4b7e0ff00c9345910541d3ae Mon Sep 17 00:00:00 2001 From: a Date: Thu, 13 Jun 2024 14:17:04 -0500 Subject: [PATCH] initial --- Caddyfile | 2 +- .../markdown/caddyfile/directives/import.md | 52 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Caddyfile b/Caddyfile index 7128093..9bfaa1d 100644 --- a/Caddyfile +++ b/Caddyfile @@ -1,4 +1,4 @@ -localhost +http://localhost:2080 root * src diff --git a/src/docs/markdown/caddyfile/directives/import.md b/src/docs/markdown/caddyfile/directives/import.md index bc7a248..86a713a 100644 --- a/src/docs/markdown/caddyfile/directives/import.md +++ b/src/docs/markdown/caddyfile/directives/import.md @@ -11,7 +11,7 @@ This directive is a special case: it is evaluated before the structure is parsed ## Syntax ```caddy-d -import [] +import [] [{block}] ``` - **<pattern>** is the filename, glob pattern, or name of [snippet](/docs/caddyfile/concepts#snippets) to include. Its contents will replace this line as if that file's contents appeared here to begin with. @@ -34,6 +34,11 @@ import [] Note that prior to v2.7.0, the syntax was `{args.N}` but this form was deprecated in favor of the more flexible syntax above. +⚠️ Experimental | v2.9.x+ +- **{block...}** is an optional block to pass to the imported tokens. This placeholder is a special case, and is evaluated recursively at Caddyfile-parse-time, not at runtime. They can be used in two forms: + - `{block}` where the content of provided block will be substituted for the placeholder. + - `{block.key}` where `key` is the first token of a parameter within the provided block + ## Examples @@ -85,3 +90,48 @@ example.com { import proxy-rewrite /api 10.0.0.1 10.0.0.2 10.0.0.3 } ``` + + +⚠️ Experimental | v2.9.x+ + +Import a snippet which provides extendable options for a reverse proxy + +```caddy +(extendable-proxy) { + reverse_proxy { + to {block.proxy_target} + {block.proxy_options} + } +} + +example.com { + import extendable-proxy { + proxy_target 10.0.0.1 + proxy_options { + transport http { + tls + } + } + } +} +``` + +Import a snippet that serves any set of directives, but with a pre-loaded middleware. + +```caddy +(instrumented-route) { + header { + Alt-Svc `h3="0.0.0.0:443"; ma=2592000` + } + tracing { + span args[0] + } + {block} +} + +example.com { + import instrumented-route example-com { + respond "OK" + } +} +```