Nginx configuration test service status

Posted by logicopinion on Thu, 14 Nov 2019 16:49:21 +0100

1. Check whether the check status module is installed;

[root@localhost ~]# nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
configure arguments: --prefix=/usr/local/nginx --with-http_sub_module

2. If it is not installed, recompile and install it;

Check status module; -- with HTTP > status > module

[root@localhost ~]# cd /usr/local/src/nginx-1.12.2/                           
[root@localhost ~]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
[root@localhost ~]# make && make install

3. Edit the configuration file of nginx;

[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
server {
        listen  80;
        server_name  localhost;
        #access_log  logs/host.access.log  main;
 
        location /nginx_status  {
        stub_status on;
        access_log off;
         #allow 127.0.0.1; ##Visitors to this page can be filtered
         #deny all;
         }
     }
[root@localhost ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost ~]# nginx -s reload

4. Test syntax;

[root@localhost ~]# curl http://192.168.10.110:80/nginx_status
Active connections: 1
server accepts handled requests
 1   1   1
Reading: 0 Writing: 1 Waiting: 0

5. Output details;

First line Active connections: 1 -- number of Active connections, including waiting clients 0
The second line server accepts handled requests -- processed 1 connection in total, successfully created 1 handshake, processed 1 request in total
In the third line, Reading - the number of connections to read the client, Writing - the number of responses to the client, Waiting - when keep alive is enabled, this value is equal to active - (reading+writing), which means that Nginx has processed the resident connection Waiting for the next request instruction


Topics: Linux Nginx vim curl