Nginx 一些内置的变量

Nginx 一些内置的变量

core module var:
$arg_PARAMETER
$args
$content_length
$content_type
$document_root
$document_uri
$host
$http_user_agent
$http_cookie
$is_args
$limit_rate
$query_string
$request_body_file
$request_method
$remote_addr
$remote_port
$remote_user
$request_filename
$request_uri
$scheme
$server_protocol
$server_addr
$server_name
$server_port
$uri
log module var:
$body_bytes_sent, the number of bytes, transmitted to client minus the response headers. This variable is compatible with the %B parameter of Apache's mod_log_config (this was called $apache_bytes_sent, before version 0.3.10)
$bytes_sent, the number of bytes transmitted to client
$connection, the number of connections
$msec, the current time at the moment of writing the log entry (microsecond accuracy)
$pipe, "p" if request was pipelined
$request_length, the length of the body of the request
$request_time, the time it took nginx to work on the request, in milliseconds, (in seconds for versions older than 0.5.19)
$status, status of answer
$time_local, local time into common log format.
$http_x_forwarded_for, X-Forward information 
# 于 apache 兼容的日志格式
------------------------------------------------- APACHE2.2 ------------------------------------------------
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T %D %{TETX_USER_KEY}C" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
================================================== Nginx 0.7.35 ============================================
        log_format  tetx  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" 0 $request_time $TETX_USER_KEY "$http_x_forwarded_for" $host';
日志回滚:
利用命名管道来做这事情,昨天去实践了一下。
先创建一个命名管道,
  1. mkfifo /path/to/nginx/logs/access_log_pipe
当然也可以直接用命名管道代替原来的日志文件。
然后让 cronolog 从这个文件读:
  1. /path/to/cronolog /path/to/log/access_%Y%m%.log <  /path/to/nginx/logs/access_log_pipe &
把 nginx 的日志路径指到那个命名管道然后重启一下就可以了。之后在 nginx 的启动脚本里要把启动 cronolog 放在启动nginx 之前

你可能感兴趣的:(nginx,职场,休闲)