mirror of
https://github.com/caddyserver/website.git
synced 2025-04-22 13:06:16 -04:00
docs: header default values (#98)
see https://github.com/caddyserver/caddy/pull/3807
This commit is contained in:
parent
b95745040b
commit
8084cba78b
1 changed files with 11 additions and 2 deletions
|
@ -12,16 +12,18 @@ By default, header operations are performed immediately unless any of the header
|
|||
## Syntax
|
||||
|
||||
```caddy-d
|
||||
header [<matcher>] [[+|-]<field> [<value>|<find>] [<replace>]] {
|
||||
header [<matcher>] [[+|-|?]<field> [<value>|<find>] [<replace>]] {
|
||||
<field> <find> <replace>
|
||||
[+]<field> <value>
|
||||
-<field>
|
||||
?<field> <default_value>
|
||||
[defer]
|
||||
}
|
||||
```
|
||||
|
||||
- **<field>** is the name of the header field. By default, will overwrite any existing field of the same name. Prefix with `+` to add the field instead of replace, or prefix with `-` to remove the field.
|
||||
- **<value>** is the header field value, if adding or setting a field.
|
||||
- **<default_value>** is the header field value that will be set only if the header does not already exist.
|
||||
- **<find>** is the substring or regular expression to search for.
|
||||
- **<replace>** is the replacement value; required if performing a search-and-replace.
|
||||
- **defer** will force the header operations to be deferred until the response is written out to the client. This is automatically enabled if any of the header fields are being deleted.
|
||||
|
@ -58,7 +60,7 @@ header {
|
|||
|
||||
# disable clients from sniffing the media type
|
||||
X-Content-Type-Options nosniff
|
||||
|
||||
|
||||
# clickjacking protection
|
||||
X-Frame-Options DENY
|
||||
|
||||
|
@ -75,3 +77,10 @@ route {
|
|||
header /static/* Cache-Control max-age=31536000
|
||||
}
|
||||
```
|
||||
|
||||
Set a default cache expiration if upstream doesn't define one:
|
||||
|
||||
```caddy-d
|
||||
header ?Cache-Control "max-age=3600"
|
||||
reverse_proxy upstream:443
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue