ngx_headers_more是Nginx的一个很不错的模块,ngx_headers_more主要用于添加、设置和清除输入或者输出http header头的信息。下面详细的看看Nginx ngx_headers_more模块的安装、具体的用法和配置。
1、安装最新的ngx_headers_more压缩包
[root@nginx ~]# cd /usr/local/src/nginx-1.9.9
[root@nginx nginx-1.9.9]# wget https://github.com/openresty/headers-more-nginx-module/archive/v0.29.tar.gz
[root@nginx nginx-1.9.9]# tar zxvf headers-more-nginx-module-0.29.tar.gz
[root@nginx nginx-1.9.9]# ./configure –prefix=/usr/local/nginx –user=www –group=www –with-http_stub_status_module –with-openssl=/usr/ –with-pcre=/usr/local/src/pcre-8.35 –add-module=../ngx_cache_purge-2.1 –add-module=/usr/local/src/headers-more-nginx-module-0.26
[root@nginx nginx-1.9.9]# make
[root@nginx nginx-1.9.9]# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
[root@nginx nginx-1.9.9]# cp /usr/local/src/nginx-1.9.9/objs/nginx /usr/local/nginx/sbin/nginx
2、ngx_headers_more的用法
more_set_headers替换(如有)或增加(如果不是所有)指定的输出header头时响应状态代码与-s选项相匹配和响应的内容类型的-t选项指定的类型相匹配的。
语法:more_set_headers [-t ]… [-s ]… …
默认值:no
配置段:http, server, location, location if
阶段:输出报头过滤器
more_clear_headers清除指定的输出header头。
语法:more_clear_headers [-t ]… [-s ]… …
默认值:no
配置段:http, server, location, location if
阶段:输出报头过滤器
more_set_input_headers设置指定的输入header头,和more_set_headers类似,仅支持-t选项。
语法:more_set_input_headers [-r] [-t ]… …
默认值:no
配置段:http, server, location, location if
阶段: rewrite tail
注意:使用-t选项的是过滤请求头的Content-Type,而不是响应头的。
more_clear_input_headers清除指定输入header头。
语法:more_clear_input_headers [-t ]… …
默认值:no
配置段:http, server, location, location if
阶段: rewrite tail
在nginx.conf配置中的server段,添加清除header信息
location /api/ {
more_clear_headers “X-Powered-By”;
more_clear_headers “Server”;
more_clear_headers “ETag”;
more_clear_headers “Connection”;
more_clear_headers “Date”;
more_clear_headers “Accept-Ranges”;
more_clear_headers “Last-Modified”;
}
洋果子店rose最新版本
洋果子店最新版是一款十分容易让人垂涎的开店经营类手游。游戏玩
明日大亨最新版
明日大亨手游,一个非常经典有趣的模拟经营类型的商战手游,在游
早安我的少年日服最新版2024
早安我的少年日服是一款治愈恋爱手游,清新明亮的游戏画面,让你
我的世界基岩版1.16正式版
我的世界基岩版是一款模拟经营手游,游戏采用的是经典像素玩法,
早安我的少年最新版2024
早安我的少年是一款养成恋爱手游,在这款游戏中,玩家们将可以体