Back to Directory
How to Monitor Recent

How to Monitor an Nginx Web Server & Uptime Metrics

SAuthor

How to Monitor an Nginx Web Server

Nginx is the web server backbone that routes incoming HTTP traffic, resolves SSL handshakes, and load-balances backend application processes. If Nginx crashes, your entire site instantly goes offline with a connection timeout error.

This guide explains how to monitor Nginx web server uptime and map internal request volume and connection metrics to prevent server overload outages.


Step 1: Enable the Nginx Stub Status Module

Nginx has a built-in statistics module called ngx_http_stub_status_module that exposes current connection metrics on a secure endpoint.

Configure Nginx Server Block

Open your Nginx configuration file (e.g. /etc/nginx/sites-available/default) and add a status location block:

server {
    listen 80;
    server_name localhost;

    location /nginx_status {
        stub_status on;

        # Restrict access so only authorized IPs can view connection metrics
        allow 127.0.0.1;
        # Add your local monitoring agent or office IP here:
        # allow YOUR_OFFICE_IP;
        deny all;
    }
}

Reload Nginx to apply configurations:

sudo nginx -t && sudo systemctl reload nginx

Step 2: Check the Status Metrics

Curling your configured endpoint will return text metrics:

curl http://localhost/nginx_status

Output:

Active connections: 291 
server accepts handled requests
 16630 16630 31084
Reading: 6 Writing: 179 Waiting: 106

Explaining the Metrics:

  • Active connections: The number of concurrent open client connections.
  • accepts: Total number of accepted client connections.
  • handled: Total number of handled connections (typically equal to accepts unless client limits are hit).
  • requests: Total client request volume handled by Nginx.
  • Reading: Number of headers Nginx is currently reading.
  • Writing: Active body requests processed or sent back to clients.
  • Waiting: Keep-alive connections idle waiting for requests.

Step 3: Monitor Uptime with Pingzo

To ensure Nginx responds quickly to incoming web traffic, configure active checks on Pingzo:

  1. Log in to your Pingzo Dashboard.
  2. Create an HTTP/HTTPS Monitor pointing to your website URL.
  3. Choose checker frequencies (down to 30 seconds for business critical paths).
  4. Configure custom alerts to receive instant notifications via WhatsApp or Slack if Nginx returns 502 Bad Gateway, 504 Gateway Timeout, or goes offline completely.

Summarize with AI

Instantly generate a summary of this page using your favorite LLM

pz-console
// Terminal
$npm install @pingzoapp/sdk
// Initialization Code
import { Pingzo } from '@pingzoapp/sdk';
const checker = new Pingzo({ apiKey: 'pz_live_...' });
[pingzo-agent] monitoring active: App
[pingzo-agent] status: 200 OK | latency: 85ms
DevOps Uptime Check

Uptime monitoring built for App developers

Configure HTTP health routes, inspect SSL status, and track cron workers from our console dashboard. Get direct texts on WhatsApp.

Start Monitoring Free