$http_origin in Nginx config files

$http_<headername> is automatically created based on the request headers. You can see the same on

https://nginx.org/en/docs/http/ngx_http_core_module.html#var_http_

$http_name

arbitrary request header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores


If you look closer at http://nginx.org/docs/varindex.html, you'll notice there's only a single item with a prefix of $http_ mentioned on that page; and, in fact, this single item is lacking any further suffix, being generic on purpose.

The functionality is documented over at http://nginx.org/r/$http_ as follows:

$http_name — arbitrary request header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores


However, if you look into the source code behind nginx, it does have internal optimisations for storing certain specific request headers in individual variables for performance reasons (these are defined as a list in the code below, but they are henceforth placed into a hash table during the initialisation process of nginx by ngx_http_variables_add_core_vars() function). For example, $http_host, $http_user_agent and $http_referer, plus a bunch of other variables that may have to be handled internally by certain nginx components, or which may be frequently used within the configuration files.

  • http://ngx.su/src/http/ngx_http_request.h#ngx_http_header_t
  • http://ngx.su/src/http/ngx_http_variables.c#ngx_http_core_variables
  • http://ngx.su/src/http/ngx_http_variables.c#ngx_http_variables_add_core_vars

However, as an end-user, you don't really have to worry about those kinds of details — the generic $http_name is sufficient to describe the whole functionality. (In fact, $http_origin isn't special or popular enough to have warranted its own specialised handling.)

Tags:

Nginx