custom header documentation
This commit is contained in:
parent
1557fd3591
commit
dbdda5ed3d
1 changed files with 74 additions and 0 deletions
74
docs/header-config.md
Normal file
74
docs/header-config.md
Normal file
|
@ -0,0 +1,74 @@
|
|||
# Header Config
|
||||
|
||||
With the header config, you can specify custom [HTTP Header](https://developer.mozilla.org/de/docs/Web/HTTP/Headers) for the responses of certain file types and paths.
|
||||
|
||||
## Config
|
||||
|
||||
You have to create a JSON file that serves as a config. The JSON must contain a `configs` array. For every entry, you can specify a certain path that must be matched as well as a file extension. You can use the `*` symbol to use the config entry for any path or filename. Note that the path option only matches the requested path from the start. Thatswhy you have to start with a `/` and can use paths like `/files/static/css`. The `headers` array includes a key-value pair of the actual header rule. The headers are not parsed so double check your spelling and test your site.
|
||||
|
||||
The created JSON config has to be mounted into the container via a volume into `/config/headerConfig.json`. When this file does not exist inside the container, the header middleware will not be active.
|
||||
|
||||
Example command to add to the docker run command:
|
||||
|
||||
```
|
||||
-v /your/path/to/the/config/myConfig.json:/config/headerConfig.json
|
||||
```
|
||||
|
||||
On startup, the container will log the found header rules.
|
||||
|
||||
## Example headerConfig.json
|
||||
|
||||
```json
|
||||
{
|
||||
"configs": [
|
||||
{
|
||||
"path": "*",
|
||||
"fileExtension": "html",
|
||||
"headers": [
|
||||
{
|
||||
"key": "cache-control",
|
||||
"value": "public, max-age=0, must-revalidate"
|
||||
},
|
||||
{
|
||||
"key": "Strict-Transport-Security",
|
||||
"value": "max-age=31536000; includeSubDomains;"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "*",
|
||||
"fileExtension": "css",
|
||||
"headers": [
|
||||
{
|
||||
"key": "cache-control",
|
||||
"value": "public, max-age=31536000, immutable"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/page-data",
|
||||
"fileExtension": "json",
|
||||
"headers": [
|
||||
{
|
||||
"key": "cache-control",
|
||||
"value": "public, max-age=0, must-revalidate"
|
||||
},
|
||||
{
|
||||
"key": "content-language",
|
||||
"value": "en"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/static/",
|
||||
"fileExtension": "*",
|
||||
"headers": [
|
||||
{
|
||||
"key": "cache-control",
|
||||
"value": "public, max-age=31536000, immutable"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
Loading…
Reference in a new issue