非常教程

Nginx参考手册

ngx_http_upstream_conf_module

ngx_http_upstream_conf_module

  • 示例配置
  • 指令
  • upstream_conf

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

该模块已被1.13.0中的ngx_http_api_module模块取代。此模块可作为我们商业订阅的一部分。

示例配置

upstream backend {
    zone upstream_backend 64k;

    ...
}

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

指令

句法:

upstream_conf;

默认:

语境:

位置

在周围位置打开上游配置的HTTP接口。访问这个位置应该是有限的。

配置命令可以用来:

  • 查看组配置;
  • 查看,修改或删除服务器;
  • 添加一个新的服务器。

由于组中的地址不必是唯一的,因此组中的特定服务器将通过其ID进行引用。在添加新服务器或查看组配置时,会自动分配ID并显示ID。

配置命令由作为请求参数传递的参数组成,例如:

http://127.0.0.1/upstream_conf?upstream=backend

支持以下参数:

stream=选择一个流上游服务器组。如果没有此参数,请选择一个http上游服务器组。upstream=name选择要使用的组。该参数是强制性的。id=number选择用于查看,修改或删除的服务器。remove=从组中删除服务器。add=向该组添加新的服务器。backup=需要添加备份服务器。

在版本1.7.2之前,backup=还需要查看,修改或删除现有的备份服务器。

server=addressaddresshttp或流上游服务器的“ ”参数相同。

添加服务器时,可以将其指定为域名。在这种情况下,与域名对应的IP地址的更改将被监控并自动应用到上游配置,而不需要重新启动nginx(1.7.2)。这需要resolverhttp或流块中的“ ”指令。另请参阅resolvehttp或流上游服务器的“ ”参数。

service=nameservicehttp或流上游服务器(1.9.13)的“ ”参数相同。weight=numberweighthttp或流上游服务器的“ ”参数相同。max_conns=numbermax_connshttp或流上游服务器的“ ”参数相同。max_fails=numbermax_failshttp或流上游服务器的“ ”参数相同。fail_timeout=timefail_timeouthttp或流上游服务器的“ ”参数相同。slow_start=timeslow_starthttp或流上游服务器的“ ”参数相同。down=downhttp或流上游服务器的“ ”参数相同。drain=将http上游服务器置于“排空”模式(1.7.5)。在这种模式下,只有绑定到服务器的请求才会被代理。up=与“down“http或流上游服务器的参数。route=stringroutehttp上游服务器的“ ”参数相同。

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

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

http://127.0.0.1/upstream_conf?upstream=backend

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

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

要添加新服务器,请在“ server=”参数中指定其地址。没有指定其他参数,服务器将添加其他参数设置为其默认值(请参阅http或流“ server”指令)。

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

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

以上示例适用于http上游服务器组。流上游服务器组的类似示例需要“ stream=”参数。

ngx_http_upstream_conf_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