Home > Operation and Maintenance > Nginx > How to configure status monitoring in nginx

How to configure status monitoring in nginx

王林
Release: 2023-05-28 23:06:31
forward
1487 people have browsed it

Nginx has a built-in status page, which needs to be opened by specifying the --with-http_stub_status_module parameter during compilation.
In other words, this function is provided by the http_stub_status_module module and is not loaded by default.

Configuration file example

server{
    listen 80;
    server_name www.xxx.com;
    
    location /status/ {
        stub_status on;
        access_log off;
        allow 127.0.0.1;
        allow 192.168.10.0/24;
        deny all;
    }
}
Copy after login

Configuration instructions

  • location /status/such that when accessing/ You can access the content of the status page by clicking status/.

  • stub_status on opens the status page.

  • access_log off does not record logs

  • allow and deny only allow access to specified IPs and IP segments, because this page needs to be protected and does not Public, of course, user authentication can also be done.

Testing and Results Description

测试命令:curl -x127.0.0.1:80 www.xxx.com/status/

结果如下:
Active connections: 1 
server accepts handled requests
 11 11 11 
Reading: 0 Writing: 1 Waiting: 0 

说明:
active connections – 活跃的连接数量
server accepts handled requests — 总共处理的连接数、成功创建的握手次数、总共处理的请求次数
需要注意,一个连接可以有多次请求。
reading — 读取客户端的连接数.
writing — 响应数据到客户端的数量
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.
Copy after login

The above is the detailed content of How to configure status monitoring in nginx. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template