Okay. I wanted to write more. Now I have no time, eunuch.
Core: The custom http header of the client can be directly read in the nginx configuration file.
Condition: The header must use the minus sign "-" to separate words. nginx converts the header to a lowercase word connected by the underscore.
Nginx configuration:
| The code is as follows: |
Copy code |
Location /{ If ($ http_my_custom_header ~ (D + )){ Rewrite/http://www.111cn.net/last; } }
|
Test:
| The code is as follows: |
Copy code |
Wget -- header = "my-custom-header: 1"-d http://www.111cn.net DEBUG output created by Wget 1.13.4 on linux-gnu. URI encoding = 'utf-8' -- 09:48:40 -- http://www.111cn.net/ Resolving www.111cn.net (www.111cn.net)... 172.31.30.70 Caching www.111cn.net => 172.31.30.70 Connecting to www.111cn.net | 172.31.30.70 |: 80... connected. Created socket 3. Releasing 0x084e3e18 (new refcount 1 ). --- Request begin --- GET, HTTP, 1.1 User-Agent: Wget/1.13.4 (linux-gnu) Accept :*/* Host: www.111cn.net Connection: Keep-Alive My-custom-header: 1 --- Request end --- HTTP request sent, awaiting response... --- Response begin --- HTTP/1.1 302 Moved Temporarily Server: nginx/1.1.19 Date: Mon, 28 Apr 2014 09:48:40 GMT Content-Type: text/html Content-Length: 161 Connection: keep-alive Location: http://www.111cn.net |