nginxtra 1.6.3.9 → 1.8.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nginxtra +1 -1
  3. data/bin/nginxtra_rails +1 -1
  4. data/lib/nginxtra/version.rb +1 -1
  5. data/vendor/nginx/CHANGES +358 -14
  6. data/vendor/nginx/CHANGES.ru +372 -18
  7. data/vendor/nginx/LICENSE +2 -2
  8. data/vendor/nginx/auto/cc/clang +5 -0
  9. data/vendor/nginx/auto/cc/gcc +5 -0
  10. data/vendor/nginx/auto/lib/google-perftools/conf +1 -1
  11. data/vendor/nginx/auto/lib/openssl/make +0 -5
  12. data/vendor/nginx/auto/lib/perl/conf +9 -1
  13. data/vendor/nginx/auto/make +1 -1
  14. data/vendor/nginx/auto/modules +11 -0
  15. data/vendor/nginx/auto/options +10 -2
  16. data/vendor/nginx/auto/os/darwin +0 -1
  17. data/vendor/nginx/auto/os/freebsd +6 -23
  18. data/vendor/nginx/auto/sources +16 -14
  19. data/vendor/nginx/auto/summary +3 -24
  20. data/vendor/nginx/auto/threads +20 -0
  21. data/vendor/nginx/auto/types/sizeof +2 -12
  22. data/vendor/nginx/auto/unix +50 -6
  23. data/vendor/nginx/configure +5 -0
  24. data/vendor/nginx/contrib/vim/syntax/nginx.vim +183 -50
  25. data/vendor/nginx/src/core/nginx.c +21 -9
  26. data/vendor/nginx/src/core/nginx.h +8 -2
  27. data/vendor/nginx/src/core/ngx_buf.c +88 -0
  28. data/vendor/nginx/src/core/ngx_buf.h +15 -1
  29. data/vendor/nginx/src/core/ngx_conf_file.c +4 -1
  30. data/vendor/nginx/src/core/ngx_connection.c +25 -66
  31. data/vendor/nginx/src/core/ngx_connection.h +1 -3
  32. data/vendor/nginx/src/core/ngx_core.h +11 -3
  33. data/vendor/nginx/src/core/ngx_crypt.c +1 -1
  34. data/vendor/nginx/src/core/ngx_cycle.c +7 -1
  35. data/vendor/nginx/src/core/ngx_cycle.h +6 -2
  36. data/vendor/nginx/src/core/ngx_file.c +13 -5
  37. data/vendor/nginx/src/core/ngx_file.h +6 -0
  38. data/vendor/nginx/src/core/ngx_log.c +215 -21
  39. data/vendor/nginx/src/core/ngx_log.h +9 -1
  40. data/vendor/nginx/src/core/ngx_output_chain.c +104 -15
  41. data/vendor/nginx/src/core/ngx_palloc.c +3 -7
  42. data/vendor/nginx/src/core/ngx_rbtree.c +2 -4
  43. data/vendor/nginx/src/core/ngx_rbtree.h +2 -4
  44. data/vendor/nginx/src/core/ngx_regex.c +14 -6
  45. data/vendor/nginx/src/core/ngx_resolver.c +16 -23
  46. data/vendor/nginx/src/core/ngx_resolver.h +8 -7
  47. data/vendor/nginx/src/core/ngx_shmtx.c +1 -1
  48. data/vendor/nginx/src/core/ngx_slab.c +89 -2
  49. data/vendor/nginx/src/core/ngx_slab.h +3 -0
  50. data/vendor/nginx/src/core/ngx_string.c +58 -2
  51. data/vendor/nginx/src/core/ngx_string.h +1 -0
  52. data/vendor/nginx/src/core/ngx_syslog.c +374 -0
  53. data/vendor/nginx/src/core/ngx_syslog.h +30 -0
  54. data/vendor/nginx/src/core/ngx_thread_pool.c +630 -0
  55. data/vendor/nginx/src/core/ngx_thread_pool.h +36 -0
  56. data/vendor/nginx/src/core/ngx_times.c +19 -2
  57. data/vendor/nginx/src/core/ngx_times.h +1 -0
  58. data/vendor/nginx/src/event/modules/ngx_aio_module.c +1 -1
  59. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +9 -24
  60. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +152 -28
  61. data/vendor/nginx/src/event/modules/ngx_eventport_module.c +43 -25
  62. data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +86 -156
  63. data/vendor/nginx/src/event/modules/ngx_poll_module.c +21 -37
  64. data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +15 -27
  65. data/vendor/nginx/src/event/modules/ngx_select_module.c +10 -12
  66. data/vendor/nginx/src/event/modules/ngx_win32_select_module.c +7 -9
  67. data/vendor/nginx/src/event/ngx_event.c +5 -33
  68. data/vendor/nginx/src/event/ngx_event.h +15 -50
  69. data/vendor/nginx/src/event/ngx_event_accept.c +11 -10
  70. data/vendor/nginx/src/event/ngx_event_connect.c +0 -11
  71. data/vendor/nginx/src/event/ngx_event_connect.h +1 -4
  72. data/vendor/nginx/src/event/ngx_event_openssl.c +622 -38
  73. data/vendor/nginx/src/event/ngx_event_openssl.h +20 -2
  74. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +5 -1
  75. data/vendor/nginx/src/event/ngx_event_pipe.c +45 -19
  76. data/vendor/nginx/src/event/ngx_event_pipe.h +3 -0
  77. data/vendor/nginx/src/event/ngx_event_posted.c +7 -145
  78. data/vendor/nginx/src/event/ngx_event_posted.h +12 -39
  79. data/vendor/nginx/src/event/ngx_event_timer.c +50 -70
  80. data/vendor/nginx/src/event/ngx_event_timer.h +2 -14
  81. data/vendor/nginx/src/http/modules/ngx_http_addition_filter_module.c +1 -1
  82. data/vendor/nginx/src/http/modules/ngx_http_autoindex_module.c +416 -71
  83. data/vendor/nginx/src/http/modules/ngx_http_charset_filter_module.c +19 -15
  84. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +16 -4
  85. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +601 -134
  86. data/vendor/nginx/src/http/modules/ngx_http_geo_module.c +1 -1
  87. data/vendor/nginx/src/http/modules/ngx_http_geoip_module.c +9 -3
  88. data/vendor/nginx/src/http/modules/ngx_http_gunzip_filter_module.c +9 -3
  89. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +9 -3
  90. data/vendor/nginx/src/http/modules/ngx_http_gzip_static_module.c +0 -2
  91. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +197 -91
  92. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +1 -0
  93. data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +65 -162
  94. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +53 -67
  95. data/vendor/nginx/src/http/modules/ngx_http_log_module.c +128 -23
  96. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +25 -6
  97. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +1 -1
  98. data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +39 -13
  99. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +697 -141
  100. data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +5 -1
  101. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +282 -125
  102. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +4 -1
  103. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +44 -1
  104. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.h +2 -0
  105. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +10 -8
  106. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +18 -3
  107. data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +641 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +1 -1
  109. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +3 -21
  110. data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +0 -5
  111. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +449 -125
  112. data/vendor/nginx/src/http/modules/ngx_http_xslt_filter_module.c +4 -2
  113. data/vendor/nginx/src/http/modules/perl/ngx_http_perl_module.c +2 -1
  114. data/vendor/nginx/src/http/ngx_http.c +10 -5
  115. data/vendor/nginx/src/http/ngx_http.h +4 -4
  116. data/vendor/nginx/src/http/ngx_http_cache.h +26 -1
  117. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +109 -68
  118. data/vendor/nginx/src/http/ngx_http_core_module.c +191 -46
  119. data/vendor/nginx/src/http/ngx_http_core_module.h +16 -4
  120. data/vendor/nginx/src/http/ngx_http_file_cache.c +584 -67
  121. data/vendor/nginx/src/http/ngx_http_parse.c +55 -4
  122. data/vendor/nginx/src/http/ngx_http_request.c +14 -6
  123. data/vendor/nginx/src/http/ngx_http_request.h +12 -4
  124. data/vendor/nginx/src/http/ngx_http_request_body.c +114 -28
  125. data/vendor/nginx/src/http/ngx_http_spdy.c +383 -229
  126. data/vendor/nginx/src/http/ngx_http_spdy.h +8 -5
  127. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +12 -4
  128. data/vendor/nginx/src/http/ngx_http_special_response.c +2 -2
  129. data/vendor/nginx/src/http/ngx_http_upstream.c +808 -132
  130. data/vendor/nginx/src/http/ngx_http_upstream.h +33 -3
  131. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +72 -65
  132. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +1 -2
  133. data/vendor/nginx/src/http/ngx_http_variables.c +47 -3
  134. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +15 -6
  135. data/vendor/nginx/src/mail/ngx_mail.c +2 -3
  136. data/vendor/nginx/src/mail/ngx_mail.h +2 -0
  137. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +140 -11
  138. data/vendor/nginx/src/mail/ngx_mail_core_module.c +3 -3
  139. data/vendor/nginx/src/mail/ngx_mail_handler.c +79 -2
  140. data/vendor/nginx/src/mail/ngx_mail_imap_module.c +3 -1
  141. data/vendor/nginx/src/mail/ngx_mail_pop3_module.c +3 -1
  142. data/vendor/nginx/src/mail/ngx_mail_smtp_module.c +3 -1
  143. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +125 -1
  144. data/vendor/nginx/src/mail/ngx_mail_ssl_module.h +8 -0
  145. data/vendor/nginx/src/misc/ngx_cpp_test_module.cpp +1 -1
  146. data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +1 -1
  147. data/vendor/nginx/src/os/unix/ngx_channel.c +0 -7
  148. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +0 -3
  149. data/vendor/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +44 -208
  150. data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +25 -17
  151. data/vendor/nginx/src/os/unix/ngx_files.c +109 -0
  152. data/vendor/nginx/src/os/unix/ngx_files.h +6 -0
  153. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +0 -6
  154. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +78 -206
  155. data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +25 -14
  156. data/vendor/nginx/src/os/unix/ngx_linux_config.h +4 -1
  157. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +235 -194
  158. data/vendor/nginx/src/os/unix/ngx_os.h +25 -3
  159. data/vendor/nginx/src/os/unix/ngx_posix_init.c +4 -2
  160. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +13 -195
  161. data/vendor/nginx/src/os/unix/ngx_process_cycle.h +0 -1
  162. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +27 -108
  163. data/vendor/nginx/src/os/unix/ngx_setproctitle.h +2 -2
  164. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +12 -67
  165. data/vendor/nginx/src/os/unix/ngx_thread.h +26 -83
  166. data/vendor/nginx/src/os/unix/ngx_thread_cond.c +87 -0
  167. data/vendor/nginx/src/os/unix/ngx_thread_id.c +70 -0
  168. data/vendor/nginx/src/os/unix/ngx_thread_mutex.c +174 -0
  169. data/vendor/nginx/src/os/unix/ngx_user.c +2 -20
  170. data/vendor/nginx/src/os/unix/ngx_writev_chain.c +129 -98
  171. metadata +16 -17
  172. data/vendor/nginx/auto/lib/zlib/patch.zlib.h +0 -10
  173. data/vendor/nginx/src/event/ngx_event_busy_lock.c +0 -286
  174. data/vendor/nginx/src/event/ngx_event_busy_lock.h +0 -65
  175. data/vendor/nginx/src/event/ngx_event_mutex.c +0 -70
  176. data/vendor/nginx/src/http/ngx_http_busy_lock.c +0 -307
  177. data/vendor/nginx/src/http/ngx_http_busy_lock.h +0 -54
  178. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +0 -756
  179. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +0 -122
  180. data/vendor/nginx/src/os/unix/ngx_pthread_thread.c +0 -278
  181. data/vendor/nginx/src/os/unix/rfork_thread.S +0 -73
@@ -231,7 +231,7 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
231
231
 
232
232
  next:
233
233
 
234
- if (++iphp->tries >= 20) {
234
+ if (++iphp->tries > 20) {
235
235
  return iphp->get_rr_peer(pc, &iphp->rrp);
236
236
  }
237
237
  }
@@ -79,7 +79,7 @@ static char *ngx_http_upstream_keepalive(ngx_conf_t *cf, ngx_command_t *cmd,
79
79
  static ngx_command_t ngx_http_upstream_keepalive_commands[] = {
80
80
 
81
81
  { ngx_string("keepalive"),
82
- NGX_HTTP_UPS_CONF|NGX_CONF_TAKE12,
82
+ NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1,
83
83
  ngx_http_upstream_keepalive,
84
84
  NGX_HTTP_SRV_CONF_OFFSET,
85
85
  0,
@@ -248,6 +248,7 @@ ngx_http_upstream_get_keepalive_peer(ngx_peer_connection_t *pc, void *data)
248
248
  "get keepalive peer: using connection %p", c);
249
249
 
250
250
  c->idle = 0;
251
+ c->sent = 0;
251
252
  c->log = pc->log;
252
253
  c->read->log = pc->log;
253
254
  c->write->log = pc->log;
@@ -386,7 +387,7 @@ ngx_http_upstream_keepalive_close_handler(ngx_event_t *ev)
386
387
  n = recv(c->fd, buf, 1, MSG_PEEK);
387
388
 
388
389
  if (n == -1 && ngx_socket_errno == NGX_EAGAIN) {
389
- /* stale event */
390
+ ev->ready = 0;
390
391
 
391
392
  if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
392
393
  goto close;
@@ -485,7 +486,6 @@ ngx_http_upstream_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
485
486
 
486
487
  ngx_int_t n;
487
488
  ngx_str_t *value;
488
- ngx_uint_t i;
489
489
 
490
490
  uscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_upstream_module);
491
491
 
@@ -514,23 +514,5 @@ ngx_http_upstream_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
514
514
 
515
515
  kcf->max_cached = n;
516
516
 
517
- for (i = 2; i < cf->args->nelts; i++) {
518
-
519
- if (ngx_strcmp(value[i].data, "single") == 0) {
520
- ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
521
- "the \"single\" parameter is deprecated");
522
- continue;
523
- }
524
-
525
- goto invalid;
526
- }
527
-
528
517
  return NGX_CONF_OK;
529
-
530
- invalid:
531
-
532
- ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
533
- "invalid parameter \"%V\"", &value[i]);
534
-
535
- return NGX_CONF_ERROR;
536
518
  }
@@ -299,10 +299,6 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
299
299
  lcp->rrp.tried[n] |= m;
300
300
  lcp->conns[p]++;
301
301
 
302
- if (pc->tries == 1 && peers->next) {
303
- pc->tries += peers->next->number;
304
- }
305
-
306
302
  return NGX_OK;
307
303
 
308
304
  failed:
@@ -314,7 +310,6 @@ failed:
314
310
  lcp->conns += peers->number;
315
311
 
316
312
  lcp->rrp.peers = peers->next;
317
- pc->tries = lcp->rrp.peers->number;
318
313
 
319
314
  n = (lcp->rrp.peers->number + (8 * sizeof(uintptr_t) - 1))
320
315
  / (8 * sizeof(uintptr_t));
@@ -13,15 +13,27 @@
13
13
 
14
14
 
15
15
  typedef struct {
16
- ngx_http_upstream_conf_t upstream;
16
+ ngx_array_t caches; /* ngx_http_file_cache_t * */
17
+ } ngx_http_uwsgi_main_conf_t;
18
+
17
19
 
20
+ typedef struct {
18
21
  ngx_array_t *flushes;
19
- ngx_array_t *params_len;
20
- ngx_array_t *params;
21
- ngx_array_t *params_source;
22
+ ngx_array_t *lengths;
23
+ ngx_array_t *values;
24
+ ngx_uint_t number;
25
+ ngx_hash_t hash;
26
+ } ngx_http_uwsgi_params_t;
22
27
 
23
- ngx_hash_t headers_hash;
24
- ngx_uint_t header_params;
28
+
29
+ typedef struct {
30
+ ngx_http_upstream_conf_t upstream;
31
+
32
+ ngx_http_uwsgi_params_t params;
33
+ #if (NGX_HTTP_CACHE)
34
+ ngx_http_uwsgi_params_t params_cache;
35
+ #endif
36
+ ngx_array_t *params_source;
25
37
 
26
38
  ngx_array_t *uwsgi_lengths;
27
39
  ngx_array_t *uwsgi_values;
@@ -39,6 +51,12 @@ typedef struct {
39
51
  ngx_uint_t ssl;
40
52
  ngx_uint_t ssl_protocols;
41
53
  ngx_str_t ssl_ciphers;
54
+ ngx_uint_t ssl_verify_depth;
55
+ ngx_str_t ssl_trusted_certificate;
56
+ ngx_str_t ssl_crl;
57
+ ngx_str_t ssl_certificate;
58
+ ngx_str_t ssl_certificate_key;
59
+ ngx_array_t *ssl_passwords;
42
60
  #endif
43
61
  } ngx_http_uwsgi_loc_conf_t;
44
62
 
@@ -53,11 +71,13 @@ static void ngx_http_uwsgi_abort_request(ngx_http_request_t *r);
53
71
  static void ngx_http_uwsgi_finalize_request(ngx_http_request_t *r,
54
72
  ngx_int_t rc);
55
73
 
74
+ static void *ngx_http_uwsgi_create_main_conf(ngx_conf_t *cf);
56
75
  static void *ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf);
57
76
  static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
58
77
  void *child);
59
- static ngx_int_t ngx_http_uwsgi_merge_params(ngx_conf_t *cf,
60
- ngx_http_uwsgi_loc_conf_t *conf, ngx_http_uwsgi_loc_conf_t *prev);
78
+ static ngx_int_t ngx_http_uwsgi_init_params(ngx_conf_t *cf,
79
+ ngx_http_uwsgi_loc_conf_t *conf, ngx_http_uwsgi_params_t *params,
80
+ ngx_keyval_t *default_params);
61
81
 
62
82
  static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
63
83
  void *conf);
@@ -73,6 +93,8 @@ static char *ngx_http_uwsgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd,
73
93
  #endif
74
94
 
75
95
  #if (NGX_HTTP_SSL)
96
+ static char *ngx_http_uwsgi_ssl_password_file(ngx_conf_t *cf,
97
+ ngx_command_t *cmd, void *conf);
76
98
  static ngx_int_t ngx_http_uwsgi_set_ssl(ngx_conf_t *cf,
77
99
  ngx_http_uwsgi_loc_conf_t *uwcf);
78
100
  #endif
@@ -158,6 +180,13 @@ static ngx_command_t ngx_http_uwsgi_commands[] = {
158
180
  offsetof(ngx_http_uwsgi_loc_conf_t, upstream.buffering),
159
181
  NULL },
160
182
 
183
+ { ngx_string("uwsgi_request_buffering"),
184
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
185
+ ngx_conf_set_flag_slot,
186
+ NGX_HTTP_LOC_CONF_OFFSET,
187
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.request_buffering),
188
+ NULL },
189
+
161
190
  { ngx_string("uwsgi_ignore_client_abort"),
162
191
  NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
163
192
  ngx_conf_set_flag_slot,
@@ -235,6 +264,20 @@ static ngx_command_t ngx_http_uwsgi_commands[] = {
235
264
  offsetof(ngx_http_uwsgi_loc_conf_t, upstream.busy_buffers_size_conf),
236
265
  NULL },
237
266
 
267
+ { ngx_string("uwsgi_force_ranges"),
268
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
269
+ ngx_conf_set_flag_slot,
270
+ NGX_HTTP_LOC_CONF_OFFSET,
271
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.force_ranges),
272
+ NULL },
273
+
274
+ { ngx_string("uwsgi_limit_rate"),
275
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
276
+ ngx_conf_set_size_slot,
277
+ NGX_HTTP_LOC_CONF_OFFSET,
278
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.limit_rate),
279
+ NULL },
280
+
238
281
  #if (NGX_HTTP_CACHE)
239
282
 
240
283
  { ngx_string("uwsgi_cache"),
@@ -254,8 +297,8 @@ static ngx_command_t ngx_http_uwsgi_commands[] = {
254
297
  { ngx_string("uwsgi_cache_path"),
255
298
  NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE,
256
299
  ngx_http_file_cache_set_slot,
257
- 0,
258
- 0,
300
+ NGX_HTTP_MAIN_CONF_OFFSET,
301
+ offsetof(ngx_http_uwsgi_main_conf_t, caches),
259
302
  &ngx_http_uwsgi_module },
260
303
 
261
304
  { ngx_string("uwsgi_cache_bypass"),
@@ -314,6 +357,13 @@ static ngx_command_t ngx_http_uwsgi_commands[] = {
314
357
  offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_lock_timeout),
315
358
  NULL },
316
359
 
360
+ { ngx_string("uwsgi_cache_lock_age"),
361
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
362
+ ngx_conf_set_msec_slot,
363
+ NGX_HTTP_LOC_CONF_OFFSET,
364
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.cache_lock_age),
365
+ NULL },
366
+
317
367
  { ngx_string("uwsgi_cache_revalidate"),
318
368
  NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
319
369
  ngx_conf_set_flag_slot,
@@ -351,6 +401,20 @@ static ngx_command_t ngx_http_uwsgi_commands[] = {
351
401
  offsetof(ngx_http_uwsgi_loc_conf_t, upstream.next_upstream),
352
402
  &ngx_http_uwsgi_next_upstream_masks },
353
403
 
404
+ { ngx_string("uwsgi_next_upstream_tries"),
405
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
406
+ ngx_conf_set_num_slot,
407
+ NGX_HTTP_LOC_CONF_OFFSET,
408
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.next_upstream_tries),
409
+ NULL },
410
+
411
+ { ngx_string("uwsgi_next_upstream_timeout"),
412
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
413
+ ngx_conf_set_msec_slot,
414
+ NGX_HTTP_LOC_CONF_OFFSET,
415
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.next_upstream_timeout),
416
+ NULL },
417
+
354
418
  { ngx_string("uwsgi_param"),
355
419
  NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23,
356
420
  ngx_http_upstream_param_set_slot,
@@ -409,6 +473,69 @@ static ngx_command_t ngx_http_uwsgi_commands[] = {
409
473
  offsetof(ngx_http_uwsgi_loc_conf_t, ssl_ciphers),
410
474
  NULL },
411
475
 
476
+ { ngx_string("uwsgi_ssl_name"),
477
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
478
+ ngx_http_set_complex_value_slot,
479
+ NGX_HTTP_LOC_CONF_OFFSET,
480
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.ssl_name),
481
+ NULL },
482
+
483
+ { ngx_string("uwsgi_ssl_server_name"),
484
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
485
+ ngx_conf_set_flag_slot,
486
+ NGX_HTTP_LOC_CONF_OFFSET,
487
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.ssl_server_name),
488
+ NULL },
489
+
490
+ { ngx_string("uwsgi_ssl_verify"),
491
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
492
+ ngx_conf_set_flag_slot,
493
+ NGX_HTTP_LOC_CONF_OFFSET,
494
+ offsetof(ngx_http_uwsgi_loc_conf_t, upstream.ssl_verify),
495
+ NULL },
496
+
497
+ { ngx_string("uwsgi_ssl_verify_depth"),
498
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
499
+ ngx_conf_set_num_slot,
500
+ NGX_HTTP_LOC_CONF_OFFSET,
501
+ offsetof(ngx_http_uwsgi_loc_conf_t, ssl_verify_depth),
502
+ NULL },
503
+
504
+ { ngx_string("uwsgi_ssl_trusted_certificate"),
505
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
506
+ ngx_conf_set_str_slot,
507
+ NGX_HTTP_LOC_CONF_OFFSET,
508
+ offsetof(ngx_http_uwsgi_loc_conf_t, ssl_trusted_certificate),
509
+ NULL },
510
+
511
+ { ngx_string("uwsgi_ssl_crl"),
512
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
513
+ ngx_conf_set_str_slot,
514
+ NGX_HTTP_LOC_CONF_OFFSET,
515
+ offsetof(ngx_http_uwsgi_loc_conf_t, ssl_crl),
516
+ NULL },
517
+
518
+ { ngx_string("uwsgi_ssl_certificate"),
519
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
520
+ ngx_conf_set_str_slot,
521
+ NGX_HTTP_LOC_CONF_OFFSET,
522
+ offsetof(ngx_http_uwsgi_loc_conf_t, ssl_certificate),
523
+ NULL },
524
+
525
+ { ngx_string("uwsgi_ssl_certificate_key"),
526
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
527
+ ngx_conf_set_str_slot,
528
+ NGX_HTTP_LOC_CONF_OFFSET,
529
+ offsetof(ngx_http_uwsgi_loc_conf_t, ssl_certificate_key),
530
+ NULL },
531
+
532
+ { ngx_string("uwsgi_ssl_password_file"),
533
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
534
+ ngx_http_uwsgi_ssl_password_file,
535
+ NGX_HTTP_LOC_CONF_OFFSET,
536
+ 0,
537
+ NULL },
538
+
412
539
  #endif
413
540
 
414
541
  ngx_null_command
@@ -419,7 +546,7 @@ static ngx_http_module_t ngx_http_uwsgi_module_ctx = {
419
546
  NULL, /* preconfiguration */
420
547
  NULL, /* postconfiguration */
421
548
 
422
- NULL, /* create main configuration */
549
+ ngx_http_uwsgi_create_main_conf, /* create main configuration */
423
550
  NULL, /* init main configuration */
424
551
 
425
552
  NULL, /* create server configuration */
@@ -462,7 +589,7 @@ static ngx_keyval_t ngx_http_uwsgi_cache_headers[] = {
462
589
  { ngx_string("HTTP_IF_MODIFIED_SINCE"),
463
590
  ngx_string("$upstream_cache_last_modified") },
464
591
  { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") },
465
- { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") },
592
+ { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("$upstream_cache_etag") },
466
593
  { ngx_string("HTTP_IF_MATCH"), ngx_string("") },
467
594
  { ngx_string("HTTP_RANGE"), ngx_string("") },
468
595
  { ngx_string("HTTP_IF_RANGE"), ngx_string("") },
@@ -480,10 +607,13 @@ static ngx_path_init_t ngx_http_uwsgi_temp_path = {
480
607
  static ngx_int_t
481
608
  ngx_http_uwsgi_handler(ngx_http_request_t *r)
482
609
  {
483
- ngx_int_t rc;
484
- ngx_http_status_t *status;
485
- ngx_http_upstream_t *u;
486
- ngx_http_uwsgi_loc_conf_t *uwcf;
610
+ ngx_int_t rc;
611
+ ngx_http_status_t *status;
612
+ ngx_http_upstream_t *u;
613
+ ngx_http_uwsgi_loc_conf_t *uwcf;
614
+ #if (NGX_HTTP_CACHE)
615
+ ngx_http_uwsgi_main_conf_t *uwmcf;
616
+ #endif
487
617
 
488
618
  if (ngx_http_upstream_create(r) != NGX_OK) {
489
619
  return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -526,8 +656,12 @@ ngx_http_uwsgi_handler(ngx_http_request_t *r)
526
656
  u->conf = &uwcf->upstream;
527
657
 
528
658
  #if (NGX_HTTP_CACHE)
659
+ uwmcf = ngx_http_get_module_main_conf(r, ngx_http_uwsgi_module);
660
+
661
+ u->caches = &uwmcf->caches;
529
662
  u->create_key = ngx_http_uwsgi_create_key;
530
663
  #endif
664
+
531
665
  u->create_request = ngx_http_uwsgi_create_request;
532
666
  u->reinit_request = ngx_http_uwsgi_reinit_request;
533
667
  u->process_header = ngx_http_uwsgi_process_status_line;
@@ -545,6 +679,13 @@ ngx_http_uwsgi_handler(ngx_http_request_t *r)
545
679
  u->pipe->input_filter = ngx_event_pipe_copy_input_filter;
546
680
  u->pipe->input_ctx = r;
547
681
 
682
+ if (!uwcf->upstream.request_buffering
683
+ && uwcf->upstream.pass_request_body
684
+ && !r->headers_in.chunked)
685
+ {
686
+ r->request_body_no_buffering = 1;
687
+ }
688
+
548
689
  rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init);
549
690
 
550
691
  if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
@@ -673,6 +814,7 @@ ngx_http_uwsgi_create_request(ngx_http_request_t *r)
673
814
  ngx_chain_t *cl, *body;
674
815
  ngx_list_part_t *part;
675
816
  ngx_table_elt_t *header, **ignored;
817
+ ngx_http_uwsgi_params_t *params;
676
818
  ngx_http_script_code_pt code;
677
819
  ngx_http_script_engine_t e, le;
678
820
  ngx_http_uwsgi_loc_conf_t *uwcf;
@@ -684,13 +826,19 @@ ngx_http_uwsgi_create_request(ngx_http_request_t *r)
684
826
 
685
827
  uwcf = ngx_http_get_module_loc_conf(r, ngx_http_uwsgi_module);
686
828
 
687
- if (uwcf->params_len) {
829
+ #if (NGX_HTTP_CACHE)
830
+ params = r->upstream->cacheable ? &uwcf->params_cache : &uwcf->params;
831
+ #else
832
+ params = &uwcf->params;
833
+ #endif
834
+
835
+ if (params->lengths) {
688
836
  ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
689
837
 
690
- ngx_http_script_flush_no_cacheable_variables(r, uwcf->flushes);
838
+ ngx_http_script_flush_no_cacheable_variables(r, params->flushes);
691
839
  le.flushed = 1;
692
840
 
693
- le.ip = uwcf->params_len->elts;
841
+ le.ip = params->lengths->elts;
694
842
  le.request = r;
695
843
 
696
844
  while (*(uintptr_t *) le.ip) {
@@ -719,7 +867,7 @@ ngx_http_uwsgi_create_request(ngx_http_request_t *r)
719
867
  allocated = 0;
720
868
  lowcase_key = NULL;
721
869
 
722
- if (uwcf->header_params) {
870
+ if (params->number) {
723
871
  n = 0;
724
872
  part = &r->headers_in.headers.part;
725
873
 
@@ -749,7 +897,7 @@ ngx_http_uwsgi_create_request(ngx_http_request_t *r)
749
897
  i = 0;
750
898
  }
751
899
 
752
- if (uwcf->header_params) {
900
+ if (params->number) {
753
901
  if (allocated < header[i].key.len) {
754
902
  allocated = header[i].key.len + 16;
755
903
  lowcase_key = ngx_pnalloc(r->pool, allocated);
@@ -774,7 +922,7 @@ ngx_http_uwsgi_create_request(ngx_http_request_t *r)
774
922
  lowcase_key[n] = ch;
775
923
  }
776
924
 
777
- if (ngx_hash_find(&uwcf->headers_hash, hash, lowcase_key, n)) {
925
+ if (ngx_hash_find(&params->hash, hash, lowcase_key, n)) {
778
926
  ignored[header_params++] = &header[i];
779
927
  continue;
780
928
  }
@@ -813,15 +961,15 @@ ngx_http_uwsgi_create_request(ngx_http_request_t *r)
813
961
  *b->last++ = (u_char) ((len >> 8) & 0xff);
814
962
  *b->last++ = (u_char) uwcf->modifier2;
815
963
 
816
- if (uwcf->params_len) {
964
+ if (params->lengths) {
817
965
  ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
818
966
 
819
- e.ip = uwcf->params->elts;
967
+ e.ip = params->values->elts;
820
968
  e.pos = b->last;
821
969
  e.request = r;
822
970
  e.flushed = 1;
823
971
 
824
- le.ip = uwcf->params_len->elts;
972
+ le.ip = params->lengths->elts;
825
973
 
826
974
  while (*(uintptr_t *) le.ip) {
827
975
 
@@ -934,7 +1082,10 @@ ngx_http_uwsgi_create_request(ngx_http_request_t *r)
934
1082
  b->last = ngx_copy(b->last, uwcf->uwsgi_string.data,
935
1083
  uwcf->uwsgi_string.len);
936
1084
 
937
- if (uwcf->upstream.pass_request_body) {
1085
+ if (r->request_body_no_buffering) {
1086
+ r->upstream->request_bufs = cl;
1087
+
1088
+ } else if (uwcf->upstream.pass_request_body) {
938
1089
  body = r->upstream->request_bufs;
939
1090
  r->upstream->request_bufs = cl;
940
1091
 
@@ -1194,6 +1345,29 @@ ngx_http_uwsgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
1194
1345
  }
1195
1346
 
1196
1347
 
1348
+ static void *
1349
+ ngx_http_uwsgi_create_main_conf(ngx_conf_t *cf)
1350
+ {
1351
+ ngx_http_uwsgi_main_conf_t *conf;
1352
+
1353
+ conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_uwsgi_main_conf_t));
1354
+ if (conf == NULL) {
1355
+ return NULL;
1356
+ }
1357
+
1358
+ #if (NGX_HTTP_CACHE)
1359
+ if (ngx_array_init(&conf->caches, cf->pool, 4,
1360
+ sizeof(ngx_http_file_cache_t *))
1361
+ != NGX_OK)
1362
+ {
1363
+ return NULL;
1364
+ }
1365
+ #endif
1366
+
1367
+ return conf;
1368
+ }
1369
+
1370
+
1197
1371
  static void *
1198
1372
  ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf)
1199
1373
  {
@@ -1209,17 +1383,22 @@ ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf)
1209
1383
 
1210
1384
  conf->upstream.store = NGX_CONF_UNSET;
1211
1385
  conf->upstream.store_access = NGX_CONF_UNSET_UINT;
1386
+ conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;
1212
1387
  conf->upstream.buffering = NGX_CONF_UNSET;
1388
+ conf->upstream.request_buffering = NGX_CONF_UNSET;
1213
1389
  conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
1390
+ conf->upstream.force_ranges = NGX_CONF_UNSET;
1214
1391
 
1215
1392
  conf->upstream.local = NGX_CONF_UNSET_PTR;
1216
1393
 
1217
1394
  conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC;
1218
1395
  conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC;
1219
1396
  conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC;
1397
+ conf->upstream.next_upstream_timeout = NGX_CONF_UNSET_MSEC;
1220
1398
 
1221
1399
  conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE;
1222
1400
  conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE;
1401
+ conf->upstream.limit_rate = NGX_CONF_UNSET_SIZE;
1223
1402
 
1224
1403
  conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
1225
1404
  conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
@@ -1229,13 +1408,14 @@ ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf)
1229
1408
  conf->upstream.pass_request_body = NGX_CONF_UNSET;
1230
1409
 
1231
1410
  #if (NGX_HTTP_CACHE)
1232
- conf->upstream.cache = NGX_CONF_UNSET_PTR;
1411
+ conf->upstream.cache = NGX_CONF_UNSET;
1233
1412
  conf->upstream.cache_min_uses = NGX_CONF_UNSET_UINT;
1234
1413
  conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR;
1235
1414
  conf->upstream.no_cache = NGX_CONF_UNSET_PTR;
1236
1415
  conf->upstream.cache_valid = NGX_CONF_UNSET_PTR;
1237
1416
  conf->upstream.cache_lock = NGX_CONF_UNSET;
1238
1417
  conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC;
1418
+ conf->upstream.cache_lock_age = NGX_CONF_UNSET_MSEC;
1239
1419
  conf->upstream.cache_revalidate = NGX_CONF_UNSET;
1240
1420
  #endif
1241
1421
 
@@ -1243,8 +1423,13 @@ ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf)
1243
1423
  conf->upstream.pass_headers = NGX_CONF_UNSET_PTR;
1244
1424
 
1245
1425
  conf->upstream.intercept_errors = NGX_CONF_UNSET;
1426
+
1246
1427
  #if (NGX_HTTP_SSL)
1247
1428
  conf->upstream.ssl_session_reuse = NGX_CONF_UNSET;
1429
+ conf->upstream.ssl_server_name = NGX_CONF_UNSET;
1430
+ conf->upstream.ssl_verify = NGX_CONF_UNSET;
1431
+ conf->ssl_verify_depth = NGX_CONF_UNSET_UINT;
1432
+ conf->ssl_passwords = NGX_CONF_UNSET_PTR;
1248
1433
  #endif
1249
1434
 
1250
1435
  /* "uwsgi_cyclic_temp_file" is disabled */
@@ -1265,27 +1450,47 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1265
1450
  ngx_http_uwsgi_loc_conf_t *conf = child;
1266
1451
 
1267
1452
  size_t size;
1453
+ ngx_int_t rc;
1268
1454
  ngx_hash_init_t hash;
1269
1455
  ngx_http_core_loc_conf_t *clcf;
1270
1456
 
1271
- if (conf->upstream.store != 0) {
1457
+ #if (NGX_HTTP_CACHE)
1458
+
1459
+ if (conf->upstream.store > 0) {
1460
+ conf->upstream.cache = 0;
1461
+ }
1462
+
1463
+ if (conf->upstream.cache > 0) {
1464
+ conf->upstream.store = 0;
1465
+ }
1466
+
1467
+ #endif
1468
+
1469
+ if (conf->upstream.store == NGX_CONF_UNSET) {
1272
1470
  ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
1273
1471
 
1274
- if (conf->upstream.store_lengths == NULL) {
1275
- conf->upstream.store_lengths = prev->upstream.store_lengths;
1276
- conf->upstream.store_values = prev->upstream.store_values;
1277
- }
1472
+ conf->upstream.store_lengths = prev->upstream.store_lengths;
1473
+ conf->upstream.store_values = prev->upstream.store_values;
1278
1474
  }
1279
1475
 
1280
1476
  ngx_conf_merge_uint_value(conf->upstream.store_access,
1281
1477
  prev->upstream.store_access, 0600);
1282
1478
 
1479
+ ngx_conf_merge_uint_value(conf->upstream.next_upstream_tries,
1480
+ prev->upstream.next_upstream_tries, 0);
1481
+
1283
1482
  ngx_conf_merge_value(conf->upstream.buffering,
1284
1483
  prev->upstream.buffering, 1);
1285
1484
 
1485
+ ngx_conf_merge_value(conf->upstream.request_buffering,
1486
+ prev->upstream.request_buffering, 1);
1487
+
1286
1488
  ngx_conf_merge_value(conf->upstream.ignore_client_abort,
1287
1489
  prev->upstream.ignore_client_abort, 0);
1288
1490
 
1491
+ ngx_conf_merge_value(conf->upstream.force_ranges,
1492
+ prev->upstream.force_ranges, 0);
1493
+
1289
1494
  ngx_conf_merge_ptr_value(conf->upstream.local,
1290
1495
  prev->upstream.local, NULL);
1291
1496
 
@@ -1298,6 +1503,9 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1298
1503
  ngx_conf_merge_msec_value(conf->upstream.read_timeout,
1299
1504
  prev->upstream.read_timeout, 60000);
1300
1505
 
1506
+ ngx_conf_merge_msec_value(conf->upstream.next_upstream_timeout,
1507
+ prev->upstream.next_upstream_timeout, 0);
1508
+
1301
1509
  ngx_conf_merge_size_value(conf->upstream.send_lowat,
1302
1510
  prev->upstream.send_lowat, 0);
1303
1511
 
@@ -1305,6 +1513,9 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1305
1513
  prev->upstream.buffer_size,
1306
1514
  (size_t) ngx_pagesize);
1307
1515
 
1516
+ ngx_conf_merge_size_value(conf->upstream.limit_rate,
1517
+ prev->upstream.limit_rate, 0);
1518
+
1308
1519
 
1309
1520
  ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs,
1310
1521
  8, ngx_pagesize);
@@ -1386,7 +1597,8 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1386
1597
  }
1387
1598
 
1388
1599
  if (conf->upstream.max_temp_file_size != 0
1389
- && conf->upstream.max_temp_file_size < size) {
1600
+ && conf->upstream.max_temp_file_size < size)
1601
+ {
1390
1602
  ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1391
1603
  "\"uwsgi_max_temp_file_size\" must be equal to zero to disable "
1392
1604
  "temporary files usage or must be equal to or greater than "
@@ -1423,13 +1635,18 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1423
1635
 
1424
1636
  #if (NGX_HTTP_CACHE)
1425
1637
 
1426
- ngx_conf_merge_ptr_value(conf->upstream.cache,
1427
- prev->upstream.cache, NULL);
1638
+ if (conf->upstream.cache == NGX_CONF_UNSET) {
1639
+ ngx_conf_merge_value(conf->upstream.cache,
1640
+ prev->upstream.cache, 0);
1428
1641
 
1429
- if (conf->upstream.cache && conf->upstream.cache->data == NULL) {
1642
+ conf->upstream.cache_zone = prev->upstream.cache_zone;
1643
+ conf->upstream.cache_value = prev->upstream.cache_value;
1644
+ }
1645
+
1646
+ if (conf->upstream.cache_zone && conf->upstream.cache_zone->data == NULL) {
1430
1647
  ngx_shm_zone_t *shm_zone;
1431
1648
 
1432
- shm_zone = conf->upstream.cache;
1649
+ shm_zone = conf->upstream.cache_zone;
1433
1650
 
1434
1651
  ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1435
1652
  "\"uwsgi_cache\" zone \"%V\" is unknown",
@@ -1474,12 +1691,20 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1474
1691
  conf->cache_key = prev->cache_key;
1475
1692
  }
1476
1693
 
1694
+ if (conf->upstream.cache && conf->cache_key.value.data == NULL) {
1695
+ ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
1696
+ "no \"uwsgi_cache_key\" for \"uwsgi_cache\"");
1697
+ }
1698
+
1477
1699
  ngx_conf_merge_value(conf->upstream.cache_lock,
1478
1700
  prev->upstream.cache_lock, 0);
1479
1701
 
1480
1702
  ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout,
1481
1703
  prev->upstream.cache_lock_timeout, 5000);
1482
1704
 
1705
+ ngx_conf_merge_msec_value(conf->upstream.cache_lock_age,
1706
+ prev->upstream.cache_lock_age, 5000);
1707
+
1483
1708
  ngx_conf_merge_value(conf->upstream.cache_revalidate,
1484
1709
  prev->upstream.cache_revalidate, 0);
1485
1710
 
@@ -1494,6 +1719,7 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1494
1719
  prev->upstream.intercept_errors, 0);
1495
1720
 
1496
1721
  #if (NGX_HTTP_SSL)
1722
+
1497
1723
  ngx_conf_merge_value(conf->upstream.ssl_session_reuse,
1498
1724
  prev->upstream.ssl_session_reuse, 1);
1499
1725
 
@@ -1505,13 +1731,30 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1505
1731
  ngx_conf_merge_str_value(conf->ssl_ciphers, prev->ssl_ciphers,
1506
1732
  "DEFAULT");
1507
1733
 
1734
+ if (conf->upstream.ssl_name == NULL) {
1735
+ conf->upstream.ssl_name = prev->upstream.ssl_name;
1736
+ }
1737
+
1738
+ ngx_conf_merge_value(conf->upstream.ssl_server_name,
1739
+ prev->upstream.ssl_server_name, 0);
1740
+ ngx_conf_merge_value(conf->upstream.ssl_verify,
1741
+ prev->upstream.ssl_verify, 0);
1742
+ ngx_conf_merge_uint_value(conf->ssl_verify_depth,
1743
+ prev->ssl_verify_depth, 1);
1744
+ ngx_conf_merge_str_value(conf->ssl_trusted_certificate,
1745
+ prev->ssl_trusted_certificate, "");
1746
+ ngx_conf_merge_str_value(conf->ssl_crl, prev->ssl_crl, "");
1747
+
1748
+ ngx_conf_merge_str_value(conf->ssl_certificate,
1749
+ prev->ssl_certificate, "");
1750
+ ngx_conf_merge_str_value(conf->ssl_certificate_key,
1751
+ prev->ssl_certificate_key, "");
1752
+ ngx_conf_merge_ptr_value(conf->ssl_passwords, prev->ssl_passwords, NULL);
1753
+
1508
1754
  if (conf->ssl && ngx_http_uwsgi_set_ssl(cf, conf) != NGX_OK) {
1509
1755
  return NGX_CONF_ERROR;
1510
1756
  }
1511
1757
 
1512
- if (conf->upstream.ssl == NULL) {
1513
- conf->upstream.ssl = prev->upstream.ssl;
1514
- }
1515
1758
  #endif
1516
1759
 
1517
1760
  ngx_conf_merge_str_value(conf->uwsgi_string, prev->uwsgi_string, "");
@@ -1527,88 +1770,91 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1527
1770
  return NGX_CONF_ERROR;
1528
1771
  }
1529
1772
 
1530
- if (conf->upstream.upstream == NULL) {
1773
+ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
1774
+
1775
+ if (clcf->noname
1776
+ && conf->upstream.upstream == NULL && conf->uwsgi_lengths == NULL)
1777
+ {
1531
1778
  conf->upstream.upstream = prev->upstream.upstream;
1532
- }
1533
1779
 
1534
- if (conf->uwsgi_lengths == NULL) {
1535
1780
  conf->uwsgi_lengths = prev->uwsgi_lengths;
1536
1781
  conf->uwsgi_values = prev->uwsgi_values;
1782
+
1783
+ #if (NGX_HTTP_SSL)
1784
+ conf->upstream.ssl = prev->upstream.ssl;
1785
+ #endif
1537
1786
  }
1538
1787
 
1539
- if (conf->upstream.upstream || conf->uwsgi_lengths) {
1540
- clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
1541
- if (clcf->handler == NULL && clcf->lmt_excpt) {
1542
- clcf->handler = ngx_http_uwsgi_handler;
1543
- }
1788
+ if (clcf->lmt_excpt && clcf->handler == NULL
1789
+ && (conf->upstream.upstream || conf->uwsgi_lengths))
1790
+ {
1791
+ clcf->handler = ngx_http_uwsgi_handler;
1544
1792
  }
1545
1793
 
1546
1794
  ngx_conf_merge_uint_value(conf->modifier1, prev->modifier1, 0);
1547
1795
  ngx_conf_merge_uint_value(conf->modifier2, prev->modifier2, 0);
1548
1796
 
1549
- if (ngx_http_uwsgi_merge_params(cf, conf, prev) != NGX_OK) {
1797
+ if (conf->params_source == NULL) {
1798
+ conf->params = prev->params;
1799
+ #if (NGX_HTTP_CACHE)
1800
+ conf->params_cache = prev->params_cache;
1801
+ #endif
1802
+ conf->params_source = prev->params_source;
1803
+ }
1804
+
1805
+ rc = ngx_http_uwsgi_init_params(cf, conf, &conf->params, NULL);
1806
+ if (rc != NGX_OK) {
1550
1807
  return NGX_CONF_ERROR;
1551
1808
  }
1552
1809
 
1810
+ #if (NGX_HTTP_CACHE)
1811
+
1812
+ if (conf->upstream.cache) {
1813
+ rc = ngx_http_uwsgi_init_params(cf, conf, &conf->params_cache,
1814
+ ngx_http_uwsgi_cache_headers);
1815
+ if (rc != NGX_OK) {
1816
+ return NGX_CONF_ERROR;
1817
+ }
1818
+ }
1819
+
1820
+ #endif
1821
+
1553
1822
  return NGX_CONF_OK;
1554
1823
  }
1555
1824
 
1556
1825
 
1557
1826
  static ngx_int_t
1558
- ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1559
- ngx_http_uwsgi_loc_conf_t *prev)
1827
+ ngx_http_uwsgi_init_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1828
+ ngx_http_uwsgi_params_t *params, ngx_keyval_t *default_params)
1560
1829
  {
1561
1830
  u_char *p;
1562
1831
  size_t size;
1563
1832
  uintptr_t *code;
1564
1833
  ngx_uint_t i, nsrc;
1565
- ngx_array_t headers_names;
1566
- #if (NGX_HTTP_CACHE)
1567
- ngx_array_t params_merged;
1568
- #endif
1834
+ ngx_array_t headers_names, params_merged;
1835
+ ngx_keyval_t *h;
1569
1836
  ngx_hash_key_t *hk;
1570
1837
  ngx_hash_init_t hash;
1571
- ngx_http_upstream_param_t *src;
1838
+ ngx_http_upstream_param_t *src, *s;
1572
1839
  ngx_http_script_compile_t sc;
1573
1840
  ngx_http_script_copy_code_t *copy;
1574
1841
 
1575
- if (conf->params_source == NULL) {
1576
- conf->params_source = prev->params_source;
1577
-
1578
- if (prev->headers_hash.buckets
1579
- #if (NGX_HTTP_CACHE)
1580
- && ((conf->upstream.cache == NULL)
1581
- == (prev->upstream.cache == NULL))
1582
- #endif
1583
- )
1584
- {
1585
- conf->flushes = prev->flushes;
1586
- conf->params_len = prev->params_len;
1587
- conf->params = prev->params;
1588
- conf->headers_hash = prev->headers_hash;
1589
- conf->header_params = prev->header_params;
1590
-
1591
- return NGX_OK;
1592
- }
1842
+ if (params->hash.buckets) {
1843
+ return NGX_OK;
1593
1844
  }
1594
1845
 
1595
- if (conf->params_source == NULL
1596
- #if (NGX_HTTP_CACHE)
1597
- && (conf->upstream.cache == NULL)
1598
- #endif
1599
- )
1600
- {
1601
- conf->headers_hash.buckets = (void *) 1;
1846
+ if (conf->params_source == NULL && default_params == NULL) {
1847
+ params->hash.buckets = (void *) 1;
1602
1848
  return NGX_OK;
1603
1849
  }
1604
1850
 
1605
- conf->params_len = ngx_array_create(cf->pool, 64, 1);
1606
- if (conf->params_len == NULL) {
1851
+ params->lengths = ngx_array_create(cf->pool, 64, 1);
1852
+ if (params->lengths == NULL) {
1607
1853
  return NGX_ERROR;
1608
1854
  }
1609
1855
 
1610
- conf->params = ngx_array_create(cf->pool, 512, 1);
1611
- if (conf->params == NULL) {
1856
+ params->values = ngx_array_create(cf->pool, 512, 1);
1857
+ if (params->values == NULL) {
1612
1858
  return NGX_ERROR;
1613
1859
  }
1614
1860
 
@@ -1627,12 +1873,7 @@ ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1627
1873
  nsrc = 0;
1628
1874
  }
1629
1875
 
1630
- #if (NGX_HTTP_CACHE)
1631
-
1632
- if (conf->upstream.cache) {
1633
- ngx_keyval_t *h;
1634
- ngx_http_upstream_param_t *s;
1635
-
1876
+ if (default_params) {
1636
1877
  if (ngx_array_init(&params_merged, cf->temp_pool, 4,
1637
1878
  sizeof(ngx_http_upstream_param_t))
1638
1879
  != NGX_OK)
@@ -1650,7 +1891,7 @@ ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1650
1891
  *s = src[i];
1651
1892
  }
1652
1893
 
1653
- h = ngx_http_uwsgi_cache_headers;
1894
+ h = default_params;
1654
1895
 
1655
1896
  while (h->key.len) {
1656
1897
 
@@ -1681,8 +1922,6 @@ ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1681
1922
  nsrc = params_merged.nelts;
1682
1923
  }
1683
1924
 
1684
- #endif
1685
-
1686
1925
  for (i = 0; i < nsrc; i++) {
1687
1926
 
1688
1927
  if (src[i].key.len > sizeof("HTTP_") - 1
@@ -1703,7 +1942,7 @@ ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1703
1942
  }
1704
1943
  }
1705
1944
 
1706
- copy = ngx_array_push_n(conf->params_len,
1945
+ copy = ngx_array_push_n(params->lengths,
1707
1946
  sizeof(ngx_http_script_copy_code_t));
1708
1947
  if (copy == NULL) {
1709
1948
  return NGX_ERROR;
@@ -1712,7 +1951,7 @@ ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1712
1951
  copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
1713
1952
  copy->len = src[i].key.len;
1714
1953
 
1715
- copy = ngx_array_push_n(conf->params_len,
1954
+ copy = ngx_array_push_n(params->lengths,
1716
1955
  sizeof(ngx_http_script_copy_code_t));
1717
1956
  if (copy == NULL) {
1718
1957
  return NGX_ERROR;
@@ -1726,7 +1965,7 @@ ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1726
1965
  + src[i].key.len + sizeof(uintptr_t) - 1)
1727
1966
  & ~(sizeof(uintptr_t) - 1);
1728
1967
 
1729
- copy = ngx_array_push_n(conf->params, size);
1968
+ copy = ngx_array_push_n(params->values, size);
1730
1969
  if (copy == NULL) {
1731
1970
  return NGX_ERROR;
1732
1971
  }
@@ -1742,15 +1981,15 @@ ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1742
1981
 
1743
1982
  sc.cf = cf;
1744
1983
  sc.source = &src[i].value;
1745
- sc.flushes = &conf->flushes;
1746
- sc.lengths = &conf->params_len;
1747
- sc.values = &conf->params;
1984
+ sc.flushes = &params->flushes;
1985
+ sc.lengths = &params->lengths;
1986
+ sc.values = &params->values;
1748
1987
 
1749
1988
  if (ngx_http_script_compile(&sc) != NGX_OK) {
1750
1989
  return NGX_ERROR;
1751
1990
  }
1752
1991
 
1753
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
1992
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
1754
1993
  if (code == NULL) {
1755
1994
  return NGX_ERROR;
1756
1995
  }
@@ -1758,7 +1997,7 @@ ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1758
1997
  *code = (uintptr_t) NULL;
1759
1998
 
1760
1999
 
1761
- code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
2000
+ code = ngx_array_push_n(params->values, sizeof(uintptr_t));
1762
2001
  if (code == NULL) {
1763
2002
  return NGX_ERROR;
1764
2003
  }
@@ -1766,16 +2005,16 @@ ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
1766
2005
  *code = (uintptr_t) NULL;
1767
2006
  }
1768
2007
 
1769
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
2008
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
1770
2009
  if (code == NULL) {
1771
2010
  return NGX_ERROR;
1772
2011
  }
1773
2012
 
1774
2013
  *code = (uintptr_t) NULL;
1775
2014
 
1776
- conf->header_params = headers_names.nelts;
2015
+ params->number = headers_names.nelts;
1777
2016
 
1778
- hash.hash = &conf->headers_hash;
2017
+ hash.hash = &params->hash;
1779
2018
  hash.key = ngx_hash_key_lc;
1780
2019
  hash.max_size = 512;
1781
2020
  hash.bucket_size = 64;
@@ -1803,7 +2042,7 @@ ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1803
2042
  return "is duplicate";
1804
2043
  }
1805
2044
 
1806
- clcf = ngx_http_conf_get_module_loc_conf (cf, ngx_http_core_module);
2045
+ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
1807
2046
  clcf->handler = ngx_http_uwsgi_handler;
1808
2047
 
1809
2048
  value = cf->args->elts;
@@ -1880,8 +2119,7 @@ ngx_http_uwsgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1880
2119
  ngx_str_t *value;
1881
2120
  ngx_http_script_compile_t sc;
1882
2121
 
1883
- if (uwcf->upstream.store != NGX_CONF_UNSET || uwcf->upstream.store_lengths)
1884
- {
2122
+ if (uwcf->upstream.store != NGX_CONF_UNSET) {
1885
2123
  return "is duplicate";
1886
2124
  }
1887
2125
 
@@ -1894,16 +2132,15 @@ ngx_http_uwsgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1894
2132
 
1895
2133
  #if (NGX_HTTP_CACHE)
1896
2134
 
1897
- if (uwcf->upstream.cache != NGX_CONF_UNSET_PTR
1898
- && uwcf->upstream.cache != NULL)
1899
- {
2135
+ if (uwcf->upstream.cache > 0) {
1900
2136
  return "is incompatible with \"uwsgi_cache\"";
1901
2137
  }
1902
2138
 
1903
2139
  #endif
1904
2140
 
2141
+ uwcf->upstream.store = 1;
2142
+
1905
2143
  if (ngx_strcmp(value[1].data, "on") == 0) {
1906
- uwcf->upstream.store = 1;
1907
2144
  return NGX_CONF_OK;
1908
2145
  }
1909
2146
 
@@ -1935,26 +2172,53 @@ ngx_http_uwsgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1935
2172
  {
1936
2173
  ngx_http_uwsgi_loc_conf_t *uwcf = conf;
1937
2174
 
1938
- ngx_str_t *value;
2175
+ ngx_str_t *value;
2176
+ ngx_http_complex_value_t cv;
2177
+ ngx_http_compile_complex_value_t ccv;
1939
2178
 
1940
2179
  value = cf->args->elts;
1941
2180
 
1942
- if (uwcf->upstream.cache != NGX_CONF_UNSET_PTR) {
2181
+ if (uwcf->upstream.cache != NGX_CONF_UNSET) {
1943
2182
  return "is duplicate";
1944
2183
  }
1945
2184
 
1946
2185
  if (ngx_strcmp(value[1].data, "off") == 0) {
1947
- uwcf->upstream.cache = NULL;
2186
+ uwcf->upstream.cache = 0;
1948
2187
  return NGX_CONF_OK;
1949
2188
  }
1950
2189
 
1951
- if (uwcf->upstream.store > 0 || uwcf->upstream.store_lengths) {
2190
+ if (uwcf->upstream.store > 0) {
1952
2191
  return "is incompatible with \"uwsgi_store\"";
1953
2192
  }
1954
2193
 
1955
- uwcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0,
1956
- &ngx_http_uwsgi_module);
1957
- if (uwcf->upstream.cache == NULL) {
2194
+ uwcf->upstream.cache = 1;
2195
+
2196
+ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
2197
+
2198
+ ccv.cf = cf;
2199
+ ccv.value = &value[1];
2200
+ ccv.complex_value = &cv;
2201
+
2202
+ if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
2203
+ return NGX_CONF_ERROR;
2204
+ }
2205
+
2206
+ if (cv.lengths != NULL) {
2207
+
2208
+ uwcf->upstream.cache_value = ngx_palloc(cf->pool,
2209
+ sizeof(ngx_http_complex_value_t));
2210
+ if (uwcf->upstream.cache_value == NULL) {
2211
+ return NGX_CONF_ERROR;
2212
+ }
2213
+
2214
+ *uwcf->upstream.cache_value = cv;
2215
+
2216
+ return NGX_CONF_OK;
2217
+ }
2218
+
2219
+ uwcf->upstream.cache_zone = ngx_shared_memory_add(cf, &value[1], 0,
2220
+ &ngx_http_uwsgi_module);
2221
+ if (uwcf->upstream.cache_zone == NULL) {
1958
2222
  return NGX_CONF_ERROR;
1959
2223
  }
1960
2224
 
@@ -1994,6 +2258,29 @@ ngx_http_uwsgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1994
2258
 
1995
2259
  #if (NGX_HTTP_SSL)
1996
2260
 
2261
+ static char *
2262
+ ngx_http_uwsgi_ssl_password_file(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
2263
+ {
2264
+ ngx_http_uwsgi_loc_conf_t *uwcf = conf;
2265
+
2266
+ ngx_str_t *value;
2267
+
2268
+ if (uwcf->ssl_passwords != NGX_CONF_UNSET_PTR) {
2269
+ return "is duplicate";
2270
+ }
2271
+
2272
+ value = cf->args->elts;
2273
+
2274
+ uwcf->ssl_passwords = ngx_ssl_read_password_file(cf, &value[1]);
2275
+
2276
+ if (uwcf->ssl_passwords == NULL) {
2277
+ return NGX_CONF_ERROR;
2278
+ }
2279
+
2280
+ return NGX_CONF_OK;
2281
+ }
2282
+
2283
+
1997
2284
  static ngx_int_t
1998
2285
  ngx_http_uwsgi_set_ssl(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *uwcf)
1999
2286
  {
@@ -2012,6 +2299,31 @@ ngx_http_uwsgi_set_ssl(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *uwcf)
2012
2299
  return NGX_ERROR;
2013
2300
  }
2014
2301
 
2302
+ cln = ngx_pool_cleanup_add(cf->pool, 0);
2303
+ if (cln == NULL) {
2304
+ return NGX_ERROR;
2305
+ }
2306
+
2307
+ cln->handler = ngx_ssl_cleanup_ctx;
2308
+ cln->data = uwcf->upstream.ssl;
2309
+
2310
+ if (uwcf->ssl_certificate.len) {
2311
+
2312
+ if (uwcf->ssl_certificate_key.len == 0) {
2313
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
2314
+ "no \"uwsgi_ssl_certificate_key\" is defined "
2315
+ "for certificate \"%V\"", &uwcf->ssl_certificate);
2316
+ return NGX_ERROR;
2317
+ }
2318
+
2319
+ if (ngx_ssl_certificate(cf, uwcf->upstream.ssl, &uwcf->ssl_certificate,
2320
+ &uwcf->ssl_certificate_key, uwcf->ssl_passwords)
2321
+ != NGX_OK)
2322
+ {
2323
+ return NGX_ERROR;
2324
+ }
2325
+ }
2326
+
2015
2327
  if (SSL_CTX_set_cipher_list(uwcf->upstream.ssl->ctx,
2016
2328
  (const char *) uwcf->ssl_ciphers.data)
2017
2329
  == 0)
@@ -2022,13 +2334,25 @@ ngx_http_uwsgi_set_ssl(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *uwcf)
2022
2334
  return NGX_ERROR;
2023
2335
  }
2024
2336
 
2025
- cln = ngx_pool_cleanup_add(cf->pool, 0);
2026
- if (cln == NULL) {
2027
- return NGX_ERROR;
2028
- }
2337
+ if (uwcf->upstream.ssl_verify) {
2338
+ if (uwcf->ssl_trusted_certificate.len == 0) {
2339
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
2340
+ "no uwsgi_ssl_trusted_certificate for uwsgi_ssl_verify");
2341
+ return NGX_ERROR;
2342
+ }
2029
2343
 
2030
- cln->handler = ngx_ssl_cleanup_ctx;
2031
- cln->data = uwcf->upstream.ssl;
2344
+ if (ngx_ssl_trusted_certificate(cf, uwcf->upstream.ssl,
2345
+ &uwcf->ssl_trusted_certificate,
2346
+ uwcf->ssl_verify_depth)
2347
+ != NGX_OK)
2348
+ {
2349
+ return NGX_ERROR;
2350
+ }
2351
+
2352
+ if (ngx_ssl_crl(cf, uwcf->upstream.ssl, &uwcf->ssl_crl) != NGX_OK) {
2353
+ return NGX_ERROR;
2354
+ }
2355
+ }
2032
2356
 
2033
2357
  return NGX_OK;
2034
2358
  }