$http_*
The variable $http_ holds the value of a specific HTTP header from the client request, prefixed by 'http_'. — NGINX Core (HTTP)
Description
In NGINX, the variable "$http_" is a dynamic prefix for accessing HTTP request headers sent by the client. The syntax for this variable is "$http_
Config Example
server {
listen 80;
location /example {
if ($http_user_agent ~* "Googlebot") {
return 403;
}
add_header X-Your-Header "$http_x_your_header";
}
}Subsystem
httpCacheable
YesType
Prefix variableContexts
http, server, location, ifRemember to convert the header name to lowercase and replace dashes with underscores when forming the variable name, as in `$http_x_forwarded_for`.
Ensure that the headers are present in the client request; accessing a non-existent header will simply yield an empty string.
Use the correct context for this variable to ensure it behaves as expected. It might not work as intended if invoked in the wrong context.