Nginx reads custom headers
Reference 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/
The following is obtained:
1. nginx supports reading non-nginx standard user-defined headers, but it needs to be Enable header underline support under http or server:
underscores_in_headers on;
2. For example, if we customize the header to be
$http_x_real_ip; (Always use lower case, and there is an extra http_ in front)<span>http</span><span>{</span><span> upstream myServer </span><span>{</span><span> server </span><span>127.0</span><span>.</span><span>0.1</span><span>:</span><span>8082</span><span>;</span><span>}</span><span> underscores_in_headers on</span><span>;</span><span> server </span><span>{</span><span> listen </span><span>80</span><span>;</span><span> server_name localhost</span><span>;</span><span> location </span><span>/</span><span>{</span><span> proxy_set_header </span><span>Some</span><span>-</span><span>Thing</span><span> $http_x_custom_header</span><span>;;</span><span> proxy_set_header X</span><span>-</span><span>Forwarded</span><span>-</span><span>For</span><span> $proxy_add_x_forwarded_for</span><span>;</span><span> proxy_pass http</span><span>://</span><span>myServer</span><span>;</span><span>}</span><span>}</span><span>}</span>
The above introduces Nginx to obtain the value of the custom header, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.