Home > Operation and Maintenance > Nginx > How to configure Nginx to detect service status

How to configure Nginx to detect service status

WBOY
Release: 2023-05-31 11:13:06
forward
2375 people have browsed it

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
Copy after login

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

ø Check Status module; --with-http_stub_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
Copy after login

3. Edit nginx configuration file;

[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; ##可对该页面的访问者进行过滤
   #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
Copy after login

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
Copy after login

5. Detailed explanation of the output content;

First line active connections: 1 ——The number of active connections, including waiting Number of clients 0
The second line server accepts handled requests——A total of 1 connection was processed, 1 handshake was successfully created, and a total of 1 request was processed
The third line reading - reading the number of connections from the client, writing - the number of response data to the client, waiting - when keep-alive is turned on, this value is equal to active - (reading writing), which means nginx has After processing the resident connection that is waiting for the next request command.

The above is the detailed content of How to configure Nginx to detect service status. 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