Nginx gets the value of the custom header header
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)- 3. If you need to pass the custom header to the next nginx:
- If the header is customized when the user requests it, such as curl –head -H “X_CUSTOM_HEADER: foo” http://domain.com/api/test, you need to pass proxy_pass_header X_CUSTOM_HEADER
- to pass
Example:
<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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Wordpress site file access is restricted: troubleshooting the reason why .txt file cannot be accessed recently. Some users encountered a problem when configuring the mini program business domain name: �...

Running multiple PHP versions simultaneously in the same system is a common requirement, especially when different projects depend on different versions of PHP. How to be on the same...

Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.

Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

How to share the same page on the PC and mobile side and handle cache issues? In the nginx php mysql environment built using the Baota background, how to make the PC side and...

Solution to Redirecting 404 Errors after Simulation Login When using Selenium for Simulation Login, we often encounter some difficult problems. �...

About efficient use of CMD commands in Dockerfile Many new Docker users are using CMD...
