header
最后更新于:2022-04-02 02:55:45
[TOC]
## header
语法
```
header [] [[+|-] [|] []] {
[+]
-
[defer]
}
```
### 实例
```
# 设置自定义 头
header Custom-Header "My value"
# 替换 http 为 https
header Location http:// https://
# 批量设置头请求
header {
# enable HSTS
Strict-Transport-Security max-age=31536000;
# disable clients from sniffing the media type
X-Content-Type-Options nosniff
# clickjacking protection
X-Frame-Options DENY
# keep referrer data off of HTTP connections
Referrer-Policy no-referrer-when-downgrade
}
# 根据不同路由设置请求头
route {
header Cache-Control max-age=3600
header /static/* Cache-Control max-age=31536000
}
```
';