summaryrefslogtreecommitdiff
path: root/pod/nginx/ngx_http_api_module_head.pod
blob: 1d83148d5cb963f66f18746e693d5f6c667ed5a9 (plain)
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
=encoding utf-8

=head1 NAME

ngx_http_api_module_head - Module ngx_http_api_module




=head1



The C<ngx_http_api_module> module (1.13.3) provides REST API
for accessing various status information,
configuring upstream server groups on-the-fly, and managing
L<key-value pairs|ngx_http_keyval_module>
without the need of reconfiguring nginx.






B<NOTE>

The module supersedes the
L<ngx_http_status_module|ngx_http_status_module> and
L<ngx_http_upstream_conf_module|ngx_http_upstream_conf_module>
modules.






When using the C<PATCH> or C<POST> methods,
make sure that the payload does not exceed the
L<buffer size|ngx_http_core_module>
for reading the client request body, otherwise, the
C<413> (C<Request Entity Too Large>)
error may be returned.






B<NOTE>

This module is available as part of our
commercial subscription.





=head1 Example Configuration




    
    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 {
                <emphasis>api</emphasis> 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;
        }
    }


All API requests include
a supported API version in the URI.
Examples of API requests with this configuration:

    
    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






=head1 Directives

=head2 api


B<syntax:> api I<
[C<write>=C<on>E<verbar>C<off>]>



B<context:> I<location>





Turns on the REST API interface in the surrounding location.
Access to this location should be
L<limited|ngx_http_core_module>.





The C<write> parameter determines whether the API
is read-only or read-write.
By default, the API is read-only.





All API requests should contain a supported API version in the URI.
If the request URI equals the location prefix,
the list of supported API versions is returned.
The current API version is “C<9>”.





The optional “C<fields>” argument in the request line
specifies which fields of the requested objects will be output:

    
    http://127.0.0.1/api/9/nginx?fields=version,build









=head2 status_zone


B<syntax:> status_zone I<I<C<zone>>>



B<context:> I<server>


B<context:> I<location>


B<context:> I<if in location>



This directive appeared in version 1.13.12.





Enables collection of virtual
L<http|ngx_http_core_module>
or
L<stream|ngx_stream_core_module>
server status information in the specified I<C<zone>>.
Several servers may share the same zone.





Starting from 1.17.0, status information can be collected
per L<ngx_http_core_module>.
The special value C<off> disables statistics collection
in nested location blocks.
Note that the statistics is collected
in the context of a location where processing ends.
It may be different from the original location, if an
L<internal
redirect|ngx_http_core_module> happens during request processing.







=head1 Compatibility




=over




=item *

The E<sol>license data
were added in version 9 (1.27.2).



=item *

The E<sol>workersE<sol> data
were added in version 9.



=item *

Detailed failure counters were added to SSL statistics
in version 8 (1.23.2).



=item *

The C<ssl> data
for each HTTP
upstream,
server zone,
and stream
upstream,
server zone,
were added in version 8 (1.21.6).



=item *

The C<codes> data
in C<responses> for each HTTP
upstream,
server zone, and
location zone
were added in version 7.



=item *

The E<sol>streamE<sol>limit_connsE<sol> data
were added in version 6.



=item *

The E<sol>httpE<sol>limit_connsE<sol> data
were added in version 6.



=item *

The E<sol>httpE<sol>limit_reqsE<sol> data
were added in version 6.



=item *

The “C<expire>” parameter of a
L<key-value|ngx_http_keyval_module> pair can be
set or
changed
since version 5.



=item *

The E<sol>resolversE<sol> data
were added in version 5.



=item *

The E<sol>httpE<sol>location_zonesE<sol> data
were added in version 5.



=item *

The C<path> and C<method> fields of
nginx error object
were removed in version 4.
These fields continue to exist in earlier api versions,
but show an empty value.



=item *

The E<sol>streamE<sol>zone_syncE<sol> data
were added in version 3.



=item *

The drain parameter
was added in version 2.



=item *

The E<sol>streamE<sol>keyvalsE<sol> data
were added in version 2.



=back