nginxtra 1.0.15.0 → 1.2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/nginxtra +1 -1
- data/lib/nginxtra/action.rb +10 -0
- data/lib/nginxtra/actions/compile.rb +16 -2
- data/lib/nginxtra/actions/start.rb +18 -2
- data/lib/nginxtra/actions/status.rb +1 -10
- data/lib/nginxtra/actions/stop.rb +18 -0
- data/lib/nginxtra/cli.rb +12 -3
- data/lib/nginxtra/config.rb +10 -0
- data/src/nginx/CHANGES +311 -90
- data/src/nginx/CHANGES.ru +315 -88
- data/src/nginx/auto/lib/pcre/conf +22 -5
- data/src/nginx/auto/lib/pcre/make +1 -1
- data/src/nginx/auto/modules +14 -3
- data/src/nginx/auto/options +17 -3
- data/src/nginx/auto/os/freebsd +8 -0
- data/src/nginx/auto/os/linux +5 -4
- data/src/nginx/auto/os/solaris +2 -1
- data/src/nginx/auto/sources +10 -2
- data/src/nginx/auto/summary +2 -0
- data/src/nginx/auto/types/sizeof +2 -1
- data/src/nginx/auto/types/typedef +1 -1
- data/src/nginx/auto/types/uintptr_t +7 -4
- data/src/nginx/auto/unix +82 -21
- data/src/nginx/conf/fastcgi.conf +1 -0
- data/src/nginx/conf/fastcgi_params +1 -0
- data/src/nginx/conf/scgi_params +1 -0
- data/src/nginx/conf/uwsgi_params +1 -0
- data/src/nginx/man/nginx.8 +49 -49
- data/src/nginx/src/core/nginx.c +10 -12
- data/src/nginx/src/core/nginx.h +2 -2
- data/src/nginx/src/core/ngx_buf.c +9 -7
- data/src/nginx/src/core/ngx_buf.h +2 -2
- data/src/nginx/src/core/ngx_conf_file.c +4 -11
- data/src/nginx/src/core/ngx_conf_file.h +1 -1
- data/src/nginx/src/core/ngx_connection.c +52 -1
- data/src/nginx/src/core/ngx_connection.h +6 -0
- data/src/nginx/src/core/ngx_core.h +5 -0
- data/src/nginx/src/core/ngx_cycle.c +1 -1
- data/src/nginx/src/core/ngx_cycle.h +2 -2
- data/src/nginx/src/core/ngx_file.c +1 -1
- data/src/nginx/src/core/ngx_inet.c +11 -8
- data/src/nginx/src/core/ngx_murmurhash.h +1 -1
- data/src/nginx/src/core/ngx_open_file_cache.c +343 -38
- data/src/nginx/src/core/ngx_open_file_cache.h +10 -0
- data/src/nginx/src/core/ngx_output_chain.c +2 -1
- data/src/nginx/src/core/ngx_parse.h +0 -3
- data/src/nginx/src/core/ngx_rbtree.c +1 -2
- data/src/nginx/src/core/ngx_regex.c +263 -5
- data/src/nginx/src/core/ngx_regex.h +6 -2
- data/src/nginx/src/core/ngx_resolver.c +88 -21
- data/src/nginx/src/core/ngx_resolver.h +7 -8
- data/src/nginx/src/core/ngx_shmtx.c +69 -44
- data/src/nginx/src/core/ngx_shmtx.h +12 -1
- data/src/nginx/src/core/ngx_slab.c +3 -3
- data/src/nginx/src/core/ngx_slab.h +1 -1
- data/src/nginx/src/core/ngx_string.c +19 -16
- data/src/nginx/src/core/ngx_times.c +2 -2
- data/src/nginx/src/event/modules/ngx_epoll_module.c +2 -2
- data/src/nginx/src/event/modules/ngx_eventport_module.c +1 -1
- data/src/nginx/src/event/modules/ngx_kqueue_module.c +1 -1
- data/src/nginx/src/event/ngx_event.c +25 -17
- data/src/nginx/src/event/ngx_event_openssl.c +3 -1
- data/src/nginx/src/event/ngx_event_pipe.c +108 -85
- data/src/nginx/src/event/ngx_event_pipe.h +1 -2
- data/src/nginx/src/event/ngx_event_timer.c +2 -3
- data/src/nginx/src/http/modules/ngx_http_access_module.c +9 -4
- data/src/nginx/src/http/modules/ngx_http_browser_module.c +5 -3
- data/src/nginx/src/http/modules/ngx_http_chunked_filter_module.c +1 -1
- data/src/nginx/src/http/modules/ngx_http_degradation_module.c +1 -1
- data/src/nginx/src/http/modules/ngx_http_fastcgi_module.c +144 -22
- data/src/nginx/src/http/modules/ngx_http_flv_module.c +8 -0
- data/src/nginx/src/http/modules/ngx_http_geo_module.c +3 -3
- data/src/nginx/src/http/modules/ngx_http_gzip_filter_module.c +20 -6
- data/src/nginx/src/http/modules/ngx_http_gzip_static_module.c +8 -0
- data/src/nginx/src/http/modules/ngx_http_headers_filter_module.c +23 -27
- data/src/nginx/src/http/modules/ngx_http_image_filter_module.c +1 -3
- data/src/nginx/src/http/modules/ngx_http_index_module.c +24 -0
- data/src/nginx/src/http/modules/ngx_http_limit_conn_module.c +747 -0
- data/src/nginx/src/http/modules/ngx_http_limit_req_module.c +289 -133
- data/src/nginx/src/http/modules/ngx_http_log_module.c +34 -6
- data/src/nginx/src/http/modules/ngx_http_memcached_module.c +19 -3
- data/src/nginx/src/http/modules/ngx_http_mp4_module.c +8 -0
- data/src/nginx/src/http/modules/ngx_http_proxy_module.c +1446 -239
- data/src/nginx/src/http/modules/ngx_http_realip_module.c +4 -10
- data/src/nginx/src/http/modules/ngx_http_scgi_module.c +90 -21
- data/src/nginx/src/http/modules/ngx_http_split_clients_module.c +8 -11
- data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.c +16 -6
- data/src/nginx/src/http/modules/ngx_http_static_module.c +8 -0
- data/src/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +2 -2
- data/src/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +570 -0
- data/src/nginx/src/http/modules/ngx_http_userid_filter_module.c +1 -5
- data/src/nginx/src/http/modules/ngx_http_uwsgi_module.c +77 -26
- data/src/nginx/src/http/modules/ngx_http_xslt_filter_module.c +171 -37
- data/src/nginx/src/http/modules/perl/nginx.pm +2 -1
- data/src/nginx/src/http/modules/perl/nginx.xs +4 -0
- data/src/nginx/src/http/ngx_http.c +8 -1
- data/src/nginx/src/http/ngx_http.h +1 -0
- data/src/nginx/src/http/ngx_http_busy_lock.c +2 -2
- data/src/nginx/src/http/ngx_http_cache.h +12 -1
- data/src/nginx/src/http/ngx_http_copy_filter_module.c +4 -3
- data/src/nginx/src/http/ngx_http_core_module.c +303 -37
- data/src/nginx/src/http/ngx_http_core_module.h +15 -0
- data/src/nginx/src/http/ngx_http_file_cache.c +226 -52
- data/src/nginx/src/http/ngx_http_parse.c +69 -3
- data/src/nginx/src/http/ngx_http_postpone_filter_module.c +4 -4
- data/src/nginx/src/http/ngx_http_request.c +61 -27
- data/src/nginx/src/http/ngx_http_request.h +3 -3
- data/src/nginx/src/http/ngx_http_request_body.c +1 -1
- data/src/nginx/src/http/ngx_http_script.c +6 -0
- data/src/nginx/src/http/ngx_http_upstream.c +200 -47
- data/src/nginx/src/http/ngx_http_upstream.h +20 -1
- data/src/nginx/src/http/ngx_http_upstream_round_robin.c +22 -6
- data/src/nginx/src/http/ngx_http_upstream_round_robin.h +1 -0
- data/src/nginx/src/http/ngx_http_variables.c +123 -4
- data/src/nginx/src/mail/ngx_mail.c +13 -0
- data/src/nginx/src/mail/ngx_mail.h +12 -0
- data/src/nginx/src/mail/ngx_mail_core_module.c +100 -15
- data/src/nginx/src/os/unix/ngx_daemon.c +2 -1
- data/src/nginx/src/os/unix/ngx_darwin.h +3 -0
- data/src/nginx/src/os/unix/ngx_darwin_config.h +1 -0
- data/src/nginx/src/os/unix/ngx_darwin_init.c +30 -0
- data/src/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +11 -5
- data/src/nginx/src/os/unix/ngx_errno.h +5 -0
- data/src/nginx/src/os/unix/ngx_files.h +50 -1
- data/src/nginx/src/os/unix/ngx_freebsd.h +2 -1
- data/src/nginx/src/os/unix/ngx_freebsd_config.h +2 -0
- data/src/nginx/src/os/unix/ngx_freebsd_init.c +4 -3
- data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +2 -2
- data/src/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +12 -6
- data/src/nginx/src/os/unix/ngx_gcc_atomic_sparc64.h +1 -1
- data/src/nginx/src/os/unix/ngx_linux_config.h +1 -0
- data/src/nginx/src/os/unix/ngx_linux_sendfile_chain.c +6 -4
- data/src/nginx/src/os/unix/ngx_os.h +0 -1
- data/src/nginx/src/os/unix/ngx_posix_config.h +3 -0
- data/src/nginx/src/os/unix/ngx_process.c +50 -11
- data/src/nginx/src/os/unix/ngx_process.h +1 -0
- data/src/nginx/src/os/unix/ngx_process_cycle.c +6 -15
- data/src/nginx/src/os/unix/ngx_readv_chain.c +8 -0
- data/src/nginx/src/os/unix/ngx_setaffinity.c +69 -0
- data/src/nginx/src/os/unix/ngx_setaffinity.h +23 -0
- data/src/nginx/src/os/unix/ngx_setproctitle.c +1 -1
- data/src/nginx/src/os/unix/ngx_solaris_config.h +2 -0
- data/src/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +11 -3
- data/src/nginx/src/os/unix/ngx_writev_chain.c +7 -3
- metadata +7 -4
- data/src/nginx/src/http/modules/ngx_http_limit_zone_module.c +0 -553
@@ -166,6 +166,9 @@ typedef struct {
|
|
166
166
|
ngx_uint_t cache_use_stale;
|
167
167
|
ngx_uint_t cache_methods;
|
168
168
|
|
169
|
+
ngx_flag_t cache_lock;
|
170
|
+
ngx_msec_t cache_lock_timeout;
|
171
|
+
|
169
172
|
ngx_array_t *cache_valid;
|
170
173
|
ngx_array_t *cache_bypass;
|
171
174
|
ngx_array_t *no_cache;
|
@@ -221,6 +224,7 @@ typedef struct {
|
|
221
224
|
ngx_table_elt_t *location;
|
222
225
|
ngx_table_elt_t *accept_ranges;
|
223
226
|
ngx_table_elt_t *www_authenticate;
|
227
|
+
ngx_table_elt_t *transfer_encoding;
|
224
228
|
|
225
229
|
#if (NGX_HTTP_GZIP)
|
226
230
|
ngx_table_elt_t *content_encoding;
|
@@ -229,6 +233,9 @@ typedef struct {
|
|
229
233
|
off_t content_length_n;
|
230
234
|
|
231
235
|
ngx_array_t cache_control;
|
236
|
+
|
237
|
+
unsigned connection_close:1;
|
238
|
+
unsigned chunked:1;
|
232
239
|
} ngx_http_upstream_headers_in_t;
|
233
240
|
|
234
241
|
|
@@ -271,7 +278,7 @@ struct ngx_http_upstream_s {
|
|
271
278
|
ngx_http_upstream_resolved_t *resolved;
|
272
279
|
|
273
280
|
ngx_buf_t buffer;
|
274
|
-
|
281
|
+
off_t length;
|
275
282
|
|
276
283
|
ngx_chain_t *out_bufs;
|
277
284
|
ngx_chain_t *busy_bufs;
|
@@ -292,6 +299,8 @@ struct ngx_http_upstream_s {
|
|
292
299
|
ngx_int_t rc);
|
293
300
|
ngx_int_t (*rewrite_redirect)(ngx_http_request_t *r,
|
294
301
|
ngx_table_elt_t *h, size_t prefix);
|
302
|
+
ngx_int_t (*rewrite_cookie)(ngx_http_request_t *r,
|
303
|
+
ngx_table_elt_t *h);
|
295
304
|
|
296
305
|
ngx_msec_t timeout;
|
297
306
|
|
@@ -312,6 +321,7 @@ struct ngx_http_upstream_s {
|
|
312
321
|
#endif
|
313
322
|
|
314
323
|
unsigned buffering:1;
|
324
|
+
unsigned keepalive:1;
|
315
325
|
|
316
326
|
unsigned request_sent:1;
|
317
327
|
unsigned header_sent:1;
|
@@ -324,6 +334,13 @@ typedef struct {
|
|
324
334
|
} ngx_http_upstream_next_t;
|
325
335
|
|
326
336
|
|
337
|
+
typedef struct {
|
338
|
+
ngx_str_t key;
|
339
|
+
ngx_str_t value;
|
340
|
+
ngx_uint_t skip_empty;
|
341
|
+
} ngx_http_upstream_param_t;
|
342
|
+
|
343
|
+
|
327
344
|
ngx_int_t ngx_http_upstream_header_variable(ngx_http_request_t *r,
|
328
345
|
ngx_http_variable_value_t *v, uintptr_t data);
|
329
346
|
|
@@ -333,6 +350,8 @@ ngx_http_upstream_srv_conf_t *ngx_http_upstream_add(ngx_conf_t *cf,
|
|
333
350
|
ngx_url_t *u, ngx_uint_t flags);
|
334
351
|
char *ngx_http_upstream_bind_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
335
352
|
void *conf);
|
353
|
+
char *ngx_http_upstream_param_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
354
|
+
void *conf);
|
336
355
|
ngx_int_t ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,
|
337
356
|
ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev,
|
338
357
|
ngx_str_t *default_hide_headers, ngx_hash_init_t *hash);
|
@@ -49,6 +49,13 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
|
|
49
49
|
n += server[i].naddrs;
|
50
50
|
}
|
51
51
|
|
52
|
+
if (n == 0) {
|
53
|
+
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
54
|
+
"no servers in upstream \"%V\" in %s:%ui",
|
55
|
+
&us->host, us->file_name, us->line);
|
56
|
+
return NGX_ERROR;
|
57
|
+
}
|
58
|
+
|
52
59
|
peers = ngx_pcalloc(cf->pool, sizeof(ngx_http_upstream_rr_peers_t)
|
53
60
|
+ sizeof(ngx_http_upstream_rr_peer_t) * (n - 1));
|
54
61
|
if (peers == NULL) {
|
@@ -444,8 +451,8 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
|
|
444
451
|
break;
|
445
452
|
}
|
446
453
|
|
447
|
-
if (now - peer->
|
448
|
-
peer->
|
454
|
+
if (now - peer->checked > peer->fail_timeout) {
|
455
|
+
peer->checked = now;
|
449
456
|
break;
|
450
457
|
}
|
451
458
|
|
@@ -492,8 +499,8 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
|
|
492
499
|
break;
|
493
500
|
}
|
494
501
|
|
495
|
-
if (now - peer->
|
496
|
-
peer->
|
502
|
+
if (now - peer->checked > peer->fail_timeout) {
|
503
|
+
peer->checked = now;
|
497
504
|
break;
|
498
505
|
}
|
499
506
|
|
@@ -664,15 +671,16 @@ ngx_http_upstream_free_round_robin_peer(ngx_peer_connection_t *pc, void *data,
|
|
664
671
|
return;
|
665
672
|
}
|
666
673
|
|
674
|
+
peer = &rrp->peers->peer[rrp->current];
|
675
|
+
|
667
676
|
if (state & NGX_PEER_FAILED) {
|
668
677
|
now = ngx_time();
|
669
678
|
|
670
|
-
peer = &rrp->peers->peer[rrp->current];
|
671
|
-
|
672
679
|
/* ngx_lock_mutex(rrp->peers->mutex); */
|
673
680
|
|
674
681
|
peer->fails++;
|
675
682
|
peer->accessed = now;
|
683
|
+
peer->checked = now;
|
676
684
|
|
677
685
|
if (peer->max_fails) {
|
678
686
|
peer->current_weight -= peer->weight / peer->max_fails;
|
@@ -687,6 +695,14 @@ ngx_http_upstream_free_round_robin_peer(ngx_peer_connection_t *pc, void *data,
|
|
687
695
|
}
|
688
696
|
|
689
697
|
/* ngx_unlock_mutex(rrp->peers->mutex); */
|
698
|
+
|
699
|
+
} else {
|
700
|
+
|
701
|
+
/* mark peer live if check passed */
|
702
|
+
|
703
|
+
if (peer->accessed < peer->checked) {
|
704
|
+
peer->fails = 0;
|
705
|
+
}
|
690
706
|
}
|
691
707
|
|
692
708
|
rrp->current++;
|
@@ -34,6 +34,10 @@ static ngx_int_t ngx_http_variable_cookie(ngx_http_request_t *r,
|
|
34
34
|
ngx_http_variable_value_t *v, uintptr_t data);
|
35
35
|
static ngx_int_t ngx_http_variable_argument(ngx_http_request_t *r,
|
36
36
|
ngx_http_variable_value_t *v, uintptr_t data);
|
37
|
+
#if (NGX_HAVE_TCP_INFO)
|
38
|
+
static ngx_int_t ngx_http_variable_tcpinfo(ngx_http_request_t *r,
|
39
|
+
ngx_http_variable_value_t *v, uintptr_t data);
|
40
|
+
#endif
|
37
41
|
|
38
42
|
static ngx_int_t ngx_http_variable_host(ngx_http_request_t *r,
|
39
43
|
ngx_http_variable_value_t *v, uintptr_t data);
|
@@ -49,6 +53,8 @@ static ngx_int_t ngx_http_variable_server_port(ngx_http_request_t *r,
|
|
49
53
|
ngx_http_variable_value_t *v, uintptr_t data);
|
50
54
|
static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r,
|
51
55
|
ngx_http_variable_value_t *v, uintptr_t data);
|
56
|
+
static ngx_int_t ngx_http_variable_https(ngx_http_request_t *r,
|
57
|
+
ngx_http_variable_value_t *v, uintptr_t data);
|
52
58
|
static ngx_int_t ngx_http_variable_is_args(ngx_http_request_t *r,
|
53
59
|
ngx_http_variable_value_t *v, uintptr_t data);
|
54
60
|
static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r,
|
@@ -106,7 +112,7 @@ static ngx_int_t ngx_http_variable_pid(ngx_http_request_t *r,
|
|
106
112
|
/*
|
107
113
|
* the $http_host, $http_user_agent, $http_referer, $http_via,
|
108
114
|
* and $http_x_forwarded_for variables may be handled by generic
|
109
|
-
* ngx_http_variable_unknown_header_in(), but for
|
115
|
+
* ngx_http_variable_unknown_header_in(), but for performance reasons
|
110
116
|
* they are handled using dedicated entries
|
111
117
|
*/
|
112
118
|
|
@@ -158,6 +164,8 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
|
|
158
164
|
|
159
165
|
{ ngx_string("scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 },
|
160
166
|
|
167
|
+
{ ngx_string("https"), NULL, ngx_http_variable_https, 0, 0, 0 },
|
168
|
+
|
161
169
|
{ ngx_string("request_uri"), NULL, ngx_http_variable_request,
|
162
170
|
offsetof(ngx_http_request_t, unparsed_uri), 0, 0 },
|
163
171
|
|
@@ -255,6 +263,20 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
|
|
255
263
|
{ ngx_string("pid"), NULL, ngx_http_variable_pid,
|
256
264
|
0, 0, 0 },
|
257
265
|
|
266
|
+
#if (NGX_HAVE_TCP_INFO)
|
267
|
+
{ ngx_string("tcpinfo_rtt"), NULL, ngx_http_variable_tcpinfo,
|
268
|
+
0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
|
269
|
+
|
270
|
+
{ ngx_string("tcpinfo_rttvar"), NULL, ngx_http_variable_tcpinfo,
|
271
|
+
1, NGX_HTTP_VAR_NOCACHEABLE, 0 },
|
272
|
+
|
273
|
+
{ ngx_string("tcpinfo_snd_cwnd"), NULL, ngx_http_variable_tcpinfo,
|
274
|
+
2, NGX_HTTP_VAR_NOCACHEABLE, 0 },
|
275
|
+
|
276
|
+
{ ngx_string("tcpinfo_rcv_space"), NULL, ngx_http_variable_tcpinfo,
|
277
|
+
3, NGX_HTTP_VAR_NOCACHEABLE, 0 },
|
278
|
+
#endif
|
279
|
+
|
258
280
|
{ ngx_null_string, NULL, NULL, 0, 0, 0 }
|
259
281
|
};
|
260
282
|
|
@@ -380,7 +402,7 @@ ngx_http_get_variable_index(ngx_conf_t *cf, ngx_str_t *name)
|
|
380
402
|
v->flags = 0;
|
381
403
|
v->index = cmcf->variables.nelts - 1;
|
382
404
|
|
383
|
-
return
|
405
|
+
return v->index;
|
384
406
|
}
|
385
407
|
|
386
408
|
|
@@ -880,6 +902,61 @@ ngx_http_variable_argument(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
|
880
902
|
}
|
881
903
|
|
882
904
|
|
905
|
+
#if (NGX_HAVE_TCP_INFO)
|
906
|
+
|
907
|
+
static ngx_int_t
|
908
|
+
ngx_http_variable_tcpinfo(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
909
|
+
uintptr_t data)
|
910
|
+
{
|
911
|
+
struct tcp_info ti;
|
912
|
+
socklen_t len;
|
913
|
+
uint32_t value;
|
914
|
+
|
915
|
+
len = sizeof(struct tcp_info);
|
916
|
+
if (getsockopt(r->connection->fd, IPPROTO_TCP, TCP_INFO, &ti, &len) == -1) {
|
917
|
+
v->not_found = 1;
|
918
|
+
return NGX_OK;
|
919
|
+
}
|
920
|
+
|
921
|
+
v->data = ngx_pnalloc(r->pool, NGX_INT32_LEN);
|
922
|
+
if (v->data == NULL) {
|
923
|
+
return NGX_ERROR;
|
924
|
+
}
|
925
|
+
|
926
|
+
switch (data) {
|
927
|
+
case 0:
|
928
|
+
value = ti.tcpi_rtt;
|
929
|
+
break;
|
930
|
+
|
931
|
+
case 1:
|
932
|
+
value = ti.tcpi_rttvar;
|
933
|
+
break;
|
934
|
+
|
935
|
+
case 2:
|
936
|
+
value = ti.tcpi_snd_cwnd;
|
937
|
+
break;
|
938
|
+
|
939
|
+
case 3:
|
940
|
+
value = ti.tcpi_rcv_space;
|
941
|
+
break;
|
942
|
+
|
943
|
+
/* suppress warning */
|
944
|
+
default:
|
945
|
+
value = 0;
|
946
|
+
break;
|
947
|
+
}
|
948
|
+
|
949
|
+
v->len = ngx_sprintf(v->data, "%uD", value) - v->data;
|
950
|
+
v->valid = 1;
|
951
|
+
v->no_cacheable = 0;
|
952
|
+
v->not_found = 0;
|
953
|
+
|
954
|
+
return NGX_OK;
|
955
|
+
}
|
956
|
+
|
957
|
+
#endif
|
958
|
+
|
959
|
+
|
883
960
|
static ngx_int_t
|
884
961
|
ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
885
962
|
uintptr_t data)
|
@@ -1108,6 +1185,30 @@ ngx_http_variable_scheme(ngx_http_request_t *r,
|
|
1108
1185
|
}
|
1109
1186
|
|
1110
1187
|
|
1188
|
+
static ngx_int_t
|
1189
|
+
ngx_http_variable_https(ngx_http_request_t *r,
|
1190
|
+
ngx_http_variable_value_t *v, uintptr_t data)
|
1191
|
+
{
|
1192
|
+
#if (NGX_HTTP_SSL)
|
1193
|
+
|
1194
|
+
if (r->connection->ssl) {
|
1195
|
+
v->len = sizeof("on") - 1;
|
1196
|
+
v->valid = 1;
|
1197
|
+
v->no_cacheable = 0;
|
1198
|
+
v->not_found = 0;
|
1199
|
+
v->data = (u_char *) "on";
|
1200
|
+
|
1201
|
+
return NGX_OK;
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
#endif
|
1205
|
+
|
1206
|
+
*v = ngx_http_variable_null_value;
|
1207
|
+
|
1208
|
+
return NGX_OK;
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
|
1111
1212
|
static ngx_int_t
|
1112
1213
|
ngx_http_variable_is_args(ngx_http_request_t *r,
|
1113
1214
|
ngx_http_variable_value_t *v, uintptr_t data)
|
@@ -1172,10 +1273,13 @@ static ngx_int_t
|
|
1172
1273
|
ngx_http_variable_realpath_root(ngx_http_request_t *r,
|
1173
1274
|
ngx_http_variable_value_t *v, uintptr_t data)
|
1174
1275
|
{
|
1276
|
+
u_char *real;
|
1175
1277
|
size_t len;
|
1176
1278
|
ngx_str_t path;
|
1177
1279
|
ngx_http_core_loc_conf_t *clcf;
|
1178
|
-
|
1280
|
+
#if (NGX_HAVE_MAX_PATH)
|
1281
|
+
u_char buffer[NGX_MAX_PATH];
|
1282
|
+
#endif
|
1179
1283
|
|
1180
1284
|
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
1181
1285
|
|
@@ -1197,7 +1301,15 @@ ngx_http_variable_realpath_root(ngx_http_request_t *r,
|
|
1197
1301
|
}
|
1198
1302
|
}
|
1199
1303
|
|
1200
|
-
|
1304
|
+
#if (NGX_HAVE_MAX_PATH)
|
1305
|
+
real = buffer;
|
1306
|
+
#else
|
1307
|
+
real = NULL;
|
1308
|
+
#endif
|
1309
|
+
|
1310
|
+
real = ngx_realpath(path.data, real);
|
1311
|
+
|
1312
|
+
if (real == NULL) {
|
1201
1313
|
ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
|
1202
1314
|
ngx_realpath_n " \"%s\" failed", path.data);
|
1203
1315
|
return NGX_ERROR;
|
@@ -1207,6 +1319,9 @@ ngx_http_variable_realpath_root(ngx_http_request_t *r,
|
|
1207
1319
|
|
1208
1320
|
v->data = ngx_pnalloc(r->pool, len);
|
1209
1321
|
if (v->data == NULL) {
|
1322
|
+
#if !(NGX_HAVE_MAX_PATH)
|
1323
|
+
ngx_free(real);
|
1324
|
+
#endif
|
1210
1325
|
return NGX_ERROR;
|
1211
1326
|
}
|
1212
1327
|
|
@@ -1217,6 +1332,10 @@ ngx_http_variable_realpath_root(ngx_http_request_t *r,
|
|
1217
1332
|
|
1218
1333
|
ngx_memcpy(v->data, real, len);
|
1219
1334
|
|
1335
|
+
#if !(NGX_HAVE_MAX_PATH)
|
1336
|
+
ngx_free(real);
|
1337
|
+
#endif
|
1338
|
+
|
1220
1339
|
return NGX_OK;
|
1221
1340
|
}
|
1222
1341
|
|
@@ -309,6 +309,12 @@ found:
|
|
309
309
|
addr->ctx = listen->ctx;
|
310
310
|
addr->bind = listen->bind;
|
311
311
|
addr->wildcard = listen->wildcard;
|
312
|
+
addr->so_keepalive = listen->so_keepalive;
|
313
|
+
#if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
314
|
+
addr->tcp_keepidle = listen->tcp_keepidle;
|
315
|
+
addr->tcp_keepintvl = listen->tcp_keepintvl;
|
316
|
+
addr->tcp_keepcnt = listen->tcp_keepcnt;
|
317
|
+
#endif
|
312
318
|
#if (NGX_MAIL_SSL)
|
313
319
|
addr->ssl = listen->ssl;
|
314
320
|
#endif
|
@@ -374,6 +380,13 @@ ngx_mail_optimize_servers(ngx_conf_t *cf, ngx_array_t *ports)
|
|
374
380
|
ls->log.data = &ls->addr_text;
|
375
381
|
ls->log.handler = ngx_accept_log_error;
|
376
382
|
|
383
|
+
ls->keepalive = addr[i].so_keepalive;
|
384
|
+
#if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
385
|
+
ls->keepidle = addr[i].tcp_keepidle;
|
386
|
+
ls->keepintvl = addr[i].tcp_keepintvl;
|
387
|
+
ls->keepcnt = addr[i].tcp_keepcnt;
|
388
|
+
#endif
|
389
|
+
|
377
390
|
#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
|
378
391
|
ls->ipv6only = addr[i].ipv6only;
|
379
392
|
#endif
|
@@ -40,6 +40,12 @@ typedef struct {
|
|
40
40
|
#endif
|
41
41
|
#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
|
42
42
|
unsigned ipv6only:2;
|
43
|
+
#endif
|
44
|
+
unsigned so_keepalive:2;
|
45
|
+
#if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
46
|
+
int tcp_keepidle;
|
47
|
+
int tcp_keepintvl;
|
48
|
+
int tcp_keepcnt;
|
43
49
|
#endif
|
44
50
|
} ngx_mail_listen_t;
|
45
51
|
|
@@ -95,6 +101,12 @@ typedef struct {
|
|
95
101
|
#endif
|
96
102
|
#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
|
97
103
|
unsigned ipv6only:2;
|
104
|
+
#endif
|
105
|
+
unsigned so_keepalive:2;
|
106
|
+
#if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
107
|
+
int tcp_keepidle;
|
108
|
+
int tcp_keepintvl;
|
109
|
+
int tcp_keepcnt;
|
98
110
|
#endif
|
99
111
|
} ngx_mail_conf_addr_t;
|
100
112
|
|
@@ -25,6 +25,12 @@ static char *ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
25
25
|
void *conf);
|
26
26
|
|
27
27
|
|
28
|
+
static ngx_conf_deprecated_t ngx_conf_deprecated_so_keepalive = {
|
29
|
+
ngx_conf_deprecated, "so_keepalive",
|
30
|
+
"so_keepalive\" parameter of the \"listen"
|
31
|
+
};
|
32
|
+
|
33
|
+
|
28
34
|
static ngx_command_t ngx_mail_core_commands[] = {
|
29
35
|
|
30
36
|
{ ngx_string("server"),
|
@@ -53,7 +59,7 @@ static ngx_command_t ngx_mail_core_commands[] = {
|
|
53
59
|
ngx_conf_set_flag_slot,
|
54
60
|
NGX_MAIL_SRV_CONF_OFFSET,
|
55
61
|
offsetof(ngx_mail_core_srv_conf_t, so_keepalive),
|
56
|
-
|
62
|
+
&ngx_conf_deprecated_so_keepalive },
|
57
63
|
|
58
64
|
{ ngx_string("timeout"),
|
59
65
|
NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
|
@@ -70,7 +76,7 @@ static ngx_command_t ngx_mail_core_commands[] = {
|
|
70
76
|
NULL },
|
71
77
|
|
72
78
|
{ ngx_string("resolver"),
|
73
|
-
NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|
|
79
|
+
NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE,
|
74
80
|
ngx_mail_core_resolver,
|
75
81
|
NGX_MAIL_SRV_CONF_OFFSET,
|
76
82
|
0,
|
@@ -447,6 +453,96 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
447
453
|
#endif
|
448
454
|
}
|
449
455
|
|
456
|
+
if (ngx_strncmp(value[i].data, "so_keepalive=", 13) == 0) {
|
457
|
+
|
458
|
+
if (ngx_strcmp(&value[i].data[13], "on") == 0) {
|
459
|
+
ls->so_keepalive = 1;
|
460
|
+
|
461
|
+
} else if (ngx_strcmp(&value[i].data[13], "off") == 0) {
|
462
|
+
ls->so_keepalive = 2;
|
463
|
+
|
464
|
+
} else {
|
465
|
+
|
466
|
+
#if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
467
|
+
u_char *p, *end;
|
468
|
+
ngx_str_t s;
|
469
|
+
|
470
|
+
end = value[i].data + value[i].len;
|
471
|
+
s.data = value[i].data + 13;
|
472
|
+
|
473
|
+
p = ngx_strlchr(s.data, end, ':');
|
474
|
+
if (p == NULL) {
|
475
|
+
p = end;
|
476
|
+
}
|
477
|
+
|
478
|
+
if (p > s.data) {
|
479
|
+
s.len = p - s.data;
|
480
|
+
|
481
|
+
ls->tcp_keepidle = ngx_parse_time(&s, 1);
|
482
|
+
if (ls->tcp_keepidle == (time_t) NGX_ERROR) {
|
483
|
+
goto invalid_so_keepalive;
|
484
|
+
}
|
485
|
+
}
|
486
|
+
|
487
|
+
s.data = (p < end) ? (p + 1) : end;
|
488
|
+
|
489
|
+
p = ngx_strlchr(s.data, end, ':');
|
490
|
+
if (p == NULL) {
|
491
|
+
p = end;
|
492
|
+
}
|
493
|
+
|
494
|
+
if (p > s.data) {
|
495
|
+
s.len = p - s.data;
|
496
|
+
|
497
|
+
ls->tcp_keepintvl = ngx_parse_time(&s, 1);
|
498
|
+
if (ls->tcp_keepintvl == (time_t) NGX_ERROR) {
|
499
|
+
goto invalid_so_keepalive;
|
500
|
+
}
|
501
|
+
}
|
502
|
+
|
503
|
+
s.data = (p < end) ? (p + 1) : end;
|
504
|
+
|
505
|
+
if (s.data < end) {
|
506
|
+
s.len = end - s.data;
|
507
|
+
|
508
|
+
ls->tcp_keepcnt = ngx_atoi(s.data, s.len);
|
509
|
+
if (ls->tcp_keepcnt == NGX_ERROR) {
|
510
|
+
goto invalid_so_keepalive;
|
511
|
+
}
|
512
|
+
}
|
513
|
+
|
514
|
+
if (ls->tcp_keepidle == 0 && ls->tcp_keepintvl == 0
|
515
|
+
&& ls->tcp_keepcnt == 0)
|
516
|
+
{
|
517
|
+
goto invalid_so_keepalive;
|
518
|
+
}
|
519
|
+
|
520
|
+
ls->so_keepalive = 1;
|
521
|
+
|
522
|
+
#else
|
523
|
+
|
524
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
525
|
+
"the \"so_keepalive\" parameter accepts "
|
526
|
+
"only \"on\" or \"off\" on this platform");
|
527
|
+
return NGX_CONF_ERROR;
|
528
|
+
|
529
|
+
#endif
|
530
|
+
}
|
531
|
+
|
532
|
+
ls->bind = 1;
|
533
|
+
|
534
|
+
continue;
|
535
|
+
|
536
|
+
#if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
537
|
+
invalid_so_keepalive:
|
538
|
+
|
539
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
540
|
+
"invalid so_keepalive value: \"%s\"",
|
541
|
+
&value[i].data[13]);
|
542
|
+
return NGX_CONF_ERROR;
|
543
|
+
#endif
|
544
|
+
}
|
545
|
+
|
450
546
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
451
547
|
"the invalid \"%V\" parameter", &value[i]);
|
452
548
|
return NGX_CONF_ERROR;
|
@@ -494,7 +590,6 @@ ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
494
590
|
{
|
495
591
|
ngx_mail_core_srv_conf_t *cscf = conf;
|
496
592
|
|
497
|
-
ngx_url_t u;
|
498
593
|
ngx_str_t *value;
|
499
594
|
|
500
595
|
value = cf->args->elts;
|
@@ -508,19 +603,9 @@ ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
508
603
|
return NGX_CONF_OK;
|
509
604
|
}
|
510
605
|
|
511
|
-
|
512
|
-
|
513
|
-
u.host = value[1];
|
514
|
-
u.port = 53;
|
515
|
-
|
516
|
-
if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) {
|
517
|
-
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V: %s", &u.host, u.err);
|
518
|
-
return NGX_CONF_ERROR;
|
519
|
-
}
|
520
|
-
|
521
|
-
cscf->resolver = ngx_resolver_create(cf, &u.addrs[0]);
|
606
|
+
cscf->resolver = ngx_resolver_create(cf, &value[1], cf->args->nelts - 1);
|
522
607
|
if (cscf->resolver == NULL) {
|
523
|
-
return
|
608
|
+
return NGX_CONF_ERROR;
|
524
609
|
}
|
525
610
|
|
526
611
|
return NGX_CONF_OK;
|