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 提供支持
在本页
  • 示例配置
  • 指令
  • upstream_conf
  • 原文档
  1. 核心功能
  2. HTTP

ngx_http_upstream_conf_module

上一页ngx_http_upstream_module下一页ngx_http_upstream_hc_module

最后更新于5年前

直到 1.13.10 版本,它被 1.13.3 中的 模块所取代。

ngx_http_upstream_conf_module 模块允许通过简单的 HTTP 接口即时配置上游(upstream)服务器组,而无需重新启动 nginx。 或服务器组必须驻留在共享内存中。

该模块作为部分提供,

示例配置

upstream backend {
    zone upstream_backend 64k;

    ...
}

server {
    location /upstream_conf {
        upstream_conf;
        allow 127.0.0.1;
        deny all;
    }
}

指令

upstream_conf

-

说明

语法

upstream_conf;

默认

——

上下文

location

配置命令可用于:

  • 查看组配置

  • 查看、修改或删除服务器

  • 添加新服务器

由于组中的地址不要求唯一,因此组中的服务器使用 ID 引用。添加新服务器或查看组配置时,会自动分配 ID 并显示 ID。

配置命令作为请求参数传入,例如:

http://127.0.0.1/upstream_conf?upstream=backend

支持以下参数:

  • stream=

  • upstream=name

    选择要使用的组。此参数是必需的。

  • id=number

    选择一个要查看、修改或删除的服务器。

  • remove=

    从组中删除一个服务器。

  • add=

    向组中添加一个新服务器。

  • backup=

    需要添加一个备用服务器。

    在 1.7.2 版之前,查看、修改或删除现有备用服务器还需要 backup= 参数。

  • server=address

  • service=name

  • weight=number

  • max_conns=number

  • max_fails=number

  • fail_timeout=time

  • slow_start=time

  • down=

  • up=

  • route=string

前三个参数会选择一个对象。这可以是整个 http 或 stream 上游服务器组,也可以是特定服务器。如果没有其他参数,则会显示所选组或服务器的配置。

例如,要查看整个组的配置,请发送:

http://127.0.0.1/upstream_conf?upstream=backend

要查看特定服务器的配置,还要指定其 ID:

http://127.0.0.1/upstream_conf?upstream=backend&id=42

例如,要添加一个新的主服务器,请发送:

http://127.0.0.1/upstream_conf?add=&upstream=backend&server=127.0.0.1:8080

要添加一个备用服务器,发送:

http://127.0.0.1/upstream_conf?add=&upstream=backend&backup=&server=127.0.0.1:8080

要添加一个新的主服务器,将其参数设置为非默认值并将其标记为 down,发送:

http://127.0.0.1/upstream_conf?add=&upstream=backend&server=127.0.0.1:8080&weight=2&down=

删除一个服务器,指定其 ID:

http://127.0.0.1/upstream_conf?remove=&upstream=backend&id=42

讲一个现有的服务器标记为 down,发送:

http://127.0.0.1/upstream_conf?upstream=backend&id=42&down=

修改一个现有服务器的地址,发送:

http://127.0.0.1/upstream_conf?upstream=backend&id=42&server=192.0.2.3:8123

修改一个现有服务器的其他参数,发送:

http://127.0.0.1/upstream_conf?upstream=backend&id=42&max_fails=3&weight=4

原文档

在 location 中引入该指令,开启上游配置 HTTP 接口。 应访问此 location。

选择一个 上游服务器组。如果没有此参数,将选择一个 上游服务器组。

与 或 上游服务器的 address 参数相同。

添加服务器时,可以将其指定为一个域名。这种情况下,将监视与域名对应的 IP 地址的更改并自动应用于上游配置,无需重新启动 nginx(1.7.2)。这需要 或 块中的 resolver 指令。另请参阅 或 上游服务器的 resolve 参数。

与 或 上游服务器的 service 参数相同(1.9.13)。

与 或 上游服务器的 weight 参数相同。

与 或 上游服务器的 max_conns 参数相同。

与 或 上游服务器的 max_fails 参数相同。

与 或 上游服务器的 fail_timeout 参数相同。

与 或 上游服务器的 slow_start 参数相同。

与 或 上游服务器的 down 参数相同。

drain= 将 上游服务器置为 draining 模式(1.7.5)。在此模式下,只有绑定到服务器的请求才会被代理。

与 或 上游服务器的 down 参数相反。

与 上游服务器的 route 参数相同。

要添加新服务器,请在 server= 参数中指定其地址。如果未指定其他参数,添加服务器时将其他参数设置为其默认值(请参阅 或 的 server 指令)。

以上示例适用于 上游服务器组。 上游服务器组需要加上 stream= 参数。

stream
http
http
stream
http://nginx.org/en/docs/http/ngx_http_upstream_conf_module.html
ngx_http_api_module
流
商业订阅
示例配置
指令
upstream_conf
stream
stream
stream
stream
stream
stream
stream
stream
stream
stream
stream
stream
限制
http
http
http
http
http
http
http
http
http
http
http
http
http
http
http