The NGINX web server has a number of built-in variables whose values may be needed in certain situations. Consider a small snippet that will help you understand their meaning.
Quote from the documentation:
The ngx_http_core_module module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing client request header fields, such as $http_user_agent, $http_cookie, and so on.
Let's pass the values of the main variables in the request header. Add these lines to the NGINX configuration file:
add_header x0-NGINX-DEBUG '=========================================';
add_header x1-NGINX-http_user_agent $http_user_agent;
add_header xA-NGINX-http_cookie $http_cookie;
add_header xB-NGINX-request $request;
add_header xC-NGINX-request_body $request_body;
add_header xD-NGINX-request_method $request_method;
add_header xE-NGINX-request_time $request_time;
add_header xF-NGINX-request_uri $request_uri;
add_header xG-NGINX-scheme $scheme;
add_header xH-NGINX-request_server_name $server_name;
add_header xI-NGINX-request_server_port $server_port;
add_header xJ-NGINX-uri $uri;
add_header xK-NGINX-args $args;
add_header xL-NGINX-is_args $is_args;
add_header xM-NGINX-request_filename $request_filename;
add_header xN-NGINX-pid $pid;
add_header xO-NGINX-document_root $document_root;
add_header xP-NGINX-document_uri $document_uri;
add_header xQ-NGINX-host $host;
add_header xR-NGINX-hostname $hostname;
add_header xS-NGINX-proxy_protocol_addr $proxy_protocol_addr;
add_header xT-NGINX-proxy_protocol_port $proxy_protocol_port;
add_header xU-NGINX-query_string $query_string;
add_header xV-NGINX-realpath_root $realpath_root;
add_header xW-NGINX-remote_addr $remote_addr;
add_header xX-NGINX-remote_port $remote_port;
add_header xY-NGINX-remote_user $remote_user;
add_header xZ-NGINX-DEBUG '=========================================';
The first part of the name of each header, type x1-NGINX — does not mean anything, the letters — for sorting, the last part — duplicates the name of the variable.
Of course, you can add any arbitrary title:
# dev
add_header Z-PHP-BACKEND 'DRUPAL LAUNCHED';
For convenience, you can put this in a separate file like debug-headers.conf and insert it in the config:
# DEBUG: Nginx variables in headers
include includes/debug-headers.conf;
Do not forget to remove this output after debugging!
Examples of headers with NGINX variables
An example of the Drupal headers for the request (the authenticated user) to the address:
http://drupalvm.dev/search/node?keys=234
Result:
x0-NGINX-DEBUG:=========================================
x1-NGINX-http_user_agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
xA-NGINX-http_cookie: SESSa8464a72f90cb48bd2b8e69d439a9446=tnzOVQ2Y4QDJ5ehKWGXmcF94JxKjXb7JQxf5H-IAxfc
xB-NGINX-request: GET /search/node?keys=234 HTTP/1.1
xD-NGINX-request_method: GET
xE-NGINX-request_time: 0.519
xF-NGINX-request_uri: /search/node?keys=234
xG-NGINX-scheme: http
xH-NGINX-request_server_name: drupalvm.dev
xI-NGINX-request_server_port: 80
xJ-NGINX-uri: /index.php
xK-NGINX-args: keys=234
xL-NGINX-is_args: ?
xM-NGINX-request_filename: /var/www/drupalvm/drupal/web/index.php
xN-NGINX-pid: 13351
xO-NGINX-document_root: /var/www/drupalvm/drupal/web
xP-NGINX-document_uri: /index.php
xQ-NGINX-host: drupalvm.dev
xR-NGINX-hostname: drupalvm
xU-NGINX-query_string:keys=234
xV-NGINX-realpath_root: /var/www/drupalvm/drupal/web
xW-NGINX-remote_addr: 10.0.1.1
xX-NGINX-remote_port: 53240
xZ-NGINX-DEBUG:=========================================
Example of an address without parameters and from an anonymous user:
http://drupalvm.dev/mypage
Result:
x0-NGINX-DEBUG:=========================================
x1-NGINX-http_user_agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
xB-NGINX-request: GET /mypage HTTP/1.1
xD-NGINX-request_method: GET
xE-NGINX-request_time: 0.008
xF-NGINX-request_uri: /mypage
xG-NGINX-scheme: http
xH-NGINX-request_server_name: drupalvm.dev
xI-NGINX-request_server_port: 80
xJ-NGINX-uri: /index.php
xM-NGINX-request_filename: /var/www/drupalvm/drupal/web/index.php
xN-NGINX-pid: 13351
xO-NGINX-document_root: /var/www/drupalvm/drupal/web
xP-NGINX-document_uri: /index.php
xQ-NGINX-host: drupalvm.dev
xR-NGINX-hostname: drupalvm
xV-NGINX-realpath_root: /var/www/drupalvm/drupal/web
xW-NGINX-remote_addr: 10.0.1.1
xX-NGINX-remote_port: 53733
xZ-NGINX-DEBUG:=========================================
This is how it looks in Chrome Dev Tools: