-
-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs for PR caddyserver/caddy#6573 #424
Changes from 9 commits
e590d29
bc8db1d
3c8bd2a
fe713a3
f0e45f6
83c0376
1e98c7d
bcb697a
5604b50
a0eb8cf
22a1f3e
f9cf7ef
17c9c59
5bc75dd
3292caf
ed85759
ed889b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,13 @@ Note that binding sites inconsistently may result in unintended consequences. Fo | |
## Syntax | ||
|
||
```caddy-d | ||
bind <hosts...> | ||
bind <hosts...> { | ||
protocols <protocol> ... | ||
} | ||
``` | ||
|
||
- **<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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably list the allowed options |
||
|
||
|
||
## 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 file descriptors specified with [environment placeholders](/docs/conventions#placeholders): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should explain a bit why you'd want to use file descriptors. As a reader, I think "but why?" |
||
|
||
```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 | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -56,7 +56,9 @@ Possible options are (click on each option to jump to its documentation): | |||||
debug | ||||||
http_port <port> | ||||||
https_port <port> | ||||||
default_bind <hosts...> | ||||||
default_bind <hosts...> { | ||||||
protocols <protocol> ... | ||||||
} | ||||||
order <dir1> first|last|[before|after <dir2>] | ||||||
storage <module_name> { | ||||||
<options...> | ||||||
|
@@ -192,21 +194,44 @@ 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 optional HTTP protocol(s) to serve with them for all sites, if the [`bind` directive](/docs/caddyfile/directives/bind) is not used in the site. If multiple `default_bind` directives are present, each will be applied to servers with no `bind` directive in the order they were given. Default: empty, which binds to all interfaces, and serves the default protocols (h1+h2+h3) on them. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer to show the options in the way they would appear in the Caddyfile
Suggested change
Also this section should probably mention the list of allowed options |
||||||
|
||||||
<aside class="tip"> | ||||||
|
||||||
Keep in mind that this will only apply to servers which are generated by the Caddyfile; this means that the HTTP server created by [Automatic HTTPS](/docs/automatic-https) for HTTP-to-HTTPS redirects will not inherit these bind addresses. To work around this, make sure to declare an `http://` site (it can be empty, with no directives) so that it exists when the Caddyfile is adapted, to receive the bind addresses. | ||||||
|
||||||
</aside> | ||||||
|
||||||
For example, to bind to `10.0.0.1` when no other address(es) are specified: | ||||||
|
||||||
```caddy | ||||||
{ | ||||||
default_bind 10.0.0.1 | ||||||
} | ||||||
``` | ||||||
|
||||||
to disable HTTP/3 unless otherwise specified: | ||||||
MayCXC marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
```caddy | ||||||
{ | ||||||
default_bind { | ||||||
protocols h1 h2 | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
to create default listeners from file descriptors given by [environment placeholders](/docs/conventions#placeholders): | ||||||
MayCXC marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
```caddy | ||||||
{ | ||||||
default_bind fd/{env.CADDY_HTTPS_FD} { | ||||||
protocols h1 h2 | ||||||
} | ||||||
default_bind fdgram/{env.CADDY_HTTP3_FD} { | ||||||
protocols h3 | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
##### `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. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a short paragraph to explain what a "file descriptor" means in this context would help |
||
|
||
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). | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it moreseo like this?
<protocol> ...
implies a single protocol is given, which can itself have additional options, but from my reading of the examples, it's just a list of protocols.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the
...
after, I thought this was the notation for at least one protocol, then possibly more. there are other options that use both, but I thought the distinction was >=1 vs >=0.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use
<args...>
to to mean "one or more". See https://caddyserver.com/docs/caddyfile/directives#syntax. If it was optional, it would be[<args...>]
.