Nginx NGX_HEADERS_MORE sets clearing headers

Source: Internet
Author: User

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 ";
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.