I've seen it used in a lot of examples relating to CORS but where is the value of $http_origin set?
I checked the Nginx variables but there's no mention of it. And there's no mention in PHP FastCGI.
Every NGINX configuration file will be found in the /etc/nginx/ directory, with the main configuration file located in /etc/nginx/nginx. conf . NGINX configuration options are known as “directives”: these are arranged into groups, known interchangeably as blocks or contexts .
Definition of Nginx Add_header. Nginx add_header allows us to define a value and an arbitrary response header is included in the code of the response. The nginx add_header is defined in the configuration file of nginx.
This happens if you haven't set up CORS configuration correctly. you can fix this on you'r local machine using a plugin/extension called Allow-Control-Allow-Origin and add you'r localhost into it. The other way is to manually fix the configuration in server side.
$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.
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With