nginx常用模块(状态模块)

语法

Syntax: stub_status;
Default: —
Context: server, location

server {
    listen 80;
    server_name www.test.com;
    
    location / {
        root /code;
        index index.html;
    }
    location /download {
        root /code;
        index index.html;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
        allow all;
        auth_basic on;
        auth_basic_user_file /etc/nginx/auth_basic;
    }
    location /status {
        stub_status;
    }
}

 

#访问 http://www.test.com/status

#返回内容
Active connections: 2 
server accepts handled requests
           2      2             1 
Reading: 0 Writing: 1 Waiting: 1 

#nginx七种状态
Active connections        #活跃的连接数
accepts                   #接受的TCP连接数
handled                   #已处理的TCP连接数
requests                  #请求数
Reading                   #读取的请求头的数量
Writing                   #响应的请求头的数量
Waiting                   #等待的请求数量

[root@web02 /etc/nginx/conf.d]# curl -s www.test.com/status| awk 'NR==3{print $3}'
原文地址:https://www.cnblogs.com/chenlifan/p/13560932.html