Cho*_*per 4 nginx http-headers
文档说明了这一点:
当且仅当在当前级别上没有定义add_header指令时,这些指令才从先前级别继承.
我的问题是我有几个location要缓存的块,比如这个:
add_header X-Frame-Options SAMEORIGIN;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
location ~ ^/img/(.*)\.(png|jpg|jpeg|gif|bmp)$ {
expires 1w;
add_header Cache-Control public;
}
Run Code Online (Sandbox Code Playgroud)
但这将使我失去在块外宣布的所有标题.所以显然唯一的方法是在每个location块上复制这些头,例如:
add_header X-Frame-Options SAMEORIGIN;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
location ~ ^/img/(.*)\.(png|jpg|jpeg|gif|bmp)$ {
expires 1w;
add_header Cache-Control public;
add_header X-Frame-Options SAMEORIGIN;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
}
Run Code Online (Sandbox Code Playgroud)
似乎不对.有任何想法吗?
| 归档时间: |
|
| 查看次数: |
2100 次 |
| 最近记录: |