Nginx 使用 ngx_headers_more 模块来增加、删除出站、入站的 Header 信息。
ngx_headers_more 项目主页
默认该模块没有加入到 Nginx 的源码中,要想使用相关功能需要在编译 Nginx 时加入该模块。
本人服务器中的 Nginx 在编译时没有加入该模块,使用 -V 查看当前 Nginx 的编译参数:
[root@z-dig ~]# nginx -V
nginx version: www.z-dig.com
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www \
--with-http_ssl_module --with-http_stub_status_module
[root@z-dig ~]#
1
2
3
4
5
6
7
8
[root@z-dig~]# nginx -V
nginxversion:www.z-dig.com
builtbygcc4.4.720120313(RedHat4.4.7-16)(GCC)
builtwithOpenSSL1.0.1e-fips11Feb2013
TLSSNIsupportenabled
configurearguments:--prefix=/usr/local/nginx--user=www--group=www\
--with-http_ssl_module--with-http_stub_status_module
[root@z-dig~]#
从官网下载模块:
[root@z-dig ~]# cd /usr/local/src/
[root@z-dig src]# wget 、https://codeload.github.com/openresty/headers-more-nginx-module/zip/master\
-O ./headers-more-nginx-module-master.zip
[root@z-dig src]# unzip headers-more-nginx-module-master.zip
1
2
3
4
[root@z-dig~]# cd /usr/local/src/
[root@z-digsrc]# wget 、https://codeload.github.com/openresty/headers-more-nginx-module/zip/master\
-O./headers-more-nginx-module-master.zip
[root@z-digsrc]# unzip he