nginx添加自定义HTTP响应头

nginx添加自定义HTTP响应头

语法:add_header name value;
作用域:http,server,location

nginx页面官方说明:将指定的字段添加到一个响应头。响应代码等于200, 204, 206, 301, 302, 303, 304, or 307。(Adds the specified field to a response header provided that the response code equals 200, 204, 206, 301, 302, 303, 304, or 307.)值可以包含变量。

location / {
add_header Content-Type “text/plain;charset=utf-8”;
add_header ‘Access-Control-Max-Age’ 1728000;
add_header ‘Content-Length’ 100;
}

另外还有一个配置参数可以添加nginx的http响应头,没有深研仅备忘:
more_set_headers “Server: HostSoft Web Server”;

6san.com

发表评论