From e590d29117c7e604a6866f1db2981f8a35b6dfaf Mon Sep 17 00:00:00 2001 From: Aaron Paterson <9441877+MayCXC@users.noreply.github.com> Date: Thu, 10 Oct 2024 00:06:46 -0400 Subject: [PATCH 01/17] Update bind.md --- .../markdown/caddyfile/directives/bind.md | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/docs/markdown/caddyfile/directives/bind.md b/src/docs/markdown/caddyfile/directives/bind.md index 151ed051..f8fa151b 100644 --- a/src/docs/markdown/caddyfile/directives/bind.md +++ b/src/docs/markdown/caddyfile/directives/bind.md @@ -16,10 +16,13 @@ Note that binding sites inconsistently may result in unintended consequences. Fo ## Syntax ```caddy-d -bind +bind { + protocols ... +} ``` - **<hosts...>** is the list of host interfaces to bind which to bind the listener. +- **<protocols...>** is an optional override of the HTTP protocols to enable for the listener. ## Examples @@ -64,6 +67,39 @@ example.com { } ``` +To bind to a Unix domain socket at `/run/caddy/stream.sock` that serves h1 and h2, and another at `/run/caddy/dgram.sock` that serves h3: + +```caddy +example.com { + bind unix//run/caddy/stream.sock { + protocols h1 h2 + } + bind unixgram//run/caddy/dgram.sock { + protocols h3 + } +} +``` + +To bind to inherited descriptors specified with [environment placeholders](/docs/conventions#placeholders): + +```caddy +http://example.com { + bind fd/{env.CADDY_HTTP_FD} { + protocols h1 + } + redir https://example.com{uri} permanent +} + +https://example.com { + bind fd/{env.CADDY_HTTPS_FD} { + protocols h1 h2 + } + bind fdgram/{env.CADDY_HTTP3_FD} { + protocols h3 + } +} +``` + To bind one domain to two different interfaces, with different responses: ```caddy From bc8db1de26890f110ad2e65248cf33d731b9222c Mon Sep 17 00:00:00 2001 From: Aaron Paterson <9441877+MayCXC@users.noreply.github.com> Date: Thu, 10 Oct 2024 00:11:23 -0400 Subject: [PATCH 02/17] Update conventions.md --- src/docs/markdown/conventions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/docs/markdown/conventions.md b/src/docs/markdown/conventions.md index 4ddef28d..be66752d 100644 --- a/src/docs/markdown/conventions.md +++ b/src/docs/markdown/conventions.md @@ -32,6 +32,7 @@ The network can be any of the following; ones suffixed with `4` or `6` are IPv4 - UDP: `udp`, `udp4`, `udp6` - IP: `ip`, `ip4`, `ip6` - Unix: `unix`, `unixgram`, `unixpacket` +- File descriptors: `fd`, `fdgram` The address part may be any of these forms: @@ -42,7 +43,7 @@ The address part may be any of these forms: - `/path/to/unix/socket` - `/path/to/unix/socket|0200` -The host may be any hostname, resolvable domain name, or IP address. +The host may be any hostname, resolvable domain name, IP address, or file descriptor number. In the case of IPv6 addresses, the address must be enclosed in square brackets `[]`. The zone identifier (starting with `%`) is optional (often used for link-local addresses). From 3c8bd2a98b7bee28711f4f2565fdecf6563cea6e Mon Sep 17 00:00:00 2001 From: Aaron Paterson <9441877+MayCXC@users.noreply.github.com> Date: Thu, 10 Oct 2024 00:21:43 -0400 Subject: [PATCH 03/17] Update options.md --- src/docs/markdown/caddyfile/options.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/docs/markdown/caddyfile/options.md b/src/docs/markdown/caddyfile/options.md index f57fb37d..ca2afe74 100644 --- a/src/docs/markdown/caddyfile/options.md +++ b/src/docs/markdown/caddyfile/options.md @@ -56,7 +56,9 @@ Possible options are (click on each option to jump to its documentation): debug http_port https_port - default_bind + default_bind { + protocols ... + } order first|last|[before|after ] storage { @@ -192,7 +194,7 @@ Default: `443` ##### `default_bind` -The default bind address(es) to be used for all sites, if the [`bind` directive](/docs/caddyfile/directives/bind) is not used in the site. Default: empty, which binds to all interfaces. +The default bind address(es) and the HTTP protocol(s) to be serve with them for all sites, if the [`bind` directive](/docs/caddyfile/directives/bind) is not used in the site. Default: empty, which binds to all interfaces, and serves the default protocols (h1+h2+h3) on them. +For example, to bind to `10.0.0.1` when no other address(es) are specified: + ```caddy { default_bind 10.0.0.1 } ``` +or to disable HTTP/3 unless otherwise specified: +```caddy +{ + default_bind { + protocols h1 h2 + } +} +``` ##### `order` Assigns an order to HTTP handler directive(s). As HTTP handlers execute in a sequential chain, it is necessary for the handlers to be executed in the right order. Standard directives have [a pre-defined order](/docs/caddyfile/directives#directive-order), but if using third-party HTTP handler modules, you'll need to define the order explicitly by either using this option or placing the directive in a [`route` block](/docs/caddyfile/directives/route). Ordering can be described absolutely (`first` or `last`), or relatively (`before` or `after`) to another directive. From fe713a34293a6dbdc5feaf93a8dcdc7790555f99 Mon Sep 17 00:00:00 2001 From: Aaron Paterson <9441877+MayCXC@users.noreply.github.com> Date: Thu, 10 Oct 2024 00:24:02 -0400 Subject: [PATCH 04/17] Update options.md --- src/docs/markdown/caddyfile/options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/markdown/caddyfile/options.md b/src/docs/markdown/caddyfile/options.md index ca2afe74..5a18f552 100644 --- a/src/docs/markdown/caddyfile/options.md +++ b/src/docs/markdown/caddyfile/options.md @@ -194,7 +194,7 @@ Default: `443` ##### `default_bind` -The default bind address(es) and the HTTP protocol(s) to be serve with them for all sites, if the [`bind` directive](/docs/caddyfile/directives/bind) is not used in the site. Default: empty, which binds to all interfaces, and serves the default protocols (h1+h2+h3) on them. +The default bind address(es) and the HTTP protocol(s) to serve with them for all sites, if the [`bind` directive](/docs/caddyfile/directives/bind) is not used in the site. Default: empty, which binds to all interfaces, and serves the default protocols (h1+h2+h3) on them.