nginx实时记录请求状态信息( ngx_realtime_request_module)

关于 ngx_realtime_request是nginx用来统计虚拟主机流量的模块, 首先和大家说下这个模块是基于域名的,将会记录这个域名的请求量、发送字节、返回http状态码的数量,特性如下:
  • 基于域名记录
  • 记录请求数据量
  • 记录发送、响应流量
  • 记录返回各种http状态码统计数据
1.  安装
# cd /usr/local/src/
# wget "http://nginx.org/download/nginx-1.4.2.tar.gz"
# tar -xzvf nginx-1.4.2.tar.gz
# wget https://github.com/magicbear/ngx_realtime_request_module/archive/master.zip -O ngx_realtime_request.zip
# unzip ngx_realtime_request.zip
# cd nginx-1.4.2/
# ./configure --prefix=/usr/local/nginx-1.4.2 --add-module=../ngx_realtime_request_module-master
# make
# make install
2.  指令(directives) realtime_zonesize 语法: realtime_zonesize size 默认值: 4m 配置块: http 设置slab大小 realtime_request 语法: realtime_request [on/off] 默认值: none 配置块: location 开启统计 3.  配置实例
http {
    realtime_zonesize  16m;

    server {
        server_name www.ttlsa.com
        location ~ /ttlsa-rt-status {
            realtime_request on;
        }
    }
}
4. 测试 访问http://www.ttlsa.com几次,制造几个404和200等等 查看状态http://www.ttlsa.com/ttlsa-rt-status如下图 [caption id="attachment_4160" align="alignnone" width="534"] ngx_realtime_request ngx_realtime_request[/caption] 上图解释: uptime:18 ->nginx运行了18秒 version:0.5 -> 当前插件版本 host:当前统计的域名,如果这台服务器有多个域名,会显示多行 request:请求量8个 recv:接收5294字节 send:发送2043字节 20x:响应了7次20x的状态码 30x:返回了0次30x 40x:返回了1次40xhttp状态码(我测试的404) 50x:返回了0次50x 5. 兼容性 如下版本已做测试 1.3.x (tested with 1.3.6 to 1.3.15). 1.4.2 运维时间用这个版本做了测试 6. 参考文章 项目地址:https://github.com/magicbear/ngx_realtime_request_module 参考文档:http://www.ttlsa.com/nginx/nginx-modules-ngx_realtime_request_module/ 网站: 运维生存时间 

转载于:https://my.oschina.net/766/blog/210995

要在 Nginx 中安装 ngx_http_mp4_module 模块,需要按照以下步骤进行操作: 1. 确认 Nginx 是否支持 ngx_http_mp4_module 模块 首先需要确认 Nginx 是否支持 ngx_http_mp4_module 模块,可以使用以下命令查看 Nginx 是否已经编译了该模块: ``` nginx -V 2>&1 | grep -o with-http_mp4_module ``` 如果输出结果为 with-http_mp4_module,则说明 Nginx 已经编译了 ngx_http_mp4_module 模块;如果输出结果为空,则说明 Nginx 没有编译该模块。 2. 下载 ngx_http_mp4_module 模块 如果 Nginx 没有编译 ngx_http_mp4_module 模块,需要下载该模块并添加到 Nginx 中。可以从 Github 上下载该模块,链接为:https://github.com/kaltura/nginx-vod-module。 可以使用以下命令将 ngx_http_mp4_module 模块下载到 /opt 目录下: ``` cd /opt git clone https://github.com/kaltura/nginx-vod-module.git ``` 3. 编译 Nginx 并添加 ngx_http_mp4_module 模块 在编译 Nginx 时需要添加 --add-module=/opt/nginx-vod-module 参数来指定 ngx_http_mp4_module 模块所在的目录,具体命令如下: ``` ./configure --prefix=/usr/local/nginx --add-module=/opt/nginx-vod-module make make install ``` 4. 配置 NginxNginx 的配置文件中添加以下内容,即可使用 ngx_http_mp4_module 模块: ``` location /video/ { mp4; mp4_buffer_size 1m; mp4_max_buffer_size 5m; } ``` 其中,/video/ 是视频文件所在的目录。mp4 是 ngx_http_mp4_module 模块提供的指令,表示该目录下的文件都是 MP4 格式的视频文件。 mp4_buffer_size 和 mp4_max_buffer_size 是 ngx_http_mp4_module 模块提供的两个参数,用于控制视频文件的缓存大小。 5. 重启 Nginx 完成以上步骤后,需要重启 Nginx 使配置生效: ``` nginx -s reload ``` 至此,ngx_http_mp4_module 模块安装完成。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值