Nginx 本身没有默认的专用监控端口,但可以通过以下方式进行监控和相关端口的配置:
ngx_http_stub_status_module(基础监控)或 ngx_http_api_module(Nginx Plus 专属)80 或 443),通过特定 URL 暴露状态。nginx
server {
listen 80;
location /nginx_status {
stub_status on;
allow 127.0.0.1; # 限制访问IP
deny all;
}
}http://<nginx_server>:80/nginx_statusActive connections: 3
server accepts handled requests
10 10 20
Reading: 0 Writing: 1 Waiting: 2nginx-prometheus-exporter9113(可自定义)stub_status 或 Nginx Plus 的 API 数据转换为 Prometheus 格式。bash
nginx-prometheus-exporter -nginx.scrape-uri http://<nginx_server>:80/nginx_status| 工具/协议 | 默认端口 | 说明 |
|---|---|---|
| Zabbix | 10050 | Agent 端口(需自定义监控项) |
| Telegraf | - | 通过插件采集,无固定端口 |
| SNMP | 161 | 需 Nginx 支持 SNMP 扩展 |
| OpenTelemetry | 4317/55680 | 可配置为暴露指标数据 |
stub_status 复用业务端口(如 80)。9113(Prometheus Exporter)或其他自定义端口。