本专栏非常感谢大家得关注和支持,本人开源项目站点https://erosbt.com 将自己热爱与信仰的技术,持续不辍地传递。
ngx_http_api_module
ngx_http_api_module模块(1.13.3)提供REST API访问的各种状态信息,关于即时配置上游服务器组,并管理键-值对,而无需重新配置Nginx的。该模块取代ngx_http_status_module和ngx_http_upstream_conf_module模块。
句法: | api write = 开启,关闭; |
---|---|
默认: | — |
语境: | 位置 |
打开周围位置的REST API接口。访问这个位置应该是有限的。
该write参数确定API是只读还是读写。默认情况下,API是只读的。
所有API请求都应在URI中包含受支持的API版本。如果请求URI等于位置前缀,则返回支持的API版本列表。当前和唯一的API版本是“ 1”。
请求行中的可选“fields ”参数指定将输出所请求对象的哪些字段:
http://127.0.0.1/api/1/nginx?fields=version,build
支持的方法:
-200 - Success, returns an array of strings
#####/nginx
支持的方法:
-GET - 返回nginx运行实例的状态返回nginx版本,构建名称,地址,配置重新加载的数量,主进程和工作进程的ID。请求参数: fields(string,可选)限制了nginx的运行实例字段将被输出。可能的回应:
- 200 - Success, returns [nginx](about:blank#def_nginx_object)
支持的方法:
-GET - 返回nginx进程状态返回异常终止和重新生成的子进程的数量。可能的回应:
- 200 - Success, returns [Processes](about:blank#def_nginx_processes)
- 204 - Success
支持的方法:
- 200 - Success, returns [Connections](about:blank#def_nginx_connections)
- 204 - Success
支持的方法:
-GET - 返回SSL统计信息返回SSL统计信息。请求参数: fields(string,可选)限制了SSL统计领域将输出。可能的回应:
- 200 - Success, returns [SSL](about:blank#def_nginx_ssl_object)
- 204 - Success
支持的方法:
-GET - 返回所有板的状态使用板分配器返回每个共享内存区的板的状态。请求参数: fields(string,可选)限制了板坯区字段将被输出。如果“ fields”值为空,则只输出区域名称。可能的回应:
- 200 - Success, returns a collection of "[Shared memory zone with slab allocator](about:blank#def_nginx_slab_zone)" objects for all slabs
支持的方法:
- 200 - Success, returns [Shared memory zone with slab allocator](about:blank#def_nginx_slab_zone)
- 404 - Slab not found (`SlabNotFound`), returns [Error](about:blank#def_nginx_error)
- 204 - Success
- 404 - Slab not found (`SlabNotFound`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
支持的方法:
- 200 - Success, returns an array of strings
支持的方法:
- 200 - Success, returns [HTTP Requests](about:blank#def_nginx_http_requests)
- 204 - Success
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
支持的方法:
- 200 - Success, returns a collection of "[HTTP Server Zone](about:blank#def_nginx_http_server_zone)" objects for all http server zones
支持的方法:
- 200 - Success, returns [HTTP Server Zone](about:blank#def_nginx_http_server_zone)
- 404 - Server zone not found (`ServerZoneNotFound`), returns [Error](about:blank#def_nginx_error)
- 204 - Success
- 404 - Server zone not found (`ServerZoneNotFound`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
支持的方法:
- 200 - Success, returns a collection of "[HTTP Cache](about:blank#def_nginx_http_cache)" objects for all http caches
支持的方法:
- 200 - Success, returns a collection of "[HTTP Upstream](about:blank#def_nginx_http_upstream)" objects for all http upstreams
支持的方法:
GET - 返回HTTP上游服务器组的状态返回特定HTTP上游服务器组及其服务器的状态。请求参数: fields(string,可选)限制了上游服务器组的字段将被输出。可能的回应:
- 200 - Success, returns [HTTP Upstream](about:blank#def_nginx_http_upstream)
- 400 - Upstream is static (`UpstreamStatic`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), returns [Error](about:blank#def_nginx_error)
- 204 - Success
- 400 - Upstream is static (`UpstreamStatic`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
支持的方法:
- 200 - Success, returns an array of [HTTP Upstream Servers](about:blank#def_nginx_http_upstream_conf_server)
- 400 - Upstream is static (`UpstreamStatic`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), returns [Error](about:blank#def_nginx_error)
POST - 将服务器添加到HTTP上游服务器组将新服务器添加到HTTP上游服务器组。服务器参数以JSON格式指定。请求参数:( postHttpUpstreamServerHTTP上游服务器,必需)新服务器的地址和JSON格式的其他可选参数。“ ID”,“ backup”和“ service”参数不能更改。可能的回应:
- 201 - Created, returns [HTTP Upstream Server](about:blank#def_nginx_http_upstream_conf_server)
- 400 - Upstream is static (`UpstreamStatic`), invalid “_`parameter`_” value (`UpstreamConfFormatError`), missing “`server`” argument (`UpstreamConfFormatError`), unknown parameter “_`name`_” (`UpstreamConfFormatError`), nested object or list (`UpstreamConfFormatError`), “`error`” while parsing (`UpstreamBadAddress`), service upstream “`host`” may not have port (`UpstreamBadAddress`), service upstream “`host`” requires domain name (`UpstreamBadAddress`), invalid “`weight`” (`UpstreamBadWeight`), invalid “`max_conns`” (`UpstreamBadMaxConns`), invalid “`max_fails`” (`UpstreamBadMaxFails`), invalid “`fail_timeout`” (`UpstreamBadFailTimeout`), invalid “`slow_start`” (`UpstreamBadSlowStart`), route is too long (`UpstreamBadRoute`), “`service`” is empty (`UpstreamBadService`), no resolver defined to resolve (`UpstreamConfNoResolver`), upstream “_`name`_” has no backup (`UpstreamNoBackup`), upstream “_`name`_” memory exhausted (`UpstreamOutOfMemory`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
- 415 - JSON error (`JsonError`), returns [Error](about:blank#def_nginx_error)
支持的方法:
- 200 - Success, returns [HTTP Upstream Server](about:blank#def_nginx_http_upstream_conf_server)
- 400 - Upstream is static (`UpstreamStatic`), invalid server ID (`UpstreamBadServerId`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), server with ID “_`id`_” does not exist (`UpstreamServerNotFound`), returns [Error](about:blank#def_nginx_error)
PATCH - 修改HTTP上游服务器组中的服务器修改HTTP上游服务器组中特定服务器的设置。服务器参数以JSON格式指定。请求参数:( patchHttpUpstreamServerHTTP上游服务器,必需)服务器参数,以JSON格式指定。“ ID”,“ backup”和“ service”参数不能更改。可能的回应:
- 200 - Success, returns [HTTP Upstream Server](about:blank#def_nginx_http_upstream_conf_server)
- 400 - Upstream is static (`UpstreamStatic`), invalid “_`parameter`_” value (`UpstreamConfFormatError`), unknown parameter “_`name`_” (`UpstreamConfFormatError`), nested object or list (`UpstreamConfFormatError`), “`error`” while parsing (`UpstreamBadAddress`), invalid “`server`” argument (`UpstreamBadAddress`), invalid server ID (`UpstreamBadServerId`), invalid “`weight`” (`UpstreamBadWeight`), invalid “`max_conns`” (`UpstreamBadMaxConns`), invalid “`max_fails`” (`UpstreamBadMaxFails`), invalid “`fail_timeout`” (`UpstreamBadFailTimeout`), invalid “`slow_start`” (`UpstreamBadSlowStart`), route is too long (`UpstreamBadRoute`), “`service`” is empty (`UpstreamBadService`), server “_`ID`_” address is immutable (`UpstreamServerImmutable`), server “`ID`” weight is immutable (`UpstreamServerWeightImmutable`), upstream “`name`” memory exhausted (`UpstreamOutOfMemory`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), server with ID “_`id`_” does not exist (`UpstreamServerNotFound`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
- 415 - JSON error (`JsonError`), returns [Error](about:blank#def_nginx_error)
- 200 - Success, returns an array of [HTTP Upstream Servers](about:blank#def_nginx_http_upstream_conf_server)
- 400 - Upstream is static (`UpstreamStatic`), invalid server ID (`UpstreamBadServerId`), server “_`id`_” not removable (`UpstreamServerImmutable`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), server with ID “_`id`_” does not exist (`UpstreamServerNotFound`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
支持的方法:
-GET - 从所有keyval区域返回键值对每个keyval共享内存区域返回键值对。请求参数: fields(string,可选)如果“ fields”值为空,那么只有KEYVAL区名称输出。可能的回应:
- 200 - Success, returns a collection of "[Keyval Shared Memory Zone](about:blank#def_nginx_http_keyval_zone)" objects for all http keyvals
支持的方法:
- 200 - Success, returns [Keyval Shared Memory Zone](about:blank#def_nginx_http_keyval_zone)
- 404 - Keyval not found (`KeyvalNotFound`), keyval key not found (`KeyvalKeyNotFound`), returns [Error](about:blank#def_nginx_error)
POST - 向keyval区域添加键值对将新的键值对添加到keyval共享内存区域。如果keyval共享内存区域为空,则可以输入多个键值对。请求参数:( Key-valueKeyval Shared Memory Zone,必需)键值对以JSON格式指定。如果keyval共享内存区域为空,则可以输入多个键值对。可能的回应:
- 201 - Created
- 400 - Key required (`KeyvalFormatError`), only one key can be added (`KeyvalFormatError`), nested object or list (`KeyvalFormatError`), returns [Error](about:blank#def_nginx_error)
- 404 - Keyval not found (`KeyvalNotFound`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
- 409 - Key already exists (`KeyvalKeyExists`), returns [Error](about:blank#def_nginx_error)
- 415 - JSON error (`JsonError`), returns [Error](about:blank#def_nginx_error)
PATCH- 修改键值或删除键更改键值对中所选键的值或通过将键值设置为来删除键null。请求参数: httpKeyvalZoneKeyValue(Keyval共享内存区域,必需)以JSON格式指定键的新值。可能的回应:
- 204 - Success
- 400 - Key required (`KeyvalFormatError`), only one key can be updated (`KeyvalFormatError`), nested object or list (`KeyvalFormatError`), returns [Error](about:blank#def_nginx_error)
- 404 - Keyval not found (`KeyvalNotFound`), keyval key not found (`KeyvalKeyNotFound`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
- 415 - JSON error (`JsonError`), returns [Error](about:blank#def_nginx_error)
- 204 - Success
- 404 - Keyval not found (`KeyvalNotFound`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
支持的方法:
GET - 与流相关的端点的返回列表返回第一级流终端列表。可能的回应:
- 200 - Success, returns an array of strings
支持的方法:
- 200 - Success, returns a collection of "[Stream Server Zone](about:blank#def_nginx_stream_server_zone)" objects for all stream server zones
- 404 - [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
支持的方法:
- 200 - Success, returns [Stream Server Zone](about:blank#def_nginx_stream_server_zone)
- 404 - Server zone not found (`ServerZoneNotFound`), [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
- 204 - Success
- 404 - Server zone not found (`ServerZoneNotFound`), [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
支持的方法:
-GET - 返回所有流上游服务器组的状态返回每个流上游服务器组及其服务器的状态。请求参数: fields(string,可选)限制了上游服务器组的字段将被输出。如果“ fields”值为空,则仅输出上游名称。可能的回应:
- 200 - Success, returns a collection of "[Stream Upstream](about:blank#def_nginx_stream_upstream)" objects for all stream upstreams
- 404 - [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
支持的方法:
- 200 - Success, returns [Stream Upstream](about:blank#def_nginx_stream_upstream)
- 400 - Upstream is static (`UpstreamStatic`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
- 204 - Success
- 400 - Upstream is static (`UpstreamStatic`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
支持的方法:
- 200 - Success, returns an array of [Stream Upstream Servers](about:blank#def_nginx_stream_upstream_conf_server)
- 400 - Upstream is static (`UpstreamStatic`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
POST - 将服务器添加到流上游服务器组,将新服务器添加到流上游服务器组。服务器参数以JSON格式指定。请求参数:( postStreamUpstreamServer流上游服务器,必需)新服务器的地址和JSON格式的其他可选参数。“ ID”,“ backup”和“ service”参数不能更改。可能的回应:
- 201 - Created, returns [Stream Upstream Server](about:blank#def_nginx_stream_upstream_conf_server)
- 400 - Upstream is static (`UpstreamStatic`), invalid “_`parameter`_” value (`UpstreamConfFormatError`), missing “`server`” argument (`UpstreamConfFormatError`), unknown parameter “_`name`_” (`UpstreamConfFormatError`), nested object or list (`UpstreamConfFormatError`), “`error`” while parsing (`UpstreamBadAddress`), no port in server “`host`” (`UpstreamBadAddress`), service upstream “`host`” may not have port (`UpstreamBadAddress`), service upstream “`host`” requires domain name (`UpstreamBadAddress`), invalid “`weight`” (`UpstreamBadWeight`), invalid “`max_conns`” (`UpstreamBadMaxConns`), invalid “`max_fails`” (`UpstreamBadMaxFails`), invalid “`fail_timeout`” (`UpstreamBadFailTimeout`), invalid “`slow_start`” (`UpstreamBadSlowStart`), “`service`” is empty (`UpstreamBadService`), no resolver defined to resolve (`UpstreamConfNoResolver`), upstream “_`name`_” has no backup (`UpstreamNoBackup`), upstream “_`name`_” memory exhausted (`UpstreamOutOfMemory`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
- 415 - JSON error (`JsonError`), returns [Error](about:blank#def_nginx_error)
支持的方法:
- 200 - Success, returns [Stream Upstream Server](about:blank#def_nginx_stream_upstream_conf_server)
- 400 - Upstream is static (`UpstreamStatic`), invalid server ID (`UpstreamBadServerId`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), server with ID “_`id`_” does not exist (`UpstreamServerNotFound`), [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
PATCH - 修改流上游服务器组中的服务器,修改流上游服务器组中特定服务器的设置。服务器参数以JSON格式指定。请求参数:( patchStreamUpstreamServer流上游服务器,必需)服务器参数,以JSON格式指定。“ ID”,“ backup”和“ service”参数不能更改。可能的回应:
- 200 - Success, returns [Stream Upstream Server](about:blank#def_nginx_stream_upstream_conf_server)
- 400 - Upstream is static (`UpstreamStatic`), invalid “_`parameter`_” value (`UpstreamConfFormatError`), unknown parameter “_`name`_” (`UpstreamConfFormatError`), nested object or list (`UpstreamConfFormatError`), “`error`” while parsing (`UpstreamBadAddress`), invalid “`server`” argument (`UpstreamBadAddress`), no port in server “`host`” (`UpstreamBadAddress`), invalid server ID (`UpstreamBadServerId`), invalid “`weight`” (`UpstreamBadWeight`), invalid “`max_conns`” (`UpstreamBadMaxConns`), invalid “`max_fails`” (`UpstreamBadMaxFails`), invalid “`fail_timeout`” (`UpstreamBadFailTimeout`), invalid “`slow_start`” (`UpstreamBadSlowStart`), “`service`” is empty (`UpstreamBadService`), server “_`ID`_” address is immutable (`UpstreamServerImmutable`), server “_`ID`_” weight is immutable (`UpstreamServerWeightImmutable`), upstream “`name`” memory exhausted (`UpstreamOutOfMemory`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), server with ID “_`id`_” does not exist (`UpstreamServerNotFound`), [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
- 415 - JSON error (`JsonError`), returns [Error](about:blank#def_nginx_error)
- 200 - Success, returns an array of [Stream Upstream Servers](about:blank#def_nginx_stream_upstream_conf_server)
- 400 - Upstream is static (`UpstreamStatic`), invalid server ID (`UpstreamBadServerId`), server “_`id`_” not removable (`UpstreamServerImmutable`), returns [Error](about:blank#def_nginx_error)
- 404 - Upstream not found (`UpstreamNotFound`), server with ID “_`id`_” does not exist (`UpstreamServerNotFound`), [stream](../stream/ngx_stream_core_module#stream) not configured (`StreamNotConfigured`), returns [Error](about:blank#def_nginx_error)
- 405 - Method disabled (`MethodDisabled`), returns [Error](about:blank#def_nginx_error)
其他参考文档,以上就不再列出了。
以上更多详解请大家关注nginx官方网站https://nginx.org/en/docs/