Nginx系列教程:HTTP Log模块

ngx_http_log_module

实例

log_format gzip '$remote_addr - $remote_
user [$time_local] ': '"$request" $status $bytes_sent ': '"$http_referer" "$http_user_
agent" "$gzip_ratio"';access_log /spool/logs/nginx-access.log gzip buffer=32k;

指令

access_log log_format

access_log

语法: access_log path [format [buffer=size | off ] 默认值: access_log log/access.log combined

作用域: http, server, location

指令 access_log 指派路径、格式和缓存大小。参数 "off" 将清除当前级别的所有 access_log 指令。如果未指定格式,则使用预置的 "combined" 格式。缓存不能大于能写入磁盘的文件的最大大小。在 FreeBSD 3.0-6.0 ,缓存大小无此限制。

log_format

语法: log_format name format [format ...]

默认值: log_format combined "..."

作用域: http server

Directive log_format describes the format of a log entry. Besides general variables in the format it is possible to use variables which exist only at the moment of record into the log:

$body_bytes_sent, the number of bytes, transmitted to client minus the response headers, variable is compatible with parameter %B of module 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 connection $msec, the time with an accuracy to microseconds at the moment of the log entry $pipe, "p" if request was pipelining $request_length, the length of the body of the request $request_time, the time of working on request in seconds $status, status of answer $time_local, local time into common log format.

The headers, transmitted to client, begin from the prefix "sent_http_", for example, $sent_http_content_range.

In the configuration there is always a predetermined format "combined":

log_format combined '$remote_addr - $remote_user [$time_local] ': '"$request" $status $apache_bytes_sent ': '"$http_referer" "$http_user_agent"';

时间: 2024-07-31 09:26:31

Nginx系列教程:HTTP Log模块的相关文章

Nginx系列教程:nginx_module_development模块开发

好像这是唯一的一份模块开发文档.. 以下简称 guide 读代码!! nginx 程序启动 把 nginx.conf 读入内存 处理模块 ngx_http_module_t 定义的 configuration. 应该是如下的执行顺序 pre create_main_conf 执行 ngx_command_t 里面定义的函数. 可以视为 init_main_conf 的自动处理部分 init_main_conf ... postconfig listen fork 子进程(真正的服务器进程 mas

Nginx系列教程:nginx_substitutions_filter模块

nginx_substitutions_filter 请注意:此模块不是Nginx源的分布,可点击此链接找到安装说明, http://wiki.nginx.org/NginxHttpSubsModule#Installation . 概述 nginx_substitutions_filter 是一个过滤器模块,它可以在响应主体上运行正则表达式和固定字符串替换.该 模块不同于Nginx的本地替代模块.它能够扫描输出链缓冲区和匹配逐行字符串,类似于http://www.aliyun.com/zixu

Nginx系列教程:ngx_cache_purge模块

ngx_cache_purge 本模块由第三方提供,不包含在 Nginx 的源码发布版中. 概述 ngx_cache_purge是nginx模块,用于从FastCGI.proxy.SCGI 和uWSGI5603.html">缓存中增加内容清除功能. 安装 下载模块源码:ngx_cache_purge-1.2(更新记录)(SHA1: d9468cf42432e81ea3a110ec63aae2eb273f5516) 其他版本 解压,然后编译: ./configuremake &&am

Nginx系列教程:事件模块

设置Nginx处理连接请求 指令 accept_mutex Syntax: accept_mutex [ on | off ] Default: on nginx 使用连接互斥锁进行顺序的accept()系统调用. accept_mutex_delay Syntax: accept_mutex_delay Nms; Default: 500ms 如果一个进程没有互斥锁,它将延迟至少多长时间.默认情况下,延迟是500ms . debug_connection Syntax: debug_conne

Nginx系列教程:HTTP模块

控制Nginx HTTP 进程的核心属性. 指令 alias 语法: alias file-path|directory-path; 默认值: no 作用域: location 该指令设置指定location使用的路径.注意它跟 root 相似,但是不改变文件的根路径,仅仅是使用文件系统路径.比如: location&http://www.aliyun.com/zixun/aggregation/37954.html">nbsp; /i/ {  alias  /spool/w3/i

Nginx系列教程:NginxHttpOwnerMatch模块(解决链接型文件跨站访问)

概述 该模块提供了一个简单文件基于所有者的http://www.aliyun.com/zixun/aggregation/38609.html">访问控制. nginx_http_owner_match_module模块使得它可以控制具体文件的所有者和组织的访问. 访问规则检查是根据其声明的顺序. 配置范例: location / {  omallow heiher;  # allow access files of heiher  omallow jack sftp; # allow a

Nginx系列教程:HTTP Secure Link模块

此模块计算和检查要求所需的安全链接网址.此模块默认情况下不会被编译启用,要启用它请使用指令 --with-http_secure_link_module 参与编译安装 nginx .注意:此模块仅在 nginx 版本为0.7.18或更高时才被支持. 配置实例: location /p/ { location ~ ^/p/(?<secure>[\w\-=]+,\d+)(?<file>/.+)$ {  secure_link $secure; secure_link_md5 $secu

Nginx系列教程:LNMP多用户动态进程管理虚拟主机方案

A. 特点1. 高效.内存使用少.2. 权限分离,用户间互不干扰.3. 动态进程管理,资源分配均衡. B. 应用程序说明Nginx:事件驱动的 Web 服务器,采用模块化设计,小巧.高效.PHP-FPM:支持快速进程管理的 PHP FastCGI 接口版本,用它实现动态进程管理,提高资源使用效率. C. 整个架构的简单说明Nginx 处理所有的 Web 请求,它将 PHP 的请求 Match 出,发送给上游服务器处理,这里的上游服务器就是 PHP-CGI.PHP-CGI 工作在 FastCGI

Nginx系列教程:LNMP多用户虚拟主机方案

A. 特点1. 高效.内存使用少.2. 权限分离,用户间互不干扰. B. 应用程序说明Nginx : 事件驱动的 Web 服务器,采用模块化设计,小巧.高效.PHP-CGI : PHP的CGI接口版本(本文使用FastCGI高效接口). C. 整个架构的简单说明Nginx 处理所有的 Web 请求,它将 PHP 的请求 Match 出,发送给上游服务器处理,这里的上游服务器就是 PHP-CGI.PHP-CGI 工作在 FastCGI 模式,它侦听着一个地址端口(或 Unix socket文件,建