Nginx中文文档
DocsHome
  • 贡献导引
  • 介绍
    • 安装 nginx
    • 从源码构建 nginx
    • 初学者指南
    • 管理指南
    • 控制 nginx
    • 连接处理方式
    • 设置哈希
    • 调试日志
    • 记录日志到 syslog
    • 配置文件度量单位
    • 命令行参数
    • Windows 下的 nginx
    • QUIC 和 HTTP/3 支持
    • nginx 如何处理请求
    • 服务器名称
    • 使用 nginx 作为 HTTP 负载均衡器
    • 配置 HTTPS 服务器
    • nginx 如何处理 TCP/UDP 会话
    • 关于 nginScript
  • 其他
    • Linux 软件包
  • How-To
    • 在 Win32 平台上使用 Visual C 构建 nginx
    • 设置 Amazon EC2 的 Nginx Plus 环境
    • 使用 DTrace pid 提供程序调试 nginx
    • 转换重写规则
    • WebSocket 代理
  • 开发
    • 贡献指南
    • 开发指南
  • 模块参考
  • 核心功能
    • HTTP
      • ngx_http_core_module
      • ngx_http_access_module
      • ngx_http_addition_module
      • ngx_http_api_module
      • ngx_http_auth_basic_module
      • ngx_http_auth_jwt_module
      • ngx_http_auth_request_module
      • ngx_http_autoindex_module
      • ngx_http_browser_module
      • ngx_http_charset_module
      • ngx_http_dav_module
      • ngx_http_empty_gif_module
      • ngx_http_f4f_module
      • ngx_http_fastcgi_module
      • ngx_http_flv_module
      • ngx_http_geo_module
      • ngx_http_geoip_module
      • ngx_http_grpc_module
      • ngx_http_gunzip_module
      • ngx_http_gzip_module
      • ngx_http_gzip_static_module
      • ngx_http_headers_module
      • ngx_http_hls_module
      • ngx_http_image_filter_module
      • ngx_http_index_module
      • ngx_http_js_module
      • ngx_http_keyval_module
      • ngx_http_limit_conn_module
      • ngx_http_limit_req_module
      • ngx_http_log_module
      • ngx_http_map_module
      • ngx_http_memcached_module
      • ngx_http_mirror_module
      • ngx_http_mp4_module
      • ngx_http_perl_module
      • ngx_http_proxy_module
      • ngx_http_random_index_module
      • ngx_http_realip_module
      • ngx_http_referer_module
      • ngx_http_rewrite_module
      • ngx_http_scgi_module
      • ngx_http_secure_link_module
      • ngx_http_session_log_module
      • ngx_http_slice_module
      • ngx_http_spdy_module(过时)
      • ngx_http_split_clients_module
      • ngx_http_ssi_module
      • ngx_http_ssl_module
      • ngx_http_status_module(过时)
      • ngx_http_stub_status_module
      • ngx_http_sub_module
      • ngx_http_upstream_module
      • ngx_http_upstream_conf_module
      • ngx_http_upstream_hc_module
      • ngx_http_userid_module
      • ngx_http_uwsgi_module
      • ngx_http_v2_module
      • ngx_http_xslt_module
    • Mail
      • ngx_mail_core_module
      • ngx_mail_auth_http_module
      • ngx_mail_proxy_module
      • ngx_mail_ssl_module
      • ngx_mail_imap_module
      • ngx_mail_pop3_module
      • ngx_mail_smtp_module
    • Stream
      • ngx_stream_core_module
      • ngx_stream_access_module
      • ngx_stream_geo_module
      • ngx_stream_geoip_module
      • ngx_stream_js_module
      • ngx_stream_keyval_module
      • ngx_stream_limit_conn_module
      • ngx_stream_log_module
      • ngx_stream_map_module
      • ngx_stream_proxy_module
      • ngx_stream_realip_module
      • ngx_stream_return_module
      • ngx_stream_split_clients_module
      • ngx_stream_ssl_module
      • ngx_stream_ssl_preread_module
      • ngx_stream_upstream_module
      • ngx_stream_upstream_hc_module
      • ngx_stream_zone_sync_module
    • 其他
      • ngx_google_perftools_module
由 GitBook 提供支持
在本页
  • 示例配置
  • 指令
  • status
  • status_format
  • status_zone
  • 数据
  • 兼容性
  • 原文档
  1. 核心功能
  2. HTTP

ngx_http_status_module(过时)

上一页ngx_http_ssl_module下一页ngx_http_stub_status_module

最后更新于5年前

1.13.10 版本起,该模块被 1.13.3 中的 模块所取代。

ngx_http_status_module 模块提供了访问各种状态信息的接口。

该模块作为我们的一部分提供。

示例配置

http {
    upstream backend {
        zone http_backend 64k;

        server backend1.example.com weight=5;
        server backend2.example.com;
    }

    proxy_cache_path /data/nginx/cache_backend keys_zone=cache_backend:10m;

    server {
        server_name backend.example.com;

        location / {
            proxy_pass  http://backend;
            proxy_cache cache_backend;

            health_check;
        }

        status_zone server_backend;
    }

    server {
        listen 127.0.0.1;

        location /upstream_conf {
            upstream_conf;
        }

        location /status {
            status;
        }

        location = /status.html {
        }
    }
}

stream {
    upstream backend {
        zone stream_backend 64k;

        server backend1.example.com:12345 weight=5;
        server backend2.example.com:12345;
    }

    server {
        listen      127.0.0.1:12345;
        proxy_pass  backend;
        status_zone server_backend;
        health_check;
    }
}

使用此配置的状态请求示例:

http://127.0.0.1/status
http://127.0.0.1/status/nginx_version
http://127.0.0.1/status/caches/cache_backend
http://127.0.0.1/status/upstreams
http://127.0.0.1/status/upstreams/backend
http://127.0.0.1/status/upstreams/backend/peers/1
http://127.0.0.1/status/upstreams/backend/peers/1/weight
http://127.0.0.1/status/stream
http://127.0.0.1/status/stream/upstreams
http://127.0.0.1/status/stream/upstreams/backend
http://127.0.0.1/status/stream/upstreams/backend/peers/1
http://127.0.0.1/status/stream/upstreams/backend/peers/1/weight

简单监视页面随分发包一起提供,使用默认配置可以 /status.html 身份访问。它需要配置 location /status 和 /status.html,如上所示。

指令

status

-

说明

语法

status;

默认

——

上下文

location

status_format

-

说明

语法

status_format json; status_format jsonp [callback];

默认

status_format json

上下文

http、server、location

默认情况下,状态信息以 JSON 格式输出。

或以输出为 JSONP 格式输出,callback 参数指定回调函数的名称。参数值可以包含变量。如果省略参数,或计算的值为空字符串,则使用 "ngx_status_jsonp_callback"。

status_zone

-

说明

语法

status_zone;

默认

——

上下文

server

数据

提供以下状态信息:

  • version

    提供的数据集的版本。目前的版本是 8。

  • nginx_version

    nginx 的版本。

  • nginx_build

    nginx 的构建名称。

  • address

    接受状态请求的服务器的地址。

  • generation

  • load_timestamp

    上次重新加载配置的时间,自 Epoch 后的毫秒数。

  • timestamp

    Epoch 后的当前时间(以毫秒为单位)。

  • pid

    处理状态请求的 worker 进程的 ID。

  • ppid

  • processes

    • respawned

      异常终止和重生的子进程的总数。

  • connections

    • accepted

      已接受的客户端连接总数。

    • dropped

      已删除的客户端连接总数。

    • active

      当前活动客户端连接数。

    • idle

      当前空闲客户端连接数。

  • ssl

    • handshakes

      SSL 握手成功的总数。

    • handshakes_failed

      SSL 握手失败的总数。

    • session_reuses

      SSL 握手期间会话​​重用的总次数。

  • requests

    • total

      客户端请求总次数。

    • current

      当前的客户端请求数。

  • server_zones

    • ngx_http_status_module.html

      当前正在处理的客户端请求数。

    • requests

      从客户端收到的客户端请求总数。

    • responses

      • total

        发送给客户的响应总数。

      • 1xx, 2xx, 3xx, 4xx, 5xx

        状态代码为 1xx、2xx、3xx、4xx 和 5xx 的响应数。

    • discarded

      在未发送响应的情况下完成的请求总数。

    • received

      从客户端收到的总字节数。

    • sent

      发送给客户端的总字节数。

  • slabs

    对于每个使用了 slab 分配器的共享内存区域:

    • pages

      • used

        当前使用的内存页数。

      • free

        当前可用内存页数。

    • slots

      对于每个内存插槽大小(8、16、32、64、128 等),提供以下数据:

      • used

        当前使用的内存槽数。

      • free

        当前可用的内存槽数。

      • reqs

        尝试分配指定大小内存的总次数。

      • fails

        尝试分配指定大小内存的失败次数。

  • upstreams

    • peers

      • id

        服务器的 ID。

      • server

      • name

      • service

      • backup

        一个布尔值,指示服务器是否为备份服务器。

      • weight

        服务器的权重。

      • state

        当前状态,可以是 up、draining、down、unavail、checking 或 unhealthy 之一。

      • active

        当前活动连接数。

      • max_conns

      • requests

        转发到此服务器的客户端请求总数。

      • responses

        • total

          从此服务器获取的响应总数。

        • 1xx, 2xx, 3xx, 4xx, 5xx

          状态代码为 1xx、2xx、3xx、4xx 和 5xx 的响应数。

      • sent

        发送到此服务器的总字节数。

      • received

        从此服务器接收的总字节数。

      • fails

        与服务器通信失败的总次数。

      • unavail

      • health_checks

        • checks

        • fails

          健康检查失败的次数。

        • unhealthy

          服务器变为不健康的次数(状态 unhealthy)。

        • last_passed

      • downtime

        服务器处于 unavail、checking 和 unhealthy 状态的总时间。

      • downstart

        服务器变为 unavail、checking 或 unhealthy 时的时间(自 Epoch 以来的毫秒数)。

      • selected

        上次选择的服务器处理一个请求的时间(自 Epoch 以来的毫秒数)(1.7.5)。

      • header_time

      • response_time

    • keepalive

    • zombies

      当前从组中删除但仍处理活动客户端请求的服务器数。

    • zone

    • queue

      • size

        队列中当前的请求数。

      • max_size

        可以同时在队列中的最大请求数。

      • overflows

        由于队列溢出而拒绝的请求总数。

  • caches

    • size

      当前缓存的大小。

    • max_size

      配置中指定的缓存最大大小限制。

    • cold

      一个布尔值,标识缓存加载器(cache loade)进程是否仍在将数据从磁盘加载到缓存中。

    • hit, stale, updating, revalidated

      • responses

      • bytes

        从缓存中读取的总字节数。

    • miss, expired, bypass

      • responses

      • bytes

        从代理服务器读取的总字节数。

      • responses_written

        写入缓存的响应总数。

      • bytes_written

        写入缓存的总字节数。

  • stream

    • server_zones

      • processing

        当前正在处理的客户端连接数。

      • connections

        从客户端接受的连接总数。

      • sessions

        • total

          已完成的客户会话总数。

        • 2xx, 4xx, 5xx

          已完成的会话数,状态代码为 2xx、4xx 或 5xx。

      • discarded

        在不创建会话的情况下完成的连接总数。

      • received

        从客户端收到的总字节数。

      • sent

        发送给客户端的总字节数。

    • upstreams

      • peers

        • id

          服务器的 ID。

        • server

        • name

        • service

        • backup

        • weight

        • state

          当前状态,可以是 up、down、unavail、checking 或 unhealthy 之一。

        • active

          当前的连接数。

        • max_conns

        • connections

          转发到此服务器的客户端连接总数。

        • connect_time

        • first_byte_time

        • response_time

        • sent

          发送到此服务器的总字节数。

        • received

          从此服务器接收的总字节数。

        • fails

          与服务器通信失败的总次数。

        • unavail

        • health_checks

          • checks

          • fails

            健康检查失败的次数。

          • unhealthy

            服务器处于不健康的次数(状态 unhealthy)。

          • last_passed

        • downtime

          服务器处于 unavail、checking 和 unhealthy 状态的总时间。

        • downstart

          服务器变为 unavail、checking 或 unhealthy 时的时间(自 Epoch 以来的毫秒数)。

        • selected

          上次选中的服务器处理连接的时间(自 Epoch 以来的毫秒数)。

      • zombies

        当前已从组中删除但仍处理活动客户端连接的服务器数。

      • zone

兼容性

原文档

可以从包含有指令的 location 访问状态信息。应访问此 location。

允许在指定的 zone 中收集虚拟 或(1.7.11)服务器状态信息。多个服务器可能共享同一个区域(zone)。

配置的总数。

启动 的主进程的 ID。

对于每个 :

对于每个,提供以下数据:

对于每个 ,提供以下数据:

一个服务器。

指令中指定的服务器的名称。

指令的服务参数值。

服务器的 限制。

由于尝试不成功的次数达到 阈值,服务器对客户端请求变为不可用的次数(状态为 unavail)。

进行的请求总数。

布尔值,表示上次运行状况检查请求是否成功并通过了。

从服务器获取的平均时间(1.7.10)。在 1.11.6 版之前,该字段仅在使用 负载均衡方法时可用。

从服务器获得的平均时间(1.7.10)。在 1.11.6 版之前,该字段仅在使用 负载均衡方法时可用。

当前空闲的 连接数。

保持组配置和运行时状态的共享内存的名称。

对于请求,提供以下数据:

对于每个缓存(由 等配置):

从缓存中读取的响应总次数(由于 等而导致的命中或过时响应)。

未从缓存中获取的响应总数(由于 等原因导致的未命中、过期或绕过)。

对于每个 :

对于每个,提供以下数据:

对于每个,提供以下数据:

一个服务器。

指令中指定的服务器的名称。

指令的 参数值。

一个布尔值,标识服务器是否为一个服务器。

服务器的。

服务器的 限制。

连接上游(upstream)服务器的平均时间。在 1.11.6 版之前,该字段仅在使用 负载均衡方法时可用。

接收第一个数据字节的平均时间。在 1.11.6 版之前,该字段仅在使用 负载均衡时可用。

接收最后一个数据字节的平均时间。在 1.11.6 版之前,该字段仅在使用 负载均衡方法时可用。

由于尝试不成功次数达到 阈值,服务器对客户端连接变为不可用的次数(状态为 unavail)

的请求总数。

布尔值,表示上次运行状况检查请求是否成功并通过了。

保持组配置和运行时状态的共享内存的名称。

8 中添加了 和 upstreams 的 字段。

8 中添加了 状态数据。

8 中添加了状态。

8 中添加了 和 upstream 的 和 字段。

8 中添加了 和 字段。

7 中添加了 状态数据和流 中的 字段。

字段是从 6 的 nginx 版本移过来的。

6 中添加了 状态数据。

中的 字段已在 6 中添加。

状态数据已在 6 中添加。

字段已在 6 中添加。

中的服务器列表已移至 6 中的对应项。

在 5 中删除了 upstream 服务器的 keepalive 字段。

状态数据已在 5 中添加。

5 中添加了 字段。

中的 字段已在 5 中添加。

5 中添加了 upstreams 中的 和 字段。

4 中添加了 upstreams 中的 字段。

4 中添加了upstreams 的 状态。

upstreams 中的 和 字段已在 3 中添加。

3 中添加了 中的 revalidated 字段。

2 中添加了 、 和 状态数据。

健康检查
测试
http://nginx.org/en/docs/http/ngx_http_status_module.html
ngx_http_api_module
商业订阅
示例配置
指令
status
status_format
status_zone
数据
兼容性
worker 进程
status_zone
status_zone
版本
http
stream
zone
版本
slab
版本
检查
版本
http
stream
name
service
版本
nginx_build
ppid
server_zones
版本
session
discarded
调试
zombies
版本
版本
ssl
server_zones
discarded
版本
queue
版本
pid
版本
upstreams
版本
版本
stream
版本
版本
generation
processes
respawned
版本
版本
header_time
response_time
版本
selected
版本
draining
id
max_conns
版本
版本
caches
版本
server_zones
caches
load_timestamp
流
健康检查
测试
重新加载
动态可配置组
服务器
地址
server
server
servive
备份
权重
max_conns
least_time
least_time
least_time
max_fails
区域
proxy_cache_path
proxy_cache_use_stale
proxy_cache_bypass
限制
http
动态可配置组
server
地址
server
server
max_conns
max_fails
响应头
least_time
完整响应
least_time
keepalive
区域
队列