非常教程

Nginx参考手册

ngx_http_status_module

ngx_http_status_module

  • 示例配置
  • 指令
  • 状态
  • status_format
  • status_zone
  • 数据
  • 兼容性

ngx_http_status_module模块提供对各种状态信息的访问。

该模块已被1.13.0中的ngx_http_api_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在默认配置中以“ ”形式访问。它要求位置“ /status”和“ /status.html”按上图所示进行配置。

指令

句法:

状态;

默认:

语境:

位置

状态信息将可以从周围的位置访问。访问这个位置应该是有限的。

句法:

status_format json; status_format jsonp回调;

默认:

status_format json;

语境:

http,服务器,位置

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

或者,数据可以作为JSONP输出。该callback参数指定回调函数的名称。该值可以包含变量。如果省略参数,或者计算的值是空字符串,则使用“ ngx_status_jsonp_callback”。

句法:

status_zone区域;

默认:

语境:

服务器

启用指定的虚拟http或流(1.7.11)服务器状态信息的收集zone。多台服务器可能共享同一个区域。

数据

提供以下状态信息:

version提供的数据集的版本。目前的版本是8. nginx_version版本的nginx。nginx_buildnginx构建的名称。address接受状态请求的服务器的地址。generation配置重新加载的总数。load_timestamp上次重新加载配置的时间,以Epoch以来的毫秒数表示。timestampEpoch以来的当前时间(以毫秒为单位)。pid处理状态请求的工作进程的ID。ppid启动辅助进程的主进程的标识。processesrespawned异常终止和重新生成的子进程的总数。connectionsaccepted接受的客户端连接的总数。dropped丢弃的客户端连接总数。active当前活动的客户端连接数。idle当前闲置的客户端连接数。sslhandshakes成功的SSL握手总数。handshakes_failed失败的SSL握手总数。session_reusesSSL握手期间会话​​重用的总次数。requeststotal客户端请求的总数。current当前的客户端请求数。server_zones对于每个status_zone:processing当前正在处理的客户端请求的数量。requests客户端收到的客户端请求总数。responsestotal发送给客户的回复总数。1xx2xx3xx4xx5xx响应状态码数1XX,2XX,3XX,4XX,5XX和。discarded没有发送回应完成的请求总数。received从客户端收到的总字节数。sent发送给客户端的总字节数。slabs对于使用slab分配器的每个共享内存区域:pagesused当前使用的内存页数。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服务器的max_conns限制。requests转发到此服务器的客户端请求总数。responsestotal从此服务器获得的响应总数。1xx2xx3xx4xx5xx状态代码为1xx,2xx,3xx,4xx和5xx的响应数量。sent发送到此服务器的总字节数。received从此服务器收到的总字节数。fails尝试与服务器通信失败的总次数。由于达到max_fails阈值的失败尝试unavail次数,服务器无法用于客户端请求(状态“ unavail”)的次数。health_checkschecks健康检查请求的总数。fails健康检查失败的次数。unhealthy服务器变得不健康多少次(状态“ unhealthy”)。last_passed布尔值,指示最后的运行状况检查请求是否成功并通过了测试。downtime服务器在“ unavail”,“ checking”和“unhealthy“ 状态。downstart服务器变为“ unavail”,“ checking”或“ unhealthy” 的时间(自Epoch以来以毫秒为单位)。selected上一次选择服务器处理请求(1.7.5)时的时间(从Epoch开始,以毫秒为单位)。header_time从服务器获取响应标头的平均时间(1.7.10)。在版本1.11.6之前,该字段仅在使用least_time负载平衡方法时可用。response_time从服务器获得完整响应的平均时间(1.7.10)。在版本1.11.6之前,该字段仅在使用least_time负载平衡方法时可用。keepalive当前空闲保持连接的数量。zombies当前从组中删除的服务器数量,但仍处理活动的客户端请求。zone保持组的配置和运行时状态的共享内存区域的名称。queue对于请求队列,提供以下数据:size队列中当前的请求数。max_size同时可以在队列中请求的最大数量。overflows由于队列溢出而被拒绝的请求总数。caches对于每个缓存(由proxy_cache_path等配置):size缓存的当前大小。max_size配置中指定的缓存的最大大小限制。cold指示“缓存加载器”进程是否仍在将数据从磁盘加载到缓存中的布尔值。hitstaleupdatingrevalidatedresponses从缓存中读取的响应的总数(命中或由于proxy_cache_use_stale等引起的陈旧响应)。bytes从缓存中读取的总字节数。missexpiredbypassresponses的响应的总数不从缓存(未命中,期满,或绕过由于proxy_cache_bypass和喜欢)。bytes从代理服务器读取的总字节数。responses_written写入缓存的响应总数。bytes_written写入缓存的总字节数。streamserver_zones对于每个status_zone:processing当前正在处理的客户端连接数。connections客户端接受的连接总数。sessionstotal完成的客户端会话总数。2xx4xx5xx用状态代码2xx,4xx或5xx完成的会话数量。discarded完成连接的总数而不创建会话。received从客户端收到的总字节数。sent发送给客户端的总字节数。upstreams对于每个动态可配置组,提供以下数据:peers为每个服务器提供以下数据:服务器的idID。server服务器的地址。name服务器指令中指定的服务器的名称。service服务器指令的服务参数值。backup指示服务器是否为备份服务器的布尔值。weight服务器的重量。state当前状态,可能是“ up”,“ down”,“unavail“,” checking“或” unhealthy“。active当前的连接数。max_conns服务器的max_conns限制。connections转发到此服务器的客户端连接总数。connect_time连接到上游服务器的平均时间。在版本1.11.6之前,该字段仅在使用least_time负载平衡方法时可用。first_byte_time接收第一个字节数据的平均时间。在版本1.11.6之前,该字段仅在使用least_time负载平衡方法时可用。response_time接收最后一个字节数据的平均时间。在版本1.11.6之前,该字段仅在使用least_time负载平衡方法时可用。sent发送到此服务器的总字节数。received从此服务器收到的总字节数。fails尝试与服务器通信失败的总次数。由于达到max_fails阈值的失败尝试unavail次数,服务器无法用于客户端连接(状态“ unavail”)多少次。health_checkschecks健康检查请求的总数。fails健康检查失败的次数。unhealthy服务器变得不健康多少次(状态“ unhealthy”)。last_passed布尔值,指示最后的运行状况检查请求是否成功并通过了测试。downtime服务器处于“ unavail”,“ checking”和“ unhealthy”状态的总时间。downstart当服务器成为“ unavail”,“ checking”或“”时,时间(从Epoch开始以毫秒为单位)unhealthy”。selected上次选择服务器处理连接时的时间(自Epoch起,以毫秒为单位)。zombies当前从组中删除的服务器数量,但仍处理活动客户端连接。zone保持组的配置和运行时状态的共享内存区域的名称。

兼容性

  • 版本8中添加了http和stream上游中的区域字段。
  • 版本8中添加了板坯状态数据。
  • 版本8中添加了状态的检查。
  • 在版本8中添加了http和stream上游中的名称和服务字段。
  • 版本8中添加了nginx_build和ppid字段。
  • 在版本7中添加了会话状态数据和流server_zones中的丢弃字段。
  • zombies字段已从版本6中的nginx调试版本中移出。
  • ssl状态数据是在版本6中添加的。
  • 在版本6中添加了server_zones中的丢弃字段。
  • 在版本6中添加了队列状态数据。
  • 在版本6中添加了pid字段。
  • 在版本6中上游的服务器列表被移入同行。
  • 版本5中移除了上游服务器的Keepalive字段。
  • 在版本5中添加了流状态数据。
  • 在版本5中添加了生成字段。
  • 版本5中增加了进程中重新生成的字段。
  • 在版本5中添加了上游中的header_time和response_time字段。
  • 在版本4中添加了上游中的选定字段。
  • 在版本4中增加了上游的排水状态。
  • 在版本3中添加了上游中的id和max_conns字段。
  • 在版本3中添加了revalidated缓存中的字段。
  • 在版本2中添加了server_zones,caches和load_timestamp状态数据。
ngx_http_status_module
Nginx

Nginx是一款轻量级的 Web 服务器/反向代理服务器及电子邮件代理服务器,可在 BSD-like 协议下发行。其特点是占有内存少,并发能力强。

主页 https://nginx.org/
源码 http://hg.nginx.org/nginx
发布版本 1.13.6

Nginx目录

1.指南 | Guides
2.核心 | Core
3.ngx_google_perftools_module
4.ngx_http_access_module
5.ngx_http_addition_module
6.ngx_http_api_module
7.ngx_http_auth_basic_module
8.ngx_http_auth_jwt_module
9.ngx_http_auth_request_module
10.ngx_http_autoindex_module
11.ngx_http_browser_module
12.ngx_http_charset_module
13.ngx_http_core_module
14.ngx_http_dav_module
15.ngx_http_empty_gif_module
16.ngx_http_f4f_module
17.ngx_http_fastcgi_module
18.ngx_http_flv_module
19.ngx_http_geoip_module
20.ngx_http_geo_module
21.ngx_http_gunzip_module
22.ngx_http_gzip_module
23.ngx_http_gzip_static_module
24.ngx_http_headers_module
25.ngx_http_hls_module
26.ngx_http_image_filter_module
27.ngx_http_index_module
28.ngx_http_js_module
29.ngx_http_keyval_module
30.ngx_http_limit_conn_module
31.ngx_http_limit_req_module
32.ngx_http_log_module
33.ngx_http_map_module
34.ngx_http_memcached_module
35.ngx_http_mirror_module
36.ngx_http_mp4_module
37.ngx_http_perl_module
38.ngx_http_proxy_module
39.ngx_http_random_index_module
40.ngx_http_realip_module
41.ngx_http_referer_module
42.ngx_http_rewrite_module
43.ngx_http_scgi_module
44.ngx_http_secure_link_module
45.ngx_http_session_log_module
46.ngx_http_slice_module
47.ngx_http_spdy_module
48.ngx_http_split_clients_module
49.ngx_http_ssi_module
50.ngx_http_ssl_module
51.ngx_http_status_module
52.ngx_http_stub_status_module
53.ngx_http_sub_module
54.ngx_http_upstream_conf_module
55.ngx_http_upstream_hc_module
56.ngx_http_upstream_module
57.ngx_http_userid_module
58.ngx_http_uwsgi_module
59.ngx_http_v2_module
60.ngx_http_xslt_module
61.ngx_mail_auth_http_module
62.ngx_mail_core_module
63.ngx_mail_imap_module
64.ngx_mail_pop3_module
65.ngx_mail_proxy_module
66.ngx_mail_smtp_module
67.ngx_mail_ssl_module
68.ngx_stream_access_module
69.ngx_stream_core_module
70.ngx_stream_geoip_module
71.ngx_stream_geo_module
72.ngx_stream_js_module
73.ngx_stream_limit_conn_module
74.ngx_stream_log_module
75.ngx_stream_map_module
76.ngx_stream_proxy_module
77.ngx_stream_realip_module
78.ngx_stream_return_module
79.ngx_stream_split_clients_module
80.ngx_stream_ssl_module
81.ngx_stream_ssl_preread_module
82.ngx_stream_upstream_hc_module
83.ngx_stream_upstream_module