Ngx_headers_more is a good module of Nginx. ngx_headers_more is mainly used to add, set, and clear input or output http header information. The following describes how to install, use, and configure the Nginx ngx_headers_more module.
1. Install the latest ngx_headers_more package.
[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
The [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
The [root @ nginx nginx-1.9.9] # make
[Root @ nginx nginx-1.9.9] # cp/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. Usage of ngx_headers_more
More_set_headers replacement (if any) or addition (if not all) the response status code of the specified output header matches the-s option and the-t option of the response content type.
Syntax: more_set_headers [-t]… [-S]… ...
Default value: no
Configuration section: http, server, location, location if
Phase: output header filter
More_clear_headers clears the specified output header.
Syntax: more_clear_headers [-t]… [-S]… ...
Default value: no
Configuration section: http, server, location, location if
Phase: output header filter
Set the specified input header in more_set_input_headers. Similar to more_set_headers, only the-t option is supported.
Syntax: more_set_input_headers [-r] [-t]… ...
Default value: no
Configuration section: http, server, location, location if
Phase: rewrite tail
Note: The-t option is used to filter the Content-Type of the request header, rather than the response header.
More_clear_input_headers clears the specified input header.
Syntax: more_clear_input_headers [-t]… ...
Default value: no
Configuration section: http, server, location, location if
Phase: rewrite tail
In the nginx. conf configuration, add the clear header information.
Location/api /{
More_clear_headers "X-Powered-";
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 ";
}