Nginx gets the value of the custom header header

Source: Internet
Author: User
Nginx Read Custom Header

In reference to the information:
Http://stackoverflow.com/questions/8393772/how-to-get-non-standard-http-headers-on-nginx
Http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers
Http://serverfault.com/questions/297225/nginx-passing-back-custom-header
https://easyengine.io/tutorials/nginx/forwarding-visitors-real-ip/
http://www.ttlsa.com/nginx/nginx-proxy_set_header/
After getting the following:
1, Nginx is supported to read non-nginx standard user custom header, but need to open the header under HTTP or server underline support:

    • Underscores_in_headers on;

2, such as our custom header for X-real-ip, through the second nginx to get the header need this:

    • $http _x_real_ip; (All lowercase, and a http_ in front)

3. If you need to pass the custom header to the next nginx:

    • If is in Nginx custom uses Proxy_set_header x_custom_header $http _host;

    • If the HEADER is customized at user request, such as curl–head-h "X_custom_header:foo" http://domain.com/api/test, you need proxy_pass_header X_CUSTOM_HEADER to pass the

Example:

http { {127.0        .     0.1 : 8082 ; }    underscores_in_headerson;          {Listen        ;              server_name  localhost; location/{Some      -Thing     $http _x_custom_header;;       proxy_set_header X-forwarded- for $proxy _add_x_ Forwarded_for;       proxy_pass http://myServer; }}}

The above describes the Nginx get custom header header values, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.