ngx_http_api_module 模块
ngx_http_api_module
模块 (1.13.3) 提供了 REST API,用于访问各种状态信息、动态配置上游服务器组以及管理键值对,而无需重新配置 nginx。
该模块取代了 ngx_http_status_module 和 ngx_http_upstream_conf_module 模块。
使用 PATCH
或 POST
方法时,请确保负载不超过用于读取客户端请求体的缓冲区大小,否则可能会返回 413 (Request Entity Too Large) 错误。
该模块作为我们的商业订阅的一部分提供。
配置示例
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; } keyval_zone zone=one:32k state=one.keyval; keyval $arg_text $text zone=one; server { listen 127.0.0.1; location /api { api write=on; allow 127.0.0.1; deny all; } } } 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; } }
所有 API 请求都在 URI 中包含支持的 API 版本。使用此配置的 API 请求示例
http://127.0.0.1/api/9/ http://127.0.0.1/api/9/nginx http://127.0.0.1/api/9/connections http://127.0.0.1/api/9/workers http://127.0.0.1/api/9/http/requests http://127.0.0.1/api/9/http/server_zones/server_backend http://127.0.0.1/api/9/http/caches/cache_backend http://127.0.0.1/api/9/http/upstreams/backend http://127.0.0.1/api/9/http/upstreams/backend/servers/ http://127.0.0.1/api/9/http/upstreams/backend/servers/1 http://127.0.0.1/api/9/http/keyvals/one?key=arg1 http://127.0.0.1/api/9/stream/ http://127.0.0.1/api/9/stream/server_zones/server_backend http://127.0.0.1/api/9/stream/upstreams/ http://127.0.0.1/api/9/stream/upstreams/backend http://127.0.0.1/api/9/stream/upstreams/backend/servers/1
指令
语法 |
api [ |
---|---|
默认值 | — |
上下文 |
location |
在所在的 location 中开启 REST API 接口。对此 location 的访问应该受到限制。
write
参数决定 API 是只读还是读写。默认情况下,API 是只读的。
所有 API 请求都应该在 URI 中包含支持的 API 版本。如果请求 URI 等于 location 前缀,则返回支持的 API 版本列表。当前 API 版本是“9
”。
请求行中可选的“fields
”参数指定将输出哪些被请求对象的字段
http://127.0.0.1/api/9/nginx?fields=version,build
语法 |
status_zone |
---|---|
默认值 | — |
上下文 |
server , location , if in location |
该指令出现在版本 1.13.12 中。
在指定的 zone
中启用收集虚拟 http 或 stream 服务器的状态信息。多个服务器可以共享同一个区域。
从 1.17.0 版本开始,状态信息可以按 location 收集。特殊值 off
会禁用嵌套 location 块中的统计信息收集。请注意,统计信息是在处理结束的 location 上下文中收集的。如果在请求处理期间发生内部重定向,它可能与原始 location 不同。
兼容性
- /license 数据在 版本 9 (1.27.2) 中添加。
- /workers/ 数据在 版本 9 中添加。
- SSL 统计信息中添加了详细的失败计数器,在 版本 8 (1.23.2) 中。
- 每个 HTTP 上游、服务器区域以及 stream 上游、服务器区域的
ssl
数据在 版本 8 (1.21.6) 中添加。 - 每个 HTTP 上游、服务器区域以及 location 区域的
responses
中的codes
数据在 版本 7 中添加。 - /stream/limit_conns/ 数据在 版本 6 中添加。
- /http/limit_conns/ 数据在 版本 6 中添加。
- /http/limit_reqs/ 数据在 版本 6 中添加。
- 键值对的“
expire
”参数从 版本 5 开始可以设置或更改。 - /resolvers/ 数据在 版本 5 中添加。
- /http/location_zones/ 数据在 版本 5 中添加。
- nginx 错误对象的
path
和method
字段在 版本 4 中被移除。这些字段在早期 api 版本中继续存在,但显示空值。 - /stream/zone_sync/ 数据在 版本 3 中添加。
- drain 参数在 版本 2 中添加。
- /stream/keyvals/ 数据在 版本 2 中添加。
端点
-
/
-
支持的方法
-
GET
- 返回根端点列表返回根端点列表。
可能的响应
- 200 - 成功,返回字符串数组
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/nginx
-
支持的方法
-
/processes
-
支持的方法
-
/connections
-
支持的方法
-
/slabs/
-
支持的方法
-
GET
- 返回所有 Slab 的状态返回每个使用 Slab 分配器的共享内存区域的 Slab 状态。
请求参数
fields
(string
, 可选)- 限制输出 Slab 区域的哪些字段。如果“
fields
”值为空,则只输出区域名称。
可能的响应
- 200 - 成功,返回所有 Slab 的“使用 Slab 分配器的共享内存区域”对象集合
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/slabs/{slabZoneName}
- 所有方法共有的参数
slabZoneName
(string
, 必需)- 使用 Slab 分配器的共享内存区域的名称。
支持的方法
-
GET
- 返回某个 Slab 的状态返回特定使用 Slab 分配器的共享内存区域的 Slab 状态。
请求参数
fields
(string
, 可选)- 限制输出该 Slab 区域的哪些字段。
可能的响应
- 200 - 成功,返回 使用 Slab 分配器的共享内存区域
- 404 - 未找到 Slab (
SlabNotFound
),未知版本 (UnknownVersion
),返回 错误
-
DELETE
- 重置 Slab 统计信息重置每个内存槽的“
reqs
”和“fails
”指标。可能的响应
-
/http/
-
支持的方法
-
GET
- 返回与 HTTP 相关的端点列表返回第一级 HTTP 端点列表。
可能的响应
- 200 - 成功,返回字符串数组
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/http/requests
-
支持的方法
-
/http/server_zones/
-
支持的方法
-
GET
- 返回所有 HTTP 服务器区域的状态返回每个 HTTP 服务器区域的状态信息。
请求参数
fields
(string
, 可选)- 限制输出服务器区域的哪些字段。如果“
fields
”值为空,则只输出服务器区域名称。
可能的响应
- 200 - 成功,返回所有 HTTP 服务器区域的“HTTP 服务器区域”对象集合
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/http/server_zones/{httpServerZoneName}
- 所有方法共有的参数
httpServerZoneName
(string
, 必需)- HTTP 服务器区域的名称。
支持的方法
-
GET
- 返回某个 HTTP 服务器区域的状态返回特定 HTTP 服务器区域的状态。
请求参数
fields
(string
, 可选)- 限制输出该服务器区域的哪些字段。
可能的响应
- 200 - 成功,返回 HTTP 服务器区域
- 404 - 未找到服务器区域 (
ServerZoneNotFound
),未知版本 (UnknownVersion
),返回 错误
-
DELETE
- 重置某个 HTTP 服务器区域的统计信息重置特定 HTTP 服务器区域中已接受和已丢弃请求、响应、接收和发送字节、SSL 握手次数和会话重用次数的统计信息。
可能的响应
-
/http/location_zones/
-
支持的方法
-
GET
- 返回所有 HTTP location 区域的状态返回每个 HTTP location 区域的状态信息。
请求参数
fields
(string
, 可选)- 限制输出 location 区域的哪些字段。如果“
fields
”值为空,则只输出区域名称。
可能的响应
- 200 - 成功,返回所有 HTTP location 区域的“HTTP Location 区域”对象集合
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/http/location_zones/{httpLocationZoneName}
- 所有方法共有的参数
httpLocationZoneName
(string
, 必需)- HTTP location 区域的名称。
支持的方法
-
GET
- 返回某个 HTTP location 区域的状态返回特定 HTTP location 区域的状态。
请求参数
fields
(string
, 可选)- 限制输出该 location 区域的哪些字段。
可能的响应
- 200 - 成功,返回 HTTP Location 区域
- 404 - 未找到 location 区域 (
LocationZoneNotFound
),未知版本 (UnknownVersion
),返回 错误
-
DELETE
- 重置某个 location 区域的统计信息。重置特定 location 区域中已接受和已丢弃请求、响应、接收和发送字节的统计信息。
可能的响应
-
/http/caches/
-
支持的方法
-
GET
- 返回所有缓存的状态返回由 proxy_cache_path 和其他“
*_cache_path
”指令配置的每个缓存的状态。请求参数
fields
(string
, 可选)- 限制输出缓存区域的哪些字段。如果“
fields
”值为空,则只输出缓存区域名称。
可能的响应
-
-
/http/caches/{httpCacheZoneName}
- 所有方法共有的参数
httpCacheZoneName
(string
, 必需)- 缓存区域的名称。
支持的方法
-
/http/limit_conns/
-
支持的方法
-
GET
- 返回所有 HTTP limit_conn 区域的状态返回每个 HTTP limit_conn 区域的状态信息。
请求参数
fields
(string
, 可选)- 限制输出 limit_conn 区域的哪些字段。如果“
fields
”值为空,则只输出区域名称。
可能的响应
-
-
/http/limit_conns/{httpLimitConnZoneName}
- 所有方法共有的参数
httpLimitConnZoneName
(string
, 必需)- limit_conn 区域的名称。
支持的方法
-
GET
- 返回某个 HTTP limit_conn 区域的状态返回特定 HTTP limit_conn 区域的状态。
请求参数
fields
(string
, 可选)- 限制输出该 limit_conn 区域的哪些字段。
可能的响应
-
DELETE
- 重置某个 HTTP limit_conn 区域的统计信息重置连接限制统计信息。
可能的响应
-
/http/limit_reqs/
-
支持的方法
-
GET
- 返回所有 HTTP limit_req 区域的状态返回每个 HTTP limit_req 区域的状态信息。
请求参数
fields
(string
, 可选)- 限制输出 limit_req 区域的哪些字段。如果“
fields
”值为空,则只输出区域名称。
可能的响应
- 200 - 成功,返回所有 HTTP limit_req 的“HTTP 请求速率限制”对象集合
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/http/limit_reqs/{httpLimitReqZoneName}
- 所有方法共有的参数
httpLimitReqZoneName
(string
, 必需)- limit_req 区域的名称。
支持的方法
-
GET
- 返回某个 HTTP limit_req 区域的状态返回特定 HTTP limit_req 区域的状态。
请求参数
fields
(string
, 可选)- 限制输出该 limit_req 区域的哪些字段。
可能的响应
- 200 - 成功,返回 HTTP 请求速率限制
- 404 - 未找到 limit_req (
LimitReqNotFound
),未知版本 (UnknownVersion
),返回 错误
-
DELETE
- 重置某个 HTTP limit_req 区域的统计信息重置请求限制统计信息。
可能的响应
-
/http/upstreams/
-
支持的方法
-
/http/upstreams/{httpUpstreamName}/
- 所有方法共有的参数
httpUpstreamName
(string
, 必需)- HTTP 上游服务器组的名称。
支持的方法
-
GET
- 返回某个 HTTP 上游服务器组的状态返回特定 HTTP 上游服务器组及其服务器的状态。
请求参数
fields
(string
, 可选)- 限制输出该上游服务器组的哪些字段。
可能的响应
-
DELETE
- 重置某个 HTTP 上游服务器组的统计信息重置上游服务器组中每个上游服务器的统计信息和队列统计信息。
可能的响应
-
/http/upstreams/{httpUpstreamName}/servers/
- 所有方法共有的参数
httpUpstreamName
(string
, 必需)- 上游服务器组的名称。
支持的方法
-
GET
- 返回某个 HTTP 上游服务器组中所有服务器的配置返回特定 HTTP 上游服务器组中每个服务器的配置。
可能的响应
- 200 - 成功,返回 HTTP 上游服务器数组
- 400 - 上游是静态的 (
UpstreamStatic
),返回 错误 - 404 - 未知版本 (
UnknownVersion
),未找到上游 (UpstreamNotFound
),返回 错误
-
POST
- 向某个 HTTP 上游服务器组添加一个服务器向 HTTP 上游服务器组添加一个新服务器。服务器参数以 JSON 格式指定。
请求参数
postHttpUpstreamServer
(HTTP 上游服务器, 必需)- 新服务器的地址和其他可选参数,以 JSON 格式指定。“
ID
”、“backup
”和“service
”参数不能更改。
可能的响应
- 201 - 已创建,返回 HTTP 上游服务器
- 400 - 上游是静态的 (
UpstreamStatic
),“parameter
”值无效 (UpstreamConfFormatError
),缺少“server
”参数 (UpstreamConfFormatError
),未知参数“name
” (UpstreamConfFormatError
),嵌套对象或列表 (UpstreamConfFormatError
),解析时出错“error
” (UpstreamBadAddress
),服务上游“host
”可能没有端口 (UpstreamBadAddress
),服务上游“host
”需要域名 (UpstreamBadAddress
),“weight
”无效 (UpstreamBadWeight
),“max_conns
”无效 (UpstreamBadMaxConns
),“max_fails
”无效 (UpstreamBadMaxFails
),“fail_timeout
”无效 (UpstreamBadFailTimeout
),“slow_start
”无效 (UpstreamBadSlowStart
),读取请求体失败BodyReadError
),路由过长 (UpstreamBadRoute
),“service
”为空 (UpstreamBadService
),未定义解析器进行解析 (UpstreamConfNoResolver
),上游“name
”没有备份 (UpstreamNoBackup
),上游“name
”内存不足 (UpstreamOutOfMemory
),返回 错误 - 404 - 未知版本 (
UnknownVersion
),未找到上游 (UpstreamNotFound
),返回 错误 - 405 - 方法禁用 (
MethodDisabled
),返回 错误 - 409 - 条目已存在 (
EntryExists
),返回 错误 - 415 - JSON 错误 (
JsonError
),返回 错误
-
/http/upstreams/{httpUpstreamName}/servers/{httpUpstreamServerId}
- 所有方法共有的参数
httpUpstreamName
(string
, 必需)- 上游服务器组的名称。
httpUpstreamServerId
(string
, 必需)- 服务器的 ID。
支持的方法
-
GET
- 返回某个 HTTP 上游服务器组中某个服务器的配置返回 HTTP 上游服务器组中特定服务器的配置。
可能的响应
- 200 - 成功,返回 HTTP 上游服务器
- 400 - 上游是静态的 (
UpstreamStatic
),服务器 ID 无效 (UpstreamBadServerId
),返回 错误 - 404 - ID 为“
id
”的服务器不存在 (UpstreamServerNotFound
),未知版本 (UnknownVersion
),未找到上游 (UpstreamNotFound
),返回 错误
-
PATCH
- 修改某个 HTTP 上游服务器组中的服务器修改 HTTP 上游服务器组中特定服务器的设置。服务器参数以 JSON 格式指定。
请求参数
patchHttpUpstreamServer
(HTTP 上游服务器, 必需)- 服务器参数,以 JSON 格式指定。“
ID
”、“backup
”和“service
”参数不能更改。
可能的响应
- 200 - 成功,返回 HTTP 上游服务器
- 400 - 上游是静态的 (
UpstreamStatic
),“parameter
”值无效 (UpstreamConfFormatError
),未知参数“name
” (UpstreamConfFormatError
),嵌套对象或列表 (UpstreamConfFormatError
),解析时出错“error
” (UpstreamBadAddress
),“server
”参数无效 (UpstreamBadAddress
),服务器 ID 无效 (UpstreamBadServerId
),“weight
”无效 (UpstreamBadWeight
),“max_conns
”无效 (UpstreamBadMaxConns
),“max_fails
”无效 (UpstreamBadMaxFails
),“fail_timeout
”无效 (UpstreamBadFailTimeout
),“slow_start
”无效 (UpstreamBadSlowStart
),读取请求体失败BodyReadError
),路由过长 (UpstreamBadRoute
),“service
”为空 (UpstreamBadService
),服务器“ID
”地址不可变 (UpstreamServerImmutable
),服务器“ID
”权重不可变 (UpstreamServerWeightImmutable
),上游“name
”内存不足 (UpstreamOutOfMemory
),返回 错误 - 404 - ID 为“
id
”的服务器不存在 (UpstreamServerNotFound
),未知版本 (UnknownVersion
),未找到上游 (UpstreamNotFound
),返回 错误 - 405 - 方法禁用 (
MethodDisabled
),返回 错误 - 415 - JSON 错误 (
JsonError
),返回 错误
-
DELETE
- 从某个 HTTP 上游服务器组中移除服务器从 HTTP 上游服务器组中移除服务器。
可能的响应
- 200 - 成功,返回 HTTP 上游服务器数组
- 400 - 上游是静态的 (
UpstreamStatic
),服务器 ID 无效 (UpstreamBadServerId
),服务器“id
”不可移除 (UpstreamServerImmutable
),返回 错误 - 404 - ID 为“
id
”的服务器不存在 (UpstreamServerNotFound
),未知版本 (UnknownVersion
),未找到上游 (UpstreamNotFound
),返回 错误 - 405 - 方法禁用 (
MethodDisabled
),返回 错误
-
/http/keyvals/
-
支持的方法
-
GET
- 从所有 HTTP keyval 区域返回键值对返回每个 HTTP keyval 共享内存区域的键值对。
请求参数
fields
(string
, 可选)- 如果“
fields
”值为空,则只输出 HTTP keyval 区域名称。
可能的响应
- 200 - 成功,返回所有 HTTP keyval 的“HTTP Keyval 共享内存区域”对象集合
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/http/keyvals/{httpKeyvalZoneName}
- 所有方法共有的参数
httpKeyvalZoneName
(string
, 必需)- HTTP keyval 共享内存区域的名称。
支持的方法
-
GET
- 从某个 HTTP keyval 区域返回键值对返回特定 HTTP keyval 共享内存区域中存储的键值对。
请求参数
key
(string
, 可选)- 从 HTTP keyval 区域获取特定的键值对。
可能的响应
- 200 - 成功,返回 HTTP Keyval 共享内存区域
- 404 - 未找到 Keyval (
KeyvalNotFound
),未找到 Keyval 键 (KeyvalKeyNotFound
),未知版本 (UnknownVersion
),返回 错误
-
POST
- 向 HTTP keyval 区域添加一个键值对向 HTTP keyval 共享内存区域添加一个新的键值对。如果 HTTP keyval 共享内存区域为空,可以输入多个键值对。
请求参数
Key-value
(HTTP Keyval 共享内存区域, 必需)- 键值对以 JSON 格式指定。如果 HTTP keyval 共享内存区域为空,可以输入多个键值对。可以使用
expire
参数指定键值对的过期时间(以毫秒为单位),这会覆盖timeout
参数的 keyval_zone 指令。
可能的响应
- 201 - 已创建
- 400 - JSON 无效 (
KeyvalFormatError
),键格式无效 (KeyvalFormatError
),需要键 (KeyvalFormatError
),keyval timeout 未启用 (KeyvalFormatError
),只能添加一个键 (KeyvalFormatError
),读取请求体失败BodyReadError
),返回 错误 - 404 - 未找到 Keyval (
KeyvalNotFound
),未知版本 (UnknownVersion
),返回 错误 - 405 - 方法禁用 (
MethodDisabled
),返回 错误 - 409 - 条目已存在 (
EntryExists
),键已存在 (KeyvalKeyExists
),返回 错误 - 413 - 请求实体过大 (Request Entity Too Large),返回 错误
- 415 - JSON 错误 (
JsonError
),返回 错误
-
PATCH
- 修改键值对或删除键更改键值对中选中键的值,通过将键值设置为
null
来删除键,更改键值对的过期时间。如果在集群中启用了 keyval 区域的同步,则仅在目标集群节点上删除键。可以使用expire
参数指定键值对的过期时间(以毫秒为单位),这会覆盖timeout
参数的 keyval_zone 指令。请求参数
httpKeyvalZoneKeyValue
(HTTP Keyval 共享内存区域, 必需)- 键的新值以 JSON 格式指定。
可能的响应
- 204 - 成功
- 400 - JSON 无效 (
KeyvalFormatError
),需要键 (KeyvalFormatError
),keyval timeout 未启用 (KeyvalFormatError
),只能更新一个键 (KeyvalFormatError
),读取请求体失败BodyReadError
),返回 错误 - 404 - 未找到 Keyval (
KeyvalNotFound
),未找到 Keyval 键 (KeyvalKeyNotFound
),未知版本 (UnknownVersion
),返回 错误 - 405 - 方法禁用 (
MethodDisabled
),返回 错误 - 413 - 请求实体过大 (Request Entity Too Large),返回 错误
- 415 - JSON 错误 (
JsonError
),返回 错误
-
DELETE
- 清空 HTTP keyval 区域从 HTTP keyval 共享内存区域中删除所有键值对。如果在集群中启用了 keyval 区域的同步,则仅在目标集群节点上清空 keyval 区域。
可能的响应
-
/stream/
-
支持的方法
-
GET
- 返回与 stream 相关的端点列表返回第一级 stream 端点列表。
可能的响应
- 200 - 成功,返回字符串数组
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/stream/server_zones/
-
支持的方法
-
GET
- 返回所有 stream 服务器区域的状态返回每个 stream 服务器区域的状态信息。
请求参数
fields
(string
, 可选)- 限制输出服务器区域的哪些字段。如果“
fields
”值为空,则只输出服务器区域名称。
可能的响应
- 200 - 成功,返回所有 stream 服务器区域的“Stream 服务器区域”对象集合
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/stream/server_zones/{streamServerZoneName}
- 所有方法共有的参数
streamServerZoneName
(string
, 必需)- stream 服务器区域的名称。
支持的方法
-
GET
- 返回某个 stream 服务器区域的状态返回特定 stream 服务器区域的状态。
请求参数
fields
(string
, 可选)- 限制输出该服务器区域的哪些字段。
可能的响应
- 200 - 成功,返回 Stream 服务器区域
- 404 - 未找到服务器区域 (
ServerZoneNotFound
),未知版本 (UnknownVersion
),返回 错误
-
DELETE
- 重置某个 stream 服务器区域的统计信息重置特定 stream 服务器区域中已接受和已丢弃连接、会话、接收和发送字节、SSL 握手次数和会话重用次数的统计信息。
可能的响应
-
/stream/limit_conns/
-
支持的方法
-
GET
- 返回所有 stream limit_conn 区域的状态返回每个 stream limit_conn 区域的状态信息。
请求参数
fields
(string
, 可选)- 限制输出 limit_conn 区域的哪些字段。如果“
fields
”值为空,则只输出区域名称。
可能的响应
- 200 - 成功,返回所有 stream limit_conn 的“Stream 连接限制”对象集合
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/stream/limit_conns/{streamLimitConnZoneName}
- 所有方法共有的参数
streamLimitConnZoneName
(string
, 必需)- limit_conn 区域的名称。
支持的方法
-
GET
- 返回某个 stream limit_conn 区域的状态返回特定 stream limit_conn 区域的状态。
请求参数
fields
(string
, 可选)- 限制输出该 limit_conn 区域的哪些字段。
可能的响应
- 200 - 成功,返回 Stream 连接限制
- 404 - 未找到 limit_conn (
LimitConnNotFound
),未知版本 (UnknownVersion
),返回 错误
-
DELETE
- 重置某个 stream limit_conn 区域的统计信息重置连接限制统计信息。
可能的响应
-
/stream/upstreams/
-
支持的方法
-
/stream/upstreams/{streamUpstreamName}/
- 所有方法共有的参数
streamUpstreamName
(string
, 必需)- stream 上游服务器组的名称。
支持的方法
-
GET
- 返回某个 stream 上游服务器组的状态返回特定 stream 上游服务器组及其服务器的状态。
请求参数
fields
(string
, 可选)- 限制输出该上游服务器组的哪些字段。
可能的响应
-
DELETE
- 重置某个 stream 上游服务器组的统计信息重置上游服务器组中每个上游服务器的统计信息。
可能的响应
-
/stream/upstreams/{streamUpstreamName}/servers/
- 所有方法共有的参数
streamUpstreamName
(string
, 必需)- 上游服务器组的名称。
支持的方法
-
GET
- 返回某个 stream 上游服务器组中所有服务器的配置返回特定 stream 上游服务器组中每个服务器的配置。
可能的响应
- 200 - 成功,返回 Stream 上游服务器数组
- 400 - 上游是静态的 (
UpstreamStatic
),返回 错误 - 404 - 未知版本 (
UnknownVersion
),未找到上游 (UpstreamNotFound
),返回 错误
-
POST
- 向某个 stream 上游服务器组添加一个服务器向 stream 上游服务器组添加一个新服务器。服务器参数以 JSON 格式指定。
请求参数
postStreamUpstreamServer
(Stream 上游服务器, 必需)- 新服务器的地址和其他可选参数,以 JSON 格式指定。“
ID
”、“backup
”和“service
”参数不能更改。
可能的响应
- 201 - 已创建,返回 Stream 上游服务器
- 400 - 上游是静态的 (
UpstreamStatic
),“parameter
”值无效 (UpstreamConfFormatError
),缺少“server
”参数 (UpstreamConfFormatError
),未知参数“name
” (UpstreamConfFormatError
),嵌套对象或列表 (UpstreamConfFormatError
),解析时出错“error
” (UpstreamBadAddress
),服务器“host
”中没有端口 (UpstreamBadAddress
),服务上游“host
”可能没有端口 (UpstreamBadAddress
),服务上游“host
”需要域名 (UpstreamBadAddress
),“weight
”无效 (UpstreamBadWeight
),“max_conns
”无效 (UpstreamBadMaxConns
),“max_fails
”无效 (UpstreamBadMaxFails
),“fail_timeout
”无效 (UpstreamBadFailTimeout
),“slow_start
”无效 (UpstreamBadSlowStart
),“service
”为空 (UpstreamBadService
),未定义解析器进行解析 (UpstreamConfNoResolver
),上游“name
”没有备份 (UpstreamNoBackup
),上游“name
”内存不足 (UpstreamOutOfMemory
),读取请求体失败BodyReadError
),返回 错误 - 404 - 未知版本 (
UnknownVersion
),未找到上游 (UpstreamNotFound
),返回 错误 - 405 - 方法禁用 (
MethodDisabled
),返回 错误 - 409 - 条目已存在 (
EntryExists
),返回 错误 - 415 - JSON 错误 (
JsonError
),返回 错误
-
/stream/upstreams/{streamUpstreamName}/servers/{streamUpstreamServerId}
- 所有方法共有的参数
streamUpstreamName
(string
, 必需)- 上游服务器组的名称。
streamUpstreamServerId
(string
, 必需)- 服务器的 ID。
支持的方法
-
GET
- 返回某个 stream 上游服务器组中某个服务器的配置返回 stream 上游服务器组中特定服务器的配置。
可能的响应
- 200 - 成功,返回 Stream 上游服务器
- 400 - 上游是静态的 (
UpstreamStatic
),服务器 ID 无效 (UpstreamBadServerId
),返回 错误 - 404 - 未知版本 (
UnknownVersion
),未找到上游 (UpstreamNotFound
),ID 为“id
”的服务器不存在 (UpstreamServerNotFound
),返回 错误
-
PATCH
- 修改某个 stream 上游服务器组中的服务器修改 stream 上游服务器组中特定服务器的设置。服务器参数以 JSON 格式指定。
请求参数
patchStreamUpstreamServer
(Stream 上游服务器, 必需)- 服务器参数,以 JSON 格式指定。“
ID
”、“backup
”和“service
”参数不能更改。
可能的响应
- 200 - 成功,返回 Stream 上游服务器
- 400 - 上游是静态的 (
UpstreamStatic
),“parameter
”值无效 (UpstreamConfFormatError
),未知参数“name
” (UpstreamConfFormatError
),嵌套对象或列表 (UpstreamConfFormatError
),解析时出错“error
” (UpstreamBadAddress
),“server
”参数无效 (UpstreamBadAddress
),服务器“host
”中没有端口 (UpstreamBadAddress
),服务器 ID 无效 (UpstreamBadServerId
),“weight
”无效 (UpstreamBadWeight
),“max_conns
”无效 (UpstreamBadMaxConns
),“max_fails
”无效 (UpstreamBadMaxFails
),“fail_timeout
”无效 (UpstreamBadFailTimeout
),“slow_start
”无效 (UpstreamBadSlowStart
),读取请求体失败BodyReadError
),“service
”为空 (UpstreamBadService
),服务器“ID
”地址不可变 (UpstreamServerImmutable
),服务器“ID
”权重不可变 (UpstreamServerWeightImmutable
),上游“name
”内存不足 (UpstreamOutOfMemory
),返回 错误 - 404 - ID 为“
id
”的服务器不存在 (UpstreamServerNotFound
),未知版本 (UnknownVersion
),未找到上游 (UpstreamNotFound
),返回 错误 - 405 - 方法禁用 (
MethodDisabled
),返回 错误 - 415 - JSON 错误 (
JsonError
),返回 错误
-
DELETE
- 从某个 stream 上游服务器组中移除服务器从 stream 服务器组中移除服务器。
可能的响应
- 200 - 成功,返回 Stream 上游服务器数组
- 400 - 上游是静态的 (
UpstreamStatic
),服务器 ID 无效 (UpstreamBadServerId
),服务器“id
”不可移除 (UpstreamServerImmutable
),返回 错误 - 404 - ID 为“
id
”的服务器不存在 (UpstreamServerNotFound
),未知版本 (UnknownVersion
),未找到上游 (UpstreamNotFound
),返回 错误 - 405 - 方法禁用 (
MethodDisabled
),返回 错误
-
/stream/keyvals/
-
支持的方法
-
GET
- 从所有 stream keyval 区域返回键值对返回每个 stream keyval 共享内存 zone 的键值对。
请求参数
fields
(string
, 可选)- 如果“
fields
”值为空,则仅输出 stream keyval zone 名称。
可能的响应
- 200 - 成功,返回所有 stream keyvals 的 "Stream Keyval Shared Memory Zone" 对象集合。
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/stream/keyvals/{streamKeyvalZoneName}
- 所有方法共有的参数
streamKeyvalZoneName
(string
, 必需)- Stream keyval 共享内存 zone 的名称。
支持的方法
-
GET
- 从 stream keyval zone 返回键值对返回存储在特定 stream keyval 共享内存 zone 中的键值对。
请求参数
key
(string
, 可选)- 从 stream keyval zone 获取特定的键值对。
可能的响应
- 200 - 成功,返回 Stream Keyval Shared Memory Zone
- 404 - 未找到 Keyval (
KeyvalNotFound
),未找到 Keyval 键 (KeyvalKeyNotFound
),未知版本 (UnknownVersion
),返回 错误
-
POST
- 向 stream keyval zone 添加键值对向 stream keyval 共享内存 zone 添加新的键值对。如果 stream keyval 共享内存 zone 为空,则可以输入多个键值对。
请求参数
Key-value
(Stream Keyval Shared Memory Zone, 必需)- 键值对以 JSON 格式指定。如果 stream keyval 共享内存 zone 为空,则可以输入多个键值对。可以使用
expire
参数为键值对指定以毫秒为单位的过期时间,该时间会覆盖timeout
指令的 keyval_zone 参数。
可能的响应
- 201 - 已创建
- 400 - JSON 无效 (
KeyvalFormatError
),键格式无效 (KeyvalFormatError
),需要键 (KeyvalFormatError
),keyval timeout 未启用 (KeyvalFormatError
),只能添加一个键 (KeyvalFormatError
),读取请求体失败BodyReadError
),返回 错误 - 404 - 未找到 Keyval (
KeyvalNotFound
),未知版本 (UnknownVersion
),返回 错误 - 405 - 方法禁用 (
MethodDisabled
),返回 错误 - 409 - 条目已存在 (
EntryExists
),键已存在 (KeyvalKeyExists
),返回 错误 - 413 - 请求实体过大 (Request Entity Too Large),返回 错误
- 415 - JSON 错误 (
JsonError
),返回 错误
-
PATCH
- 修改键值对或删除键更改键值对中选定键的值,通过将键值设置为
null
删除键,更改键值对的过期时间。如果启用了集群中 keyval zone 的 同步,则仅在目标集群节点上删除键。过期时间以毫秒为单位,通过expire
参数指定,该参数会覆盖timeout
指令的 keyval_zone 参数。请求参数
streamKeyvalZoneKeyValue
(Stream Keyval Shared Memory Zone, 必需)- 键的新值以 JSON 格式指定。
可能的响应
- 204 - 成功
- 400 - JSON 无效 (
KeyvalFormatError
),需要键 (KeyvalFormatError
),keyval timeout 未启用 (KeyvalFormatError
),只能更新一个键 (KeyvalFormatError
),读取请求体失败BodyReadError
),返回 错误 - 404 - 未找到 Keyval (
KeyvalNotFound
),未找到 Keyval 键 (KeyvalKeyNotFound
),未知版本 (UnknownVersion
),返回 错误 - 405 - 方法禁用 (
MethodDisabled
),返回 错误 - 413 - 请求实体过大 (Request Entity Too Large),返回 错误
- 415 - JSON 错误 (
JsonError
),返回 错误
-
DELETE
- 清空 stream keyval zone从 stream keyval 共享内存 zone 中删除所有键值对。如果启用了集群中 keyval zone 的 同步,则仅在目标集群节点上清空 keyval zone。
可能的响应
-
/stream/zone_sync/
-
支持的方法
-
GET
- 返回节点的同步状态返回集群节点的同步状态。
可能的响应
- 200 - 成功,返回 Stream Zone Sync Node
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/resolvers/
-
支持的方法
-
GET
- 返回所有解析器 zone 的状态返回每个 resolver zone 的状态信息。
请求参数
fields
(string
, 可选)- 限制将要输出的解析器统计信息的字段。
可能的响应
- 200 - 成功,返回所有解析器的 "Resolver Zone" 对象集合。
- 404 - 未知版本 (
UnknownVersion
),返回 错误
-
-
/resolvers/{resolverZoneName}
- 所有方法共有的参数
resolverZoneName
(string
, 必需)- 解析器 zone 的名称。
支持的方法
-
GET
- 返回解析器 zone 的统计信息返回存储在特定解析器 zone 中的统计信息。
请求参数
fields
(string
, 可选)- 限制将要输出的解析器 zone 的字段(请求、响应或两者)。
可能的响应
- 200 - 成功,返回 Resolver Zone
- 404 - 未找到解析器 zone (
ResolverZoneNotFound
),未知版本 (UnknownVersion
),返回 Error
-
DELETE
- 重置解析器 zone 的统计信息。重置特定解析器 zone 中的统计信息。
可能的响应
-
/ssl
-
支持的方法
-
/license
-
支持的方法
-
/workers/
-
支持的方法
-
GET
- 返回所有 worker 进程的统计信息返回所有 worker 进程的统计信息,例如已接受、已丢弃、活动、空闲连接,以及总请求数和当前请求数。
请求参数
fields
(string
, 可选)- 限制将要输出的 worker 进程统计信息的字段。
可能的响应
- 200 - 成功,返回所有 worker 的 "Worker process" 对象集合。
- 404 - 未找到 worker (
WorkerNotFound
),未知版本 (UnknownVersion
),返回 Error
-
DELETE
- 重置所有 worker 进程的统计信息。重置所有 worker 进程的统计信息,例如已接受、已丢弃、活动、空闲连接,以及总请求数和当前请求数。
可能的响应
-
-
/workers/{workerId}
- 所有方法共有的参数
workerId
(string
, 必需)- Worker 进程的 ID。
支持的方法
-
GET
- 返回 worker 进程的状态返回特定 worker 进程的状态。
请求参数
fields
(string
, 可选)- 限制将要输出的 worker 进程统计信息的字段。
可能的响应
- 200 - 成功,返回 Worker process
- 404 - 未找到 worker (
WorkerNotFound
),未知版本 (UnknownVersion
),返回 Error
-
DELETE
- 重置 worker 进程的统计信息。重置已接受、已丢弃、活动、空闲连接的统计信息,以及总请求数和当前请求数。
可能的响应
响应对象
-
nginx
有关 nginx 的一般信息-
version
(string
) - nginx 版本。
-
build
(string
) - nginx 构建名称。
-
address
(string
) - 接受状态请求的服务器地址。
-
generation
(integer
) - 配置重新加载的总次数。
-
load_timestamp
(string
) - 上次配置重新加载的时间,格式为 ISO 8601,精度为毫秒。
-
timestamp
(string
) - 当前时间,格式为 ISO 8601,精度为毫秒。
-
pid
(integer
) - 处理状态请求的 worker 进程 ID。
-
ppid
(integer
) - 启动 worker 进程的主进程 ID。
示例
{ "nginx" : { "version" : "1.21.6", "build" : "nginx-plus-r27", "address" : "206.251.255.64", "generation" : 6, "load_timestamp" : "2022-06-28T11:15:44.467Z", "timestamp" : "2022-06-28T09:26:07.305Z", "pid" : 32212, "ppid" : 32210 } }
-
-
进程
-
respawned
(integer
) - 异常终止和重新生成的子进程总数。
示例
{ "respawned" : 0 }
-
-
连接
已接受、已丢弃、活动和空闲连接的数量。-
accepted
(integer
) - 已接受的客户端连接总数。
-
dropped
(integer
) - 已丢弃的客户端连接总数。
-
active
(integer
) - 当前活动的客户端连接数。
-
idle
(integer
) - 当前空闲的客户端连接数。
示例
{ "accepted" : 4968119, "dropped" : 0, "active" : 5, "idle" : 117 }
-
-
SSL
-
handshakes
(integer
) - 成功的 SSL 握手总数。
-
handshakes_failed
(integer
) - 失败的 SSL 握手总数。
-
session_reuses
(integer
) - SSL 握手期间会话重用的总次数。
-
no_common_protocol
(integer
) - 因没有通用协议而失败的 SSL 握手数。
-
no_common_cipher
(integer
) - 因没有共享密码套件而失败的 SSL 握手数。
-
handshake_timeout
(integer
) - 因超时而失败的 SSL 握手数。
-
peer_rejected_cert
(integer
) - 当 nginx 向客户端提供证书但被客户端以相应的告警消息拒绝时失败的 SSL 握手数。
-
verify_failures
- SSL 证书验证错误
-
no_cert
(integer
) - 客户端未提供必需的证书。
-
expired_cert
(integer
) - 客户端提供了一个过期或尚未生效的证书。
-
revoked_cert
(integer
) - 客户端提供了一个已吊销的证书。
-
hostname_mismatch
(integer
) - 服务器证书与主机名不匹配。
-
other
(integer
) - 其他 SSL 证书验证错误。
-
示例
{ "handshakes" : 79572, "handshakes_failed" : 21025, "session_reuses" : 15762, "no_common_protocol" : 4, "no_common_cipher" : 2, "handshake_timeout" : 0, "peer_rejected_cert" : 0, "verify_failures" : { "no_cert" : 0, "expired_cert" : 2, "revoked_cert" : 1, "hostname_mismatch" : 2, "other" : 1 } }
-
-
使用 slab allocator 的共享内存 zone
使用 slab allocator 的共享内存 zone-
pages
- 空闲和已用内存页的数量。
-
used
(integer
) - 当前已用内存页数。
-
free
(integer
) - 当前空闲内存页数。
-
-
slots
-
内存槽(8、16、32、64、128 等)的状态数据
"Memory Slot" 对象集合
示例
{ "pages" : { "used" : 1143, "free" : 2928 }, "slots" : { "8" : { "used" : 0, "free" : 0, "reqs" : 0, "fails" : 0 }, "16" : { "used" : 0, "free" : 0, "reqs" : 0, "fails" : 0 }, "32" : { "used" : 0, "free" : 0, "reqs" : 0, "fails" : 0 }, "64" : { "used" : 1, "free" : 63, "reqs" : 1, "fails" : 0 }, "128" : { "used" : 0, "free" : 0, "reqs" : 0, "fails" : 0 }, "256" : { "used" : 18078, "free" : 178, "reqs" : 1635736, "fails" : 0 } } }
-
-
Memory Slot
-
used
(integer
) - 当前已用内存槽数。
-
free
(integer
) - 当前空闲内存槽数。
-
reqs
(integer
) - 尝试分配指定大小内存的总次数。
-
fails
(integer
) - 分配指定大小内存的失败次数。
-
-
HTTP Requests
-
total
(integer
) - 客户端请求总数。
-
current
(integer
) - 当前客户端请求数。
示例
{ "total" : 10624511, "current" : 4 }
-
-
HTTP Server Zone
-
processing
(integer
) - 当前正在处理的客户端请求数。
-
requests
(integer
) - 从客户端接收到的客户端请求总数。
-
responses
- 发送给客户端的响应总数,状态码为“
1xx
”、“2xx
”、“3xx
”、“4xx
”和“5xx
”的响应数,以及每个状态码的响应数。-
1xx
(integer
) - 状态码为“
1xx
”的响应数。 -
2xx
(integer
) - 状态码为“
2xx
”的响应数。 -
3xx
(integer
) - 状态码为“
3xx
”的响应数。 -
4xx
(integer
) - 状态码为“
4xx
”的响应数。 -
5xx
(integer
) - 状态码为“
5xx
”的响应数。 -
codes
- 每个状态码的响应数。
-
codeNumber
(integer
) - 具有此特定状态码的响应数。
-
-
total
(integer
) - 发送给客户端的响应总数。
-
-
discarded
(integer
) - 未发送响应即完成的请求总数。
-
received
(integer
) - 从客户端接收到的总字节数。
-
sent
(integer
) - 发送给客户端的总字节数。
-
ssl
-
-
handshakes
(integer
) - 成功的 SSL 握手总数。
-
handshakes_failed
(integer
) - 失败的 SSL 握手总数。
-
session_reuses
(integer
) - SSL 握手期间会话重用的总次数。
-
no_common_protocol
(integer
) - 因没有通用协议而失败的 SSL 握手数。
-
no_common_cipher
(integer
) - 因没有共享密码套件而失败的 SSL 握手数。
-
handshake_timeout
(integer
) - 因超时而失败的 SSL 握手数。
-
peer_rejected_cert
(integer
) - 当 nginx 向客户端提供证书但被客户端以相应的告警消息拒绝时失败的 SSL 握手数。
-
verify_failures
- SSL 证书验证错误
-
no_cert
(integer
) - 客户端未提供必需的证书。
-
expired_cert
(integer
) - 客户端提供了一个过期或尚未生效的证书。
-
revoked_cert
(integer
) - 客户端提供了一个已吊销的证书。
-
other
(integer
) - 其他 SSL 证书验证错误。
-
-
示例
{ "processing" : 1, "requests" : 706690, "responses" : { "1xx" : 0, "2xx" : 699482, "3xx" : 4522, "4xx" : 907, "5xx" : 266, "codes" : { "200" : 699482, "301" : 4522, "404" : 907, "503" : 266 }, "total" : 705177 }, "discarded" : 1513, "received" : 172711587, "sent" : 19415530115, "ssl" : { "handshakes" : 104303, "handshakes_failed" : 1421, "session_reuses" : 54645, "no_common_protocol" : 4, "no_common_cipher" : 2, "handshake_timeout" : 0, "peer_rejected_cert" : 0, "verify_failures" : { "no_cert" : 0, "expired_cert" : 2, "revoked_cert" : 1, "other" : 1 } } }
-
-
HTTP Location Zone
-
requests
(integer
) - 从客户端接收到的客户端请求总数。
-
responses
- 发送给客户端的响应总数,状态码为“
1xx
”、“2xx
”、“3xx
”、“4xx
”和“5xx
”的响应数,以及每个状态码的响应数。-
1xx
(integer
) - 状态码为“
1xx
”的响应数。 -
2xx
(integer
) - 状态码为“
2xx
”的响应数。 -
3xx
(integer
) - 状态码为“
3xx
”的响应数。 -
4xx
(integer
) - 状态码为“
4xx
”的响应数。 -
5xx
(integer
) - 状态码为“
5xx
”的响应数。 -
codes
- 每个状态码的响应数。
-
codeNumber
(integer
) - 具有此特定状态码的响应数。
-
-
total
(integer
) - 发送给客户端的响应总数。
-
-
discarded
(integer
) - 未发送响应即完成的请求总数。
-
received
(integer
) - 从客户端接收到的总字节数。
-
sent
(integer
) - 发送给客户端的总字节数。
示例
{ "requests" : 706690, "responses" : { "1xx" : 0, "2xx" : 699482, "3xx" : 4522, "4xx" : 907, "5xx" : 266, "codes" : { "200" : 112674, "301" : 4522, "404" : 2504, "503" : 266 }, "total" : 705177 }, "discarded" : 1513, "received" : 172711587, "sent" : 19415530115 }
-
-
HTTP Cache
-
size
(integer
) - 缓存的当前大小。
-
max_size
(integer
) - 配置中指定的缓存最大大小限制。
-
cold
(boolean
) - 布尔值,指示“缓存加载器”进程是否仍在从磁盘加载数据到缓存中。
-
hit
-
-
responses
(integer
) - 从缓存中读取的有效响应总数。
-
bytes
(integer
) - 从缓存中读取的总字节数。
-
-
stale
-
-
responses
(integer
) - 从缓存中读取的过期响应总数(参见 proxy_cache_use_stale 及其他 “
*_cache_use_stale
” 指令)。 -
bytes
(integer
) - 从缓存中读取的总字节数。
-
-
updating
-
-
responses
(integer
) - 在响应更新期间从缓存中读取的过期响应总数(参见 proxy_cache_use_stale 及其他 “
*_cache_use_stale
” 指令)。 -
bytes
(integer
) - 从缓存中读取的总字节数。
-
-
revalidated
-
-
responses
(integer
) - 从缓存中读取的已过期且已重新验证的响应总数(参见 proxy_cache_revalidate 及其他 “
*_cache_revalidate
” 指令)。 -
bytes
(integer
) - 从缓存中读取的总字节数。
-
-
miss
-
-
responses
(integer
) - 在缓存中未找到的响应总数。
-
bytes
(integer
) - 从代理服务器读取的总字节数。
-
responses_written
(integer
) - 写入缓存的响应总数。
-
bytes_written
(integer
) - 写入缓存的总字节数。
-
-
expired
-
-
responses
(integer
) - 未从缓存中获取的过期响应总数。
-
bytes
(integer
) - 从代理服务器读取的总字节数。
-
responses_written
(integer
) - 写入缓存的响应总数。
-
bytes_written
(integer
) - 写入缓存的总字节数。
-
-
bypass
-
-
responses
(integer
) - 由于 proxy_cache_bypass 及其他 “
*_cache_bypass
” 指令,未在缓存中查找的响应总数。 -
bytes
(integer
) - 从代理服务器读取的总字节数。
-
responses_written
(integer
) - 写入缓存的响应总数。
-
bytes_written
(integer
) - 写入缓存的总字节数。
-
示例
{ "size" : 530915328, "max_size" : 536870912, "cold" : false, "hit" : { "responses" : 254032, "bytes" : 6685627875 }, "stale" : { "responses" : 0, "bytes" : 0 }, "updating" : { "responses" : 0, "bytes" : 0 }, "revalidated" : { "responses" : 0, "bytes" : 0 }, "miss" : { "responses" : 1619201, "bytes" : 53841943822 }, "expired" : { "responses" : 45859, "bytes" : 1656847080, "responses_written" : 44992, "bytes_written" : 1641825173 }, "bypass" : { "responses" : 200187, "bytes" : 5510647548, "responses_written" : 200173, "bytes_written" : 44992 } }
-
-
HTTP Connections Limiting
-
passed
(integer
) - 既未被限制也未被记为受限的连接总数。
-
rejected
(integer
) - 被拒绝的连接总数。
-
rejected_dry_run
(integer
) - 在 dry run 模式下记为拒绝的连接总数。
示例
{ "passed" : 15, "rejected" : 0, "rejected_dry_run" : 2 }
-
-
HTTP Requests Rate Limiting
-
passed
(integer
) - 既未被限制也未被记为受限的请求总数。
-
delayed
(integer
) - 被延迟的请求总数。
-
rejected
(integer
) - 被拒绝的请求总数。
-
delayed_dry_run
(integer
) - 在 dry run 模式下记为延迟的请求总数。
-
rejected_dry_run
(integer
) - 在 dry run 模式下记为拒绝的请求总数。
示例
{ "passed" : 15, "delayed" : 4, "rejected" : 0, "delayed_dry_run" : 1, "rejected_dry_run" : 2 }
-
-
HTTP Upstream
-
peers
- 数组
-
id
(integer
) - 服务器的 ID。
-
server
(string
) - 服务器的 address。
-
service
(string
) - server 指令的 service 参数值。
-
name
(string
) - server 指令中指定的服务器名称。
-
backup
(boolean
) - 布尔值,指示服务器是否为 backup 服务器。
-
weight
(integer
) - 服务器的 Weight。
-
state
(string
) - 当前状态,可能为 “
up
”、“draining
”、“down
”、“unavail
”、“checking
” 或 “unhealthy
” 之一。 -
active
(integer
) - 当前活动的连接数。
-
ssl
-
-
handshakes
(integer
) - 成功的 SSL 握手总数。
-
handshakes_failed
(integer
) - 失败的 SSL 握手总数。
-
session_reuses
(integer
) - SSL 握手期间会话重用的总次数。
-
no_common_protocol
(integer
) - 因没有通用协议而失败的 SSL 握手数。
-
handshake_timeout
(integer
) - 因超时而失败的 SSL 握手数。
-
peer_rejected_cert
(integer
) - 当 nginx 向上游服务器提供证书但被其以相应的告警消息拒绝时失败的 SSL 握手数。
-
verify_failures
- SSL 证书验证错误
-
expired_cert
(integer
) - 上游服务器提供了一个过期或尚未生效的证书。
-
revoked_cert
(integer
) - 上游服务器提供了一个已吊销的证书。
-
hostname_mismatch
(integer
) - 服务器证书与主机名不匹配。
-
other
(integer
) - 其他 SSL 证书验证错误。
-
-
-
max_conns
(integer
) - 服务器的 max_conns 限制。
-
requests
(integer
) - 转发到此服务器的客户端请求总数。
-
responses
-
-
1xx
(integer
) - 状态码为“
1xx
”的响应数。 -
2xx
(integer
) - 状态码为“
2xx
”的响应数。 -
3xx
(integer
) - 状态码为“
3xx
”的响应数。 -
4xx
(integer
) - 状态码为“
4xx
”的响应数。 -
5xx
(integer
) - 状态码为“
5xx
”的响应数。 -
codes
- 每个状态码的响应数。
-
codeNumber
(integer
) - 具有此特定状态码的响应数。
-
-
total
(integer
) - 从此服务器获得的响应总数。
-
-
sent
(integer
) - 发送到此服务器的总字节数。
-
received
(integer
) - 从此服务器接收到的总字节数。
-
fails
(integer
) - 与服务器通信的失败尝试总数。
-
unavail
(integer
) - 由于失败尝试次数达到 max_fails 阈值而导致服务器对客户端请求不可用(状态“
unavail
”)的次数。 -
health_checks
-
downtime
(integer
) - 服务器处于 “
unavail
”、“checking
” 和 “unhealthy
” 状态的总时间。 -
downstart
(string
) - 服务器变为 “
unavail
”、“checking
” 或 “unhealthy
” 的时间,格式为 ISO 8601,精度为毫秒。 -
selected
(string
) - 上次选择服务器处理请求的时间,格式为 ISO 8601,精度为毫秒。
-
header_time
(integer
) - 从服务器获取响应头的平均时间。
-
response_time
(integer
) - 从服务器获取完整响应的平均时间。
-
-
keepalive
(integer
) - 当前空闲的 keepalive 连接数。
-
zombies
(integer
) - 当前从组中移除但仍在处理活动客户端请求的服务器数。
-
zone
(string
) - 保持组配置和运行时状态的共享内存 zone 的名称。
-
queue
- 对于请求队列,提供以下数据
-
size
(integer
) - 队列中当前请求数。
-
max_size
(integer
) - 队列中可同时存在的最大请求数。
-
overflows
(integer
) - 由于队列溢出而被拒绝的请求总数。
-
示例
{ "upstream_backend" : { "peers" : [ { "id" : 0, "server" : "10.0.0.1:8088", "name" : "10.0.0.1:8088", "backup" : false, "weight" : 5, "state" : "up", "active" : 0, "ssl" : { "handshakes" : 620311, "handshakes_failed" : 3432, "session_reuses" : 36442, "no_common_protocol" : 4, "handshake_timeout" : 0, "peer_rejected_cert" : 0, "verify_failures" : { "expired_cert" : 2, "revoked_cert" : 1, "hostname_mismatch" : 2, "other" : 1 } }, "max_conns" : 20, "requests" : 667231, "header_time" : 20, "response_time" : 36, "responses" : { "1xx" : 0, "2xx" : 666310, "3xx" : 0, "4xx" : 915, "5xx" : 6, "codes" : { "200" : 666310, "404" : 915, "503" : 6 }, "total" : 667231 }, "sent" : 251946292, "received" : 19222475454, "fails" : 0, "unavail" : 0, "health_checks" : { "checks" : 26214, "fails" : 0, "unhealthy" : 0, "last_passed" : true }, "downtime" : 0, "downstart" : "2022-06-28T11:09:21.602Z", "selected" : "2022-06-28T15:01:25.000Z" }, { "id" : 1, "server" : "10.0.0.1:8089", "name" : "10.0.0.1:8089", "backup" : true, "weight" : 1, "state" : "unhealthy", "active" : 0, "max_conns" : 20, "requests" : 0, "responses" : { "1xx" : 0, "2xx" : 0, "3xx" : 0, "4xx" : 0, "5xx" : 0, "codes" : { }, "total" : 0 }, "sent" : 0, "received" : 0, "fails" : 0, "unavail" : 0, "health_checks" : { "checks" : 26284, "fails" : 26284, "unhealthy" : 1, "last_passed" : false }, "downtime" : 262925617, "downstart" : "2022-06-28T11:09:21.602Z", "selected" : "2022-06-28T15:01:25.000Z" } ], "keepalive" : 0, "zombies" : 0, "zone" : "upstream_backend" } }
-
-
HTTP Upstream Server
HTTP upstream server 的动态可配置参数-
id
(integer
) - HTTP upstream server 的 ID。ID 自动分配,不能更改。
-
server
(string
) - 与 HTTP upstream server 的 address 参数相同。添加服务器时,可以将其指定为域名。在这种情况下,与域名对应的 IP 地址变化将受到监控并自动应用于 upstream 配置,无需重新启动 nginx。这需要在“
http
”块中设置 resolver 指令。另请参见 HTTP upstream server 的 resolve 参数。 -
service
(string
) - 与 HTTP upstream server 的 service 参数相同。此参数不能更改。
-
weight
(integer
) - 与 HTTP upstream server 的 weight 参数相同。
-
max_conns
(integer
) - 与 HTTP upstream server 的 max_conns 参数相同。
-
max_fails
(integer
) - 与 HTTP upstream server 的 max_fails 参数相同。
-
fail_timeout
(string
) - 与 HTTP upstream server 的 fail_timeout 参数相同。
-
slow_start
(string
) - 与 HTTP upstream server 的 slow_start 参数相同。
-
route
(string
) - 与 HTTP upstream server 的 route 参数相同。
-
backup
(boolean
) - 当为
true
时,添加 backup 服务器。此参数不能更改。 -
down
(boolean
) - 与 HTTP upstream server 的 down 参数相同。
-
drain
(boolean
) - 与 HTTP upstream server 的 drain 参数相同。
-
parent
(string
) - 解析服务器的父服务器 ID。ID 自动分配,不能更改。
-
host
(string
) - 解析服务器的主机名。主机名自动分配,不能更改。
示例
{ "id" : 1, "server" : "10.0.0.1:8089", "weight" : 4, "max_conns" : 0, "max_fails" : 0, "fail_timeout" : "10s", "slow_start" : "10s", "route" : "", "backup" : true, "down" : true }
-
-
HTTP Keyval Shared Memory Zone
使用 GET 方法时 HTTP keyval 共享内存 zone 的内容。示例
{ "key1" : "value1", "key2" : "value2", "key3" : "value3" }
-
HTTP Keyval Shared Memory Zone
使用 POST 或 PATCH 方法时 HTTP keyval 共享内存 zone 的内容。示例
{ "key1" : "value1", "key2" : "value2", "key3" : { "value" : "value3", "expire" : 30000 } }
-
Stream Server Zone
-
processing
(integer
) - 当前正在处理的客户端连接数。
-
connections
(integer
) - 从客户端接受的总连接数。
-
sessions
- 已完成会话总数,以及状态码为“
2xx
”、“4xx
”或“5xx
”的已完成会话数。 -
discarded
(integer
) - 未创建会话即完成的连接总数。
-
received
(integer
) - 从客户端接收到的总字节数。
-
sent
(integer
) - 发送给客户端的总字节数。
-
ssl
-
-
handshakes
(integer
) - 成功的 SSL 握手总数。
-
handshakes_failed
(integer
) - 失败的 SSL 握手总数。
-
session_reuses
(integer
) - SSL 握手期间会话重用的总次数。
-
no_common_protocol
(integer
) - 因没有通用协议而失败的 SSL 握手数。
-
no_common_cipher
(integer
) - 因没有共享密码套件而失败的 SSL 握手数。
-
handshake_timeout
(integer
) - 因超时而失败的 SSL 握手数。
-
peer_rejected_cert
(integer
) - 当 nginx 向客户端提供证书但被客户端以相应的告警消息拒绝时失败的 SSL 握手数。
-
verify_failures
- SSL 证书验证错误
-
no_cert
(integer
) - 客户端未提供必需的证书。
-
expired_cert
(integer
) - 客户端提供了一个过期或尚未生效的证书。
-
revoked_cert
(integer
) - 客户端提供了一个已吊销的证书。
-
other
(integer
) - 其他 SSL 证书验证错误。
-
-
示例
{ "dns" : { "processing" : 1, "connections" : 155569, "sessions" : { "2xx" : 155564, "4xx" : 0, "5xx" : 0, "total" : 155569 }, "discarded" : 0, "received" : 4200363, "sent" : 20489184, "ssl" : { "handshakes" : 76455, "handshakes_failed" : 432, "session_reuses" : 28770, "no_common_protocol" : 4, "no_common_cipher" : 2, "handshake_timeout" : 0, "peer_rejected_cert" : 0, "verify_failures" : { "no_cert" : 0, "expired_cert" : 2, "revoked_cert" : 1, "other" : 1 } } } }
-
-
Stream Connections Limiting
-
passed
(integer
) - 既未被限制也未被记为受限的连接总数。
-
rejected
(integer
) - 被拒绝的连接总数。
-
rejected_dry_run
(integer
) - 在 dry run 模式下记为拒绝的连接总数。
示例
{ "passed" : 15, "rejected" : 0, "rejected_dry_run" : 2 }
-
-
Stream Upstream
-
peers
- 数组
-
id
(integer
) - 服务器的 ID。
-
server
(string
) - 服务器的 address。
-
service
(string
) - server 指令的 service 参数值。
-
name
(string
) - server 指令中指定的服务器名称。
-
backup
(boolean
) - 布尔值,指示服务器是否为 backup 服务器。
-
weight
(integer
) - 服务器的 Weight。
-
state
(string
) - 当前状态,可能为 “
up
”、“down
”、“unavail
”、“checking
” 或 “unhealthy
” 之一。 -
active
(integer
) - 当前连接数。
-
ssl
-
-
handshakes
(integer
) - 成功的 SSL 握手总数。
-
handshakes_failed
(integer
) - 失败的 SSL 握手总数。
-
session_reuses
(integer
) - SSL 握手期间会话重用的总次数。
-
no_common_protocol
(integer
) - 因没有通用协议而失败的 SSL 握手数。
-
handshake_timeout
(integer
) - 因超时而失败的 SSL 握手数。
-
peer_rejected_cert
(integer
) - 当 nginx 向上游服务器提供证书但被其以相应的告警消息拒绝时失败的 SSL 握手数。
-
verify_failures
- SSL 证书验证错误
-
expired_cert
(integer
) - 上游服务器提供了一个过期或尚未生效的证书。
-
revoked_cert
(integer
) - 上游服务器提供了一个已吊销的证书。
-
hostname_mismatch
(integer
) - 服务器证书与主机名不匹配。
-
other
(integer
) - 其他 SSL 证书验证错误。
-
-
-
max_conns
(integer
) - 服务器的 max_conns 限制。
-
connections
(integer
) - 转发到此服务器的客户端连接总数。
-
connect_time
(integer
) - 连接到上游服务器的平均时间。
-
first_byte_time
(integer
) - 接收到第一个字节数据的平均时间。
-
response_time
(integer
) - 接收到最后一个字节数据的平均时间。
-
sent
(integer
) - 发送到此服务器的总字节数。
-
received
(integer
) - 从此服务器接收到的总字节数。
-
fails
(integer
) - 与服务器通信的失败尝试总数。
-
unavail
(integer
) - 由于失败尝试次数达到 max_fails 阈值而导致服务器对客户端连接不可用(状态“
unavail
”)的次数。 -
health_checks
-
downtime
(integer
) - 服务器处于 “
unavail
”、“checking
” 和 “unhealthy
” 状态的总时间。 -
downstart
(string
) - 服务器变为 “
unavail
”、“checking
” 或 “unhealthy
” 的时间,格式为 ISO 8601,精度为毫秒。 -
selected
(string
) - 上次选择服务器处理连接的时间,格式为 ISO 8601,精度为毫秒。
-
-
zombies
(integer
) - 当前从组中移除但仍在处理活动客户端连接的服务器数。
-
zone
(string
) - 保持组配置和运行时状态的共享内存 zone 的名称。
示例
{ "dns" : { "peers" : [ { "id" : 0, "server" : "10.0.0.1:12347", "name" : "10.0.0.1:12347", "backup" : false, "weight" : 5, "state" : "up", "active" : 0, "ssl" : { "handshakes" : 200, "handshakes_failed" : 4, "session_reuses" : 189, "no_common_protocol" : 4, "handshake_timeout" : 0, "peer_rejected_cert" : 0, "verify_failures" : { "expired_cert" : 2, "revoked_cert" : 1, "hostname_mismatch" : 2, "other" : 1 } }, "max_conns" : 50, "connections" : 667231, "sent" : 251946292, "received" : 19222475454, "fails" : 0, "unavail" : 0, "health_checks" : { "checks" : 26214, "fails" : 0, "unhealthy" : 0, "last_passed" : true }, "downtime" : 0, "downstart" : "2022-06-28T11:09:21.602Z", "selected" : "2022-06-28T15:01:25.000Z" }, { "id" : 1, "server" : "10.0.0.1:12348", "name" : "10.0.0.1:12348", "backup" : true, "weight" : 1, "state" : "unhealthy", "active" : 0, "max_conns" : 50, "connections" : 0, "sent" : 0, "received" : 0, "fails" : 0, "unavail" : 0, "health_checks" : { "checks" : 26284, "fails" : 26284, "unhealthy" : 1, "last_passed" : false }, "downtime" : 262925617, "downstart" : "2022-06-28T11:09:21.602Z", "selected" : "2022-06-28T15:01:25.000Z" } ], "zombies" : 0, "zone" : "dns" } }
-
-
Stream Upstream Server
Stream upstream server 的动态可配置参数-
id
(integer
) - Stream upstream server 的 ID。ID 自动分配,不能更改。
-
server
(string
) - 与 stream upstream server 的 address 参数相同。添加服务器时,可以将其指定为域名。在这种情况下,与域名对应的 IP 地址变化将受到监控并自动应用于 upstream 配置,无需重新启动 nginx。这需要在“
stream
”块中设置 resolver 指令。另请参见 stream upstream server 的 resolve 参数。 -
service
(string
) - 与 stream upstream server 的 service 参数相同。此参数不能更改。
-
weight
(integer
) - 与 stream upstream server 的 weight 参数相同。
-
max_conns
(integer
) - 与 stream upstream server 的 max_conns 参数相同。
-
max_fails
(integer
) - 与 stream upstream server 的 max_fails 参数相同。
-
fail_timeout
(string
) - 与 stream upstream server 的 fail_timeout 参数相同。
-
slow_start
(string
) - 与 stream upstream server 的 slow_start 参数相同。
-
backup
(boolean
) - 当为
true
时,添加 backup 服务器。此参数不能更改。 -
down
(boolean
) - 与 stream upstream server 的 down 参数相同。
-
parent
(string
) - 解析服务器的父服务器 ID。ID 自动分配,不能更改。
-
host
(string
) - 解析服务器的主机名。主机名自动分配,不能更改。
示例
{ "id" : 0, "server" : "10.0.0.1:12348", "weight" : 1, "max_conns" : 0, "max_fails" : 1, "fail_timeout" : "10s", "slow_start" : 0, "backup" : false, "down" : false }
-
-
Stream Keyval Shared Memory Zone
使用 GET 方法时 stream keyval 共享内存 zone 的内容。示例
{ "key1" : "value1", "key2" : "value2", "key3" : "value3" }
-
Stream Keyval Shared Memory Zone
使用 POST 或 PATCH 方法时 stream keyval 共享内存 zone 的内容。示例
{ "key1" : "value1", "key2" : "value2", "key3" : { "value" : "value3", "expire" : 30000 } }
-
Stream Zone Sync Node
-
zones
-
每个共享内存 zone 的同步信息。
"Sync Zone" 对象集合
-
status
- 集群中每个节点的同步信息。
-
bytes_in
(integer
) - 此节点接收到的字节数。
-
msgs_in
(integer
) - 此节点接收到的消息数。
-
msgs_out
(integer
) - 此节点发送的消息数。
-
bytes_out
(integer
) - 此节点发送的字节数。
-
nodes_online
(integer
) - 此节点连接到的对等节点数。
-
示例
{ "zones" : { "zone1" : { "records_pending" : 2061, "records_total" : 260575 }, "zone2" : { "records_pending" : 0, "records_total" : 14749 } }, "status" : { "bytes_in" : 1364923761, "msgs_in" : 337236, "msgs_out" : 346717, "bytes_out" : 1402765472, "nodes_online" : 15 } }
-
-
Sync Zone
共享内存 zone 的同步状态。-
records_pending
(integer
) - 需要发送到集群的记录数。
-
records_total
(integer
) - 存储在共享内存 zone 中的记录总数。
-
-
Resolver Zone
每个特定 resolver zone 的 DNS 请求和响应统计信息。-
requests
-
-
name
(integer
) - 将名称解析为地址的请求总数。
-
srv
(integer
) - 解析 SRV 记录的请求总数。
-
addr
(integer
) - 将地址解析为名称的请求总数。
-
-
responses
-
-
noerror
(integer
) - 成功响应总数。
-
formerr
(integer
) - FORMERR(
Format error
)响应总数。 -
servfail
(integer
) - SERVFAIL(
Server failure
)响应总数。 -
nxdomain
(integer
) - NXDOMAIN(
Host not found
)响应总数。 -
notimp
(integer
) - NOTIMP(
Unimplemented
)响应总数。 -
refused
(integer
) - REFUSED(
Operation refused
)响应总数。 -
timedout
(integer
) - 超时请求总数。
-
unknown
(integer
) - 因未知错误完成的请求总数。
-
示例
{ "resolver_zone1" : { "requests" : { "name" : 25460, "srv" : 130, "addr" : 2580 }, "responses" : { "noerror" : 26499, "formerr" : 0, "servfail" : 3, "nxdomain" : 0, "notimp" : 0, "refused" : 0, "timedout" : 243, "unknown" : 478 } } }
-
-
License
NGINX Plus 实例的许可证和使用报告状态。-
eval
(boolean
) - 指示 NGINX Plus 许可证是否为试用版。
-
active_till
(integer
) - 许可证过期的 Unix 时间戳。
-
reporting
-
-
healthy
(boolean
) - 指示尽管近期尝试失败,报告状态是否仍被视为健康。
-
fails
(integer
) - 失败的报告尝试次数,每次成功发送使用报告时重置。
-
grace
(integer
) - 报告尝试失败后停止处理流量前的秒数。
-
示例
{ "eval" : false, "active_till" : 1749268757, "reporting" : { "healthy" : true, "fails" : 2, "grace" : 15551961 } }
-
-
Worker process
每个 worker 进程的统计信息。-
id
(integer
) - Worker 进程的 ID。
-
pid
(integer
) - 操作系统使用的 worker 进程的 PID 标识符。
-
connections
- 每个 worker 进程的已接受、已丢弃、活动和空闲连接数。
-
accepted
(integer
) - worker 进程接受的客户端连接总数。
-
dropped
(integer
) - worker 进程丢弃的客户端连接总数。
-
active
(integer
) - 当前正在由 worker 进程处理的活动客户端连接数。
-
idle
(integer
) - 当前正在由 worker 进程处理的空闲客户端连接数。
-
-
http
-
-
requests
- 由 worker 进程处理的客户端请求总数。
-
total
(integer
) - 由 worker 进程接收到的客户端请求总数。
-
current
(integer
) - 当前正在由 worker 进程处理的客户端请求数。
-
-
示例
{ "id" : 0, "pid" : 32212, "connections" : { "accepted" : 1, "dropped" : 0, "active" : 1, "idle" : 0 }, "http" : { "requests" : { "total" : 15, "current" : 1 } } }
-
-
Error
nginx 错误对象。-
error
-
-
status
(integer
) - HTTP 错误码。
-
text
(string
) - 错误描述。
-
code
(string
) - 内部 nginx 错误码。
-
-
request_id
(string
) - 请求的 ID,等于 $request_id 变量的值。
-
href
(string
) - 参考文档链接。
-