current position:Home>6.Nginx_ variable

6.Nginx_ variable

2021-08-25 09:53:45 Little monster 55

nginx Can be referenced in the configuration file , It is used as a function judgment or log , Variables can be divided into built-in variables and user-defined variables , Built in variables are created by nginx The module comes with , Many values related to client access can be obtained through variables
Common built-in variables
$remote_addr;# The address of the client is stored , Note the public network of the client IP

$args;# The variable holds URL The instructions in
 above :id=090&partner=search  That is to say  $args
  • 1.
  • 2.

$document_root;# The system root directory that holds the request for the current resource , Such as /apps/nginx/html

$cookie_name; # Express key by name Of cookie value

$document_uri;# Save... That does not contain instructions in the current request URI, Note that the requested instruction is not included , Such as
Will be defined as /main/

$host;# Put the requested host name

$http_user_agent;# Client browser details

$http_cookie;# Client's cookie Information

$limit_rate;# If nginx Server usage limit_rate The display network rate is configured , Is displayed , If not set , Is displayed 0

$remote_port;# Client request Nginx The port that the client randomly opens when the server is running

$remote_user;# Have already been Auth Basic Module The verified user name

$request_body_file;# The name of the local resource sent to the back-end server when doing reverse proxy

$request_method;# How to request resources ,GET/PUT/DELETE etc.

$request_filename;# The pathname of the currently requested resource file , from root or alias Command and URI The absolute path of the file generated by the request , Such as /apps/nginx/html/main/index.html

$request_uri;# The primitive that contains the request parameters URI, Host name is not included . Such as :main/

$scheme;# Requested agreement , Such as ftp,https,http etc.

$server_protocol;# The protocol version of the requested resource , Such as HTTP/.0,HTTP/.,HTTP/.0 etc.

$server_addr;# Saved the server's IP Address

$server_name;# The hostname of the requested server

$server_port;# Port of the requested server

Custom variable :
Custom variable name and value , Use instruction set $variable value
The format is as follows :
set $variable value;
Support :server, location, if
Example :
set $name magedu;
echo $name;
set $my_port $server_port;
echo $my_port;
echo "$server_name:$server_port";

copyright notice
author[Little monster 55],Please bring the original link to reprint, thank you.

Random recommended