1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
|
=encoding utf-8
=head1 NAME
ngx_http_upstream_conf_module - Module ngx_http_upstream_conf_module
=head1
The C<ngx_http_upstream_conf_module> module
allows configuring upstream server groups on-the-fly
via a simple HTTP interface without the need of restarting nginx.
The
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
server group must reside in the shared memory.
B<NOTE>
This module was available as part of our
commercial subscription
until 1.13.10.
It was superseded by the
L<ngx_http_api_module|ngx_http_api_module> module
in 1.13.3.
=head1 Example Configuration
upstream backend {
zone upstream_backend 64k;
...
}
server {
location /upstream_conf {
<emphasis>upstream_conf</emphasis>;
allow 127.0.0.1;
deny all;
}
}
=head1 Directives
=head2 upstream_conf
B<context:> I<location>
Turns on the HTTP interface of upstream configuration in the surrounding
location.
Access to this location should be
L<limited|ngx_http_core_module>.
Configuration commands can be used to:
=over
=item *
view the group configuration;
=item *
view, modify, or remove a server;
=item *
add a new server.
=back
B<NOTE>
Since addresses in a group are not required to be unique, specific
servers in a group are referenced by their IDs.
IDs are assigned automatically and shown when adding a new server
or viewing the group configuration.
A configuration command consists of parameters passed as request arguments,
for example:
http://127.0.0.1/upstream_conf?upstream=backend
The following parameters are supported:
=over
=item
C<stream=>
Selects a
L<stream|ngx_stream_upstream_module>
upstream server group.
Without this parameter, selects an
L<http|ngx_http_upstream_module>
upstream server group.
=item
C<upstream=>I<C<name>>
Selects a group to work with.
This parameter is mandatory.
=item
C<id=>I<C<number>>
Selects a server for viewing, modifying, or removing.
=item
C<remove=>
Removes a server from the group.
=item
C<add=>
Adds a new server to the group.
=item
C<backup=>
Required to add a backup server.
B<NOTE>
Before version 1.7.2, C<backup=>
was also required to view, modify, or remove existing backup servers.
=item
C<server=>I<C<address>>
Same as the “C<address>” parameter
of the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
upstream server.
When adding a server, it is possible to specify it as a domain name.
In this case, changes of the IP addresses that correspond to a domain name
will be monitored and automatically applied to the upstream
configuration without the need of restarting nginx (1.7.2).
This requires the “C<resolver>” directive in the
L<http|ngx_http_core_module>
or
L<stream|ngx_stream_core_module>
block.
See also the “C<resolve>” parameter
of the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
upstream server.
=item
C<service=>I<C<name>>
Same as the “C<service>” parameter
of the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
upstream server (1.9.13).
=item
C<weight=>I<C<number>>
Same as the “C<weight>” parameter
of the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
upstream server.
=item
C<max_conns=>I<C<number>>
Same as the “C<max_conns>” parameter
of the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
upstream server.
=item
C<max_fails=>I<C<number>>
Same as the “C<max_fails>” parameter
of the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
upstream server.
=item
C<fail_timeout=>I<C<time>>
Same as the “C<fail_timeout>” parameter
of the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
upstream server.
=item
C<slow_start=>I<C<time>>
Same as the “C<slow_start>” parameter
of the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
upstream server.
=item
C<down=>
Same as the “C<down>” parameter
of the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
upstream server.
=item C<drain=>
Puts the
L<http|ngx_http_upstream_module>
upstream server into the “draining” mode (1.7.5).
In this mode, only requests
L<bound|ngx_http_upstream_module> to the server
will be proxied to it.
=item
C<up=>
The opposite of the “C<down>” parameter
of the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
upstream server.
=item
C<route=>I<C<string>>
Same as the “C<route>” parameter of the
L<http|ngx_http_upstream_module>
upstream server.
=back
The first three parameters select an object.
This can be either the whole http or stream upstream server group,
or a specific server.
Without other parameters, the configuration of the selected
group or server is shown.
For example, to view the configuration of the whole group, send:
http://127.0.0.1/upstream_conf?upstream=backend
To view the configuration of a specific server, also specify its ID:
http://127.0.0.1/upstream_conf?upstream=backend&id=42
To add a new server,
specify its address in the “C<server=>” parameter.
Without other parameters specified, a server will be added with other
parameters set to their default values (see the
L<http|ngx_http_upstream_module>
or
L<stream|ngx_stream_upstream_module>
“C<server>” directive).
For example, to add a new primary server, send:
http://127.0.0.1/upstream_conf?add=&upstream=backend&server=127.0.0.1:8080
To add a new backup server, send:
http://127.0.0.1/upstream_conf?add=&upstream=backend&backup=&server=127.0.0.1:8080
To add a new primary server,
set its parameters to non-default values
and mark it as “C<down>”, send:
http://127.0.0.1/upstream_conf?add=&upstream=backend&server=127.0.0.1:8080&weight=2&down=
To remove a server, specify its ID:
http://127.0.0.1/upstream_conf?remove=&upstream=backend&id=42
To mark an existing server as “C<down>”, send:
http://127.0.0.1/upstream_conf?upstream=backend&id=42&down=
To modify the address of an existing server, send:
http://127.0.0.1/upstream_conf?upstream=backend&id=42&server=192.0.2.3:8123
To modify other parameters of an existing server, send:
http://127.0.0.1/upstream_conf?upstream=backend&id=42&max_fails=3&weight=4
The above examples are for an
L<http|ngx_http_upstream_module>
upstream server group.
Similar examples for a
L<stream|ngx_stream_upstream_module>
upstream server group require the “C<stream=>” parameter.
|