Nginx模块之stub_status
发表于:2022-11-03 |
一.介绍
Nginx中的stub_status模块主要用于查看Nginx的一些状态信息.
当前默认在nginx的源码文件中,不需要单独下载

刚开始安装这个模块的时候报错

nginx: [emerg] invalid number of arguments in "stub_status" directive in /usr/local/nginx/conf/nginx.conf:44

通过nginx-V发现没有这个--with-http_stub_status_module这个模块

-with-http_stub_status_module作用是一个监视模块,可以查看目前的连接数等一些信息,因为是非核心模块,所以我们使用nginx -V默认是没有安装的


二.使用
本模块默认是不会编译进Nginx的,如果你要使用该模块,则要在编译安装Nginx时指定:
./configure –-with-http_stub_status_module

在server板块中添加一个location,访问127.0.0.1/nginx-status将会出现状态信息,里面记录nginx处理链接数等等

#放在某个开放的server区块,填写一个location
server{
         location /nginx-status {
             allow -------- #允许的ip,不然都能看了,一般允许本地

             deny all; #默认最后全拒绝,除了allow的

             stub_status on;

             access_log  off;
        }
}
三.参数
然后请求www.domain.com/nginx-status 就行了,下面是结果

Active connections: 5
server accepts handled requests
 5970806143 5970806143 7560482010
Reading: 0 Writing: 5 Waiting: 0
Active connections: 对后端发起的活动连接数.

Server accepts handled requests: Nginx总共处理了38810620个连接,成功创建38810620次握手(证明中间没有失败的),总共处理了298655730个请求.

Reading: Nginx 读取到客户端的Header信息数.

Writing: Nginx 返回给客户端的Header信息数.

Waiting: 开启keep-alive的情况下,这个值等于 active – (reading + writing),意思就是Nginx已经处理完成,正在等候下一次请求指令的驻留连接.

所以,在访问效率高,请求很快被处理完毕的情况下,Waiting数比较多是正常的.如果reading +writing数较多,则说明并发访问量非常大,正在处理过程中.
上一篇:
ubuntu 内网搭建服务器的一些配置,完美解决https、http、curl、wget、yum 无法访问的问题
下一篇:
Python3 http server:python3 -m httm.server 80