nginxtra 1.4.7.9 → 1.6.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) 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 +286 -19
  6. data/vendor/nginx/CHANGES.ru +296 -22
  7. data/vendor/nginx/auto/cc/clang +4 -3
  8. data/vendor/nginx/auto/cc/conf +23 -0
  9. data/vendor/nginx/auto/cc/msvc +1 -0
  10. data/vendor/nginx/auto/cc/name +1 -1
  11. data/vendor/nginx/auto/cc/owc +4 -4
  12. data/vendor/nginx/auto/cc/sunc +1 -1
  13. data/vendor/nginx/auto/endianness +2 -2
  14. data/vendor/nginx/auto/feature +1 -1
  15. data/vendor/nginx/auto/include +1 -1
  16. data/vendor/nginx/auto/lib/libatomic/make +3 -1
  17. data/vendor/nginx/auto/lib/openssl/conf +4 -0
  18. data/vendor/nginx/auto/lib/openssl/make +1 -1
  19. data/vendor/nginx/auto/lib/pcre/conf +5 -0
  20. data/vendor/nginx/auto/lib/pcre/make +11 -11
  21. data/vendor/nginx/auto/lib/pcre/makefile.bcc +4 -3
  22. data/vendor/nginx/auto/lib/pcre/makefile.msvc +2 -1
  23. data/vendor/nginx/auto/lib/pcre/makefile.owc +2 -1
  24. data/vendor/nginx/auto/lib/perl/make +1 -0
  25. data/vendor/nginx/auto/lib/test +1 -1
  26. data/vendor/nginx/auto/lib/zlib/make +22 -1
  27. data/vendor/nginx/auto/modules +8 -0
  28. data/vendor/nginx/auto/options +3 -0
  29. data/vendor/nginx/auto/os/darwin +1 -1
  30. data/vendor/nginx/auto/os/linux +32 -0
  31. data/vendor/nginx/auto/os/win32 +12 -1
  32. data/vendor/nginx/auto/sources +8 -2
  33. data/vendor/nginx/auto/types/sizeof +1 -1
  34. data/vendor/nginx/auto/types/typedef +1 -1
  35. data/vendor/nginx/auto/types/uintptr_t +1 -1
  36. data/vendor/nginx/auto/unix +13 -1
  37. data/vendor/nginx/conf/mime.types +11 -2
  38. data/vendor/nginx/conf/nginx.conf +3 -4
  39. data/vendor/nginx/contrib/README +6 -0
  40. data/vendor/nginx/contrib/vim/ftdetect/nginx.vim +4 -0
  41. data/vendor/nginx/contrib/vim/indent/nginx.vim +11 -0
  42. data/vendor/nginx/contrib/vim/syntax/nginx.vim +703 -0
  43. data/vendor/nginx/src/core/nginx.c +2 -7
  44. data/vendor/nginx/src/core/nginx.h +2 -2
  45. data/vendor/nginx/src/core/ngx_conf_file.c +8 -88
  46. data/vendor/nginx/src/core/ngx_conf_file.h +3 -3
  47. data/vendor/nginx/src/core/ngx_config.h +2 -2
  48. data/vendor/nginx/src/core/ngx_connection.c +100 -29
  49. data/vendor/nginx/src/core/ngx_connection.h +11 -0
  50. data/vendor/nginx/src/core/ngx_core.h +1 -0
  51. data/vendor/nginx/src/core/ngx_cycle.c +23 -99
  52. data/vendor/nginx/src/core/ngx_cycle.h +2 -0
  53. data/vendor/nginx/src/core/ngx_file.c +100 -8
  54. data/vendor/nginx/src/core/ngx_file.h +3 -0
  55. data/vendor/nginx/src/core/ngx_hash.c +6 -9
  56. data/vendor/nginx/src/core/ngx_inet.c +93 -5
  57. data/vendor/nginx/src/core/ngx_inet.h +4 -2
  58. data/vendor/nginx/src/core/ngx_list.c +1 -9
  59. data/vendor/nginx/src/core/ngx_log.c +132 -30
  60. data/vendor/nginx/src/core/ngx_log.h +5 -2
  61. data/vendor/nginx/src/core/ngx_open_file_cache.c +67 -1
  62. data/vendor/nginx/src/core/ngx_palloc.c +5 -2
  63. data/vendor/nginx/src/core/ngx_proxy_protocol.c +91 -0
  64. data/vendor/nginx/src/core/ngx_proxy_protocol.h +23 -0
  65. data/vendor/nginx/src/core/ngx_resolver.c +1080 -285
  66. data/vendor/nginx/src/core/ngx_resolver.h +33 -3
  67. data/vendor/nginx/src/core/ngx_slab.c +7 -2
  68. data/vendor/nginx/src/core/ngx_slab.h +2 -0
  69. data/vendor/nginx/src/core/ngx_string.c +78 -13
  70. data/vendor/nginx/src/core/ngx_string.h +2 -0
  71. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +2 -2
  72. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +13 -5
  73. data/vendor/nginx/src/event/modules/ngx_select_module.c +1 -1
  74. data/vendor/nginx/src/event/modules/ngx_win32_select_module.c +2 -2
  75. data/vendor/nginx/src/event/ngx_event.c +0 -1
  76. data/vendor/nginx/src/event/ngx_event.h +7 -6
  77. data/vendor/nginx/src/event/ngx_event_accept.c +6 -4
  78. data/vendor/nginx/src/event/ngx_event_connect.c +2 -2
  79. data/vendor/nginx/src/event/ngx_event_openssl.c +304 -13
  80. data/vendor/nginx/src/event/ngx_event_openssl.h +20 -1
  81. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +35 -23
  82. data/vendor/nginx/src/event/ngx_event_pipe.c +15 -30
  83. data/vendor/nginx/src/http/modules/ngx_http_access_module.c +115 -35
  84. data/vendor/nginx/src/http/modules/ngx_http_auth_basic_module.c +1 -1
  85. data/vendor/nginx/src/http/modules/ngx_http_auth_request_module.c +444 -0
  86. data/vendor/nginx/src/http/modules/ngx_http_autoindex_module.c +2 -1
  87. data/vendor/nginx/src/http/modules/ngx_http_charset_filter_module.c +1 -1
  88. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +1 -3
  89. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +251 -36
  90. data/vendor/nginx/src/http/modules/ngx_http_gunzip_filter_module.c +9 -5
  91. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +5 -3
  92. data/vendor/nginx/src/http/modules/ngx_http_gzip_static_module.c +1 -1
  93. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +4 -0
  94. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +8 -2
  95. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +5 -1
  96. data/vendor/nginx/src/http/modules/ngx_http_map_module.c +3 -3
  97. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +21 -10
  98. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +669 -197
  99. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +93 -60
  100. data/vendor/nginx/src/http/modules/ngx_http_range_filter_module.c +13 -6
  101. data/vendor/nginx/src/http/modules/ngx_http_realip_module.c +20 -1
  102. data/vendor/nginx/src/http/modules/ngx_http_referer_module.c +132 -74
  103. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +18 -12
  104. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +22 -20
  105. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +121 -3
  106. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.h +5 -0
  107. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +3 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +123 -91
  109. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +29 -19
  110. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +2 -5
  111. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +215 -19
  112. data/vendor/nginx/src/http/modules/ngx_http_xslt_filter_module.c +32 -6
  113. data/vendor/nginx/src/http/modules/perl/nginx.xs +4 -7
  114. data/vendor/nginx/src/http/modules/perl/ngx_http_perl_module.c +2 -2
  115. data/vendor/nginx/src/http/ngx_http.c +17 -7
  116. data/vendor/nginx/src/http/ngx_http_cache.h +4 -2
  117. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +4 -2
  118. data/vendor/nginx/src/http/ngx_http_core_module.c +63 -50
  119. data/vendor/nginx/src/http/ngx_http_core_module.h +5 -0
  120. data/vendor/nginx/src/http/ngx_http_file_cache.c +115 -3
  121. data/vendor/nginx/src/http/ngx_http_header_filter_module.c +9 -6
  122. data/vendor/nginx/src/http/ngx_http_parse.c +88 -10
  123. data/vendor/nginx/src/http/ngx_http_postpone_filter_module.c +2 -4
  124. data/vendor/nginx/src/http/ngx_http_request.c +116 -8
  125. data/vendor/nginx/src/http/ngx_http_request.h +5 -1
  126. data/vendor/nginx/src/http/ngx_http_request_body.c +7 -7
  127. data/vendor/nginx/src/http/ngx_http_script.c +6 -5
  128. data/vendor/nginx/src/http/ngx_http_spdy.c +889 -271
  129. data/vendor/nginx/src/http/ngx_http_spdy.h +51 -28
  130. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +382 -167
  131. data/vendor/nginx/src/http/ngx_http_spdy_module.c +65 -8
  132. data/vendor/nginx/src/http/ngx_http_spdy_module.h +5 -0
  133. data/vendor/nginx/src/http/ngx_http_special_response.c +1 -1
  134. data/vendor/nginx/src/http/ngx_http_upstream.c +290 -114
  135. data/vendor/nginx/src/http/ngx_http_upstream.h +9 -5
  136. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +32 -24
  137. data/vendor/nginx/src/http/ngx_http_variables.c +40 -6
  138. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +12 -5
  139. data/vendor/nginx/src/mail/ngx_mail.c +4 -2
  140. data/vendor/nginx/src/mail/ngx_mail.h +2 -0
  141. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +0 -1
  142. data/vendor/nginx/src/mail/ngx_mail_core_module.c +2 -1
  143. data/vendor/nginx/src/mail/ngx_mail_handler.c +17 -4
  144. data/vendor/nginx/src/mail/ngx_mail_parse.c +32 -2
  145. data/vendor/nginx/src/mail/ngx_mail_proxy_module.c +54 -7
  146. data/vendor/nginx/src/mail/ngx_mail_smtp_handler.c +50 -78
  147. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +48 -11
  148. data/vendor/nginx/src/mail/ngx_mail_ssl_module.h +3 -0
  149. data/vendor/nginx/src/os/unix/ngx_channel.c +3 -1
  150. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +1 -0
  151. data/vendor/nginx/src/os/unix/ngx_darwin_init.c +1 -1
  152. data/vendor/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +14 -16
  153. data/vendor/nginx/src/os/unix/ngx_errno.h +3 -0
  154. data/vendor/nginx/src/os/unix/ngx_files.h +10 -16
  155. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +6 -0
  156. data/vendor/nginx/src/os/unix/ngx_freebsd_init.c +1 -1
  157. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +1 -1
  158. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +2 -2
  159. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +17 -19
  160. data/vendor/nginx/src/os/unix/ngx_linux_config.h +8 -2
  161. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +20 -22
  162. data/vendor/nginx/src/os/unix/ngx_posix_config.h +1 -0
  163. data/vendor/nginx/src/os/unix/ngx_process.c +5 -0
  164. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +15 -3
  165. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +2 -1
  166. data/vendor/nginx/src/os/unix/ngx_recv.c +4 -1
  167. data/vendor/nginx/src/os/unix/ngx_solaris_config.h +1 -0
  168. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +14 -16
  169. metadata +8 -2
@@ -261,13 +261,12 @@ header_in(r, key)
261
261
  sep = ';';
262
262
  goto multi;
263
263
  }
264
-
265
- #if (NGX_HTTP_X_FORWARDED_FOR)
264
+ #if (NGX_HTTP_X_FORWARDED_FOR)
266
265
  if (hh->offset == offsetof(ngx_http_headers_in_t, x_forwarded_for)) {
267
266
  sep = ',';
268
267
  goto multi;
269
268
  }
270
- #endif
269
+ #endif
271
270
 
272
271
  if (hh->offset) {
273
272
 
@@ -898,8 +897,7 @@ variable(r, name, value = NULL)
898
897
 
899
898
  var.len = len;
900
899
  var.data = lowcase;
901
-
902
- #if (NGX_DEBUG)
900
+ #if (NGX_DEBUG)
903
901
 
904
902
  if (value) {
905
903
  ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -908,8 +906,7 @@ variable(r, name, value = NULL)
908
906
  ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
909
907
  "perl variable: \"%V\"", &var);
910
908
  }
911
-
912
- #endif
909
+ #endif
913
910
 
914
911
  vv = ngx_http_get_variable(r, &var, hash);
915
912
  if (vv == NULL) {
@@ -421,7 +421,7 @@ ngx_http_perl_ssi(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ssi_ctx,
421
421
  return NGX_ERROR;
422
422
  }
423
423
 
424
- asv[0] = (SV *) i;
424
+ asv[0] = (SV *) (uintptr_t) i;
425
425
 
426
426
  for (i = 0; args[i]; i++) {
427
427
  asv[i + 1] = newSVpvn((char *) args[i]->data, args[i]->len);
@@ -692,7 +692,7 @@ ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, HV *nginx, SV *sub,
692
692
  if (args) {
693
693
  EXTEND(sp, (intptr_t) args[0]);
694
694
 
695
- for (i = 1; i <= (ngx_uint_t) args[0]; i++) {
695
+ for (i = 1; i <= (uintptr_t) args[0]; i++) {
696
696
  PUSHs(sv_2mortal(args[i]));
697
697
  }
698
698
  }
@@ -949,7 +949,8 @@ ngx_http_cmp_locations(const ngx_queue_t *one, const ngx_queue_t *two)
949
949
 
950
950
  #endif
951
951
 
952
- rc = ngx_strcmp(first->name.data, second->name.data);
952
+ rc = ngx_filename_cmp(first->name.data, second->name.data,
953
+ ngx_min(first->name.len, second->name.len) + 1);
953
954
 
954
955
  if (rc == 0 && !first->exact_match && second->exact_match) {
955
956
  /* an exact match must be before the same inclusive one */
@@ -975,8 +976,10 @@ ngx_http_join_exact_locations(ngx_conf_t *cf, ngx_queue_t *locations)
975
976
  lq = (ngx_http_location_queue_t *) q;
976
977
  lx = (ngx_http_location_queue_t *) x;
977
978
 
978
- if (ngx_strcmp(lq->name->data, lx->name->data) == 0) {
979
-
979
+ if (lq->name->len == lx->name->len
980
+ && ngx_filename_cmp(lq->name->data, lx->name->data, lx->name->len)
981
+ == 0)
982
+ {
980
983
  if ((lq->exact && lx->exact) || (lq->inclusive && lx->inclusive)) {
981
984
  ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
982
985
  "duplicate location \"%V\" in %s:%ui",
@@ -1028,7 +1031,7 @@ ngx_http_create_locations_list(ngx_queue_t *locations, ngx_queue_t *q)
1028
1031
  lx = (ngx_http_location_queue_t *) x;
1029
1032
 
1030
1033
  if (len > lx->name->len
1031
- || (ngx_strncmp(name, lx->name->data, len) != 0))
1034
+ || ngx_filename_cmp(name, lx->name->data, len) != 0)
1032
1035
  {
1033
1036
  break;
1034
1037
  }
@@ -1346,11 +1349,13 @@ ngx_http_add_address(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
1346
1349
  }
1347
1350
  }
1348
1351
 
1349
- #if (NGX_HTTP_SPDY && NGX_HTTP_SSL && !defined TLSEXT_TYPE_next_proto_neg)
1352
+ #if (NGX_HTTP_SPDY && NGX_HTTP_SSL \
1353
+ && !defined TLSEXT_TYPE_application_layer_protocol_negotiation \
1354
+ && !defined TLSEXT_TYPE_next_proto_neg)
1350
1355
  if (lsopt->spdy && lsopt->ssl) {
1351
1356
  ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
1352
- "nginx was built without OpenSSL NPN support, "
1353
- "SPDY is not enabled for %s", lsopt->addr);
1357
+ "nginx was built without OpenSSL ALPN or NPN "
1358
+ "support, SPDY is not enabled for %s", lsopt->addr);
1354
1359
  }
1355
1360
  #endif
1356
1361
 
@@ -1808,6 +1813,10 @@ ngx_http_add_listening(ngx_conf_t *cf, ngx_http_conf_addr_t *addr)
1808
1813
  ls->setfib = addr->opt.setfib;
1809
1814
  #endif
1810
1815
 
1816
+ #if (NGX_HAVE_TCP_FASTOPEN)
1817
+ ls->fastopen = addr->opt.fastopen;
1818
+ #endif
1819
+
1811
1820
  return ls;
1812
1821
  }
1813
1822
 
@@ -1840,6 +1849,7 @@ ngx_http_add_addrs(ngx_conf_t *cf, ngx_http_port_t *hport,
1840
1849
  #if (NGX_HTTP_SPDY)
1841
1850
  addrs[i].conf.spdy = addr[i].opt.spdy;
1842
1851
  #endif
1852
+ addrs[i].conf.proxy_protocol = addr[i].opt.proxy_protocol;
1843
1853
 
1844
1854
  if (addr[i].hash.buckets == NULL
1845
1855
  && (addr[i].wc_head == NULL
@@ -19,8 +19,9 @@
19
19
  #define NGX_HTTP_CACHE_EXPIRED 3
20
20
  #define NGX_HTTP_CACHE_STALE 4
21
21
  #define NGX_HTTP_CACHE_UPDATING 5
22
- #define NGX_HTTP_CACHE_HIT 6
23
- #define NGX_HTTP_CACHE_SCARCE 7
22
+ #define NGX_HTTP_CACHE_REVALIDATED 6
23
+ #define NGX_HTTP_CACHE_HIT 7
24
+ #define NGX_HTTP_CACHE_SCARCE 8
24
25
 
25
26
  #define NGX_HTTP_CACHE_KEY_LEN 16
26
27
 
@@ -143,6 +144,7 @@ void ngx_http_file_cache_create_key(ngx_http_request_t *r);
143
144
  ngx_int_t ngx_http_file_cache_open(ngx_http_request_t *r);
144
145
  void ngx_http_file_cache_set_header(ngx_http_request_t *r, u_char *buf);
145
146
  void ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf);
147
+ void ngx_http_file_cache_update_header(ngx_http_request_t *r);
146
148
  ngx_int_t ngx_http_cache_send(ngx_http_request_t *);
147
149
  void ngx_http_file_cache_free(ngx_http_cache_t *c, ngx_temp_file_t *tf);
148
150
  time_t ngx_http_file_cache_valid(ngx_array_t *cache_valid, ngx_uint_t status);
@@ -169,13 +169,15 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
169
169
  offset = c->busy_sendfile->file_pos;
170
170
 
171
171
  if (file->aio) {
172
- c->aio_sendfile = (offset != file->aio->last_offset);
172
+ c->busy_count = (offset == file->aio->last_offset) ?
173
+ c->busy_count + 1 : 0;
173
174
  file->aio->last_offset = offset;
174
175
 
175
- if (c->aio_sendfile == 0) {
176
+ if (c->busy_count > 2) {
176
177
  ngx_log_error(NGX_LOG_ALERT, c->log, 0,
177
178
  "sendfile(%V) returned busy again",
178
179
  &file->name);
180
+ c->aio_sendfile = 0;
179
181
  }
180
182
  }
181
183
 
@@ -1144,7 +1144,9 @@ ngx_http_core_access_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph)
1144
1144
  }
1145
1145
 
1146
1146
  if (rc == NGX_HTTP_FORBIDDEN || rc == NGX_HTTP_UNAUTHORIZED) {
1147
- r->access_code = rc;
1147
+ if (r->access_code != NGX_HTTP_UNAUTHORIZED) {
1148
+ r->access_code = rc;
1149
+ }
1148
1150
 
1149
1151
  r->phase_handler++;
1150
1152
  return NGX_AGAIN;
@@ -1933,6 +1935,12 @@ ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
1933
1935
  ngx_int_t
1934
1936
  ngx_http_send_header(ngx_http_request_t *r)
1935
1937
  {
1938
+ if (r->header_sent) {
1939
+ ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
1940
+ "header already sent");
1941
+ return NGX_ERROR;
1942
+ }
1943
+
1936
1944
  if (r->err_status) {
1937
1945
  r->headers_out.status = r->err_status;
1938
1946
  r->headers_out.status_line.len = 0;
@@ -2016,7 +2024,9 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
2016
2024
  return NULL;
2017
2025
  }
2018
2026
 
2019
- if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, path, 0) != NGX_OK) {
2027
+ if (ngx_get_full_name(r->pool, (ngx_str_t *) &ngx_cycle->prefix, path)
2028
+ != NGX_OK)
2029
+ {
2020
2030
  return NULL;
2021
2031
  }
2022
2032
 
@@ -2358,7 +2368,7 @@ equal:
2358
2368
  }
2359
2369
 
2360
2370
 
2361
- ngx_uint_t
2371
+ static ngx_uint_t
2362
2372
  ngx_http_gzip_quantity(u_char *p, u_char *last)
2363
2373
  {
2364
2374
  u_char c;
@@ -2622,6 +2632,14 @@ ngx_http_named_location(ngx_http_request_t *r, ngx_str_t *name)
2622
2632
  return NGX_DONE;
2623
2633
  }
2624
2634
 
2635
+ if (r->uri.len == 0) {
2636
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
2637
+ "empty URI in redirect to named location \"%V\"", name);
2638
+
2639
+ ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
2640
+ return NGX_DONE;
2641
+ }
2642
+
2625
2643
  cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
2626
2644
 
2627
2645
  if (cscf->named_locations) {
@@ -3030,10 +3048,13 @@ ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
3030
3048
  lsopt.sndbuf = -1;
3031
3049
  #if (NGX_HAVE_SETFIB)
3032
3050
  lsopt.setfib = -1;
3051
+ #endif
3052
+ #if (NGX_HAVE_TCP_FASTOPEN)
3053
+ lsopt.fastopen = -1;
3033
3054
  #endif
3034
3055
  lsopt.wildcard = 1;
3035
3056
 
3036
- (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.addr,
3057
+ (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.socklen, lsopt.addr,
3037
3058
  NGX_SOCKADDR_STRLEN, 1);
3038
3059
 
3039
3060
  if (ngx_http_add_listen(cf, cscf, &lsopt) != NGX_OK) {
@@ -3211,9 +3232,9 @@ ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
3211
3232
 
3212
3233
  #if (NGX_PCRE)
3213
3234
  if (clcf->regex == NULL
3214
- && ngx_strncmp(clcf->name.data, pclcf->name.data, len) != 0)
3235
+ && ngx_filename_cmp(clcf->name.data, pclcf->name.data, len) != 0)
3215
3236
  #else
3216
- if (ngx_strncmp(clcf->name.data, pclcf->name.data, len) != 0)
3237
+ if (ngx_filename_cmp(clcf->name.data, pclcf->name.data, len) != 0)
3217
3238
  #endif
3218
3239
  {
3219
3240
  ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
@@ -3411,25 +3432,16 @@ ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf)
3411
3432
  {
3412
3433
  ngx_http_core_main_conf_t *cmcf = conf;
3413
3434
 
3414
- if (cmcf->server_names_hash_max_size == NGX_CONF_UNSET_UINT) {
3415
- cmcf->server_names_hash_max_size = 512;
3416
- }
3417
-
3418
- if (cmcf->server_names_hash_bucket_size == NGX_CONF_UNSET_UINT) {
3419
- cmcf->server_names_hash_bucket_size = ngx_cacheline_size;
3420
- }
3435
+ ngx_conf_init_uint_value(cmcf->server_names_hash_max_size, 512);
3436
+ ngx_conf_init_uint_value(cmcf->server_names_hash_bucket_size,
3437
+ ngx_cacheline_size);
3421
3438
 
3422
3439
  cmcf->server_names_hash_bucket_size =
3423
3440
  ngx_align(cmcf->server_names_hash_bucket_size, ngx_cacheline_size);
3424
3441
 
3425
3442
 
3426
- if (cmcf->variables_hash_max_size == NGX_CONF_UNSET_UINT) {
3427
- cmcf->variables_hash_max_size = 512;
3428
- }
3429
-
3430
- if (cmcf->variables_hash_bucket_size == NGX_CONF_UNSET_UINT) {
3431
- cmcf->variables_hash_bucket_size = 64;
3432
- }
3443
+ ngx_conf_init_uint_value(cmcf->variables_hash_max_size, 1024);
3444
+ ngx_conf_init_uint_value(cmcf->variables_hash_bucket_size, 64);
3433
3445
 
3434
3446
  cmcf->variables_hash_bucket_size =
3435
3447
  ngx_align(cmcf->variables_hash_bucket_size, ngx_cacheline_size);
@@ -3698,8 +3710,7 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
3698
3710
  prev->types_hash_max_size, 1024);
3699
3711
 
3700
3712
  ngx_conf_merge_uint_value(conf->types_hash_bucket_size,
3701
- prev->types_hash_bucket_size,
3702
- ngx_cacheline_size);
3713
+ prev->types_hash_bucket_size, 64);
3703
3714
 
3704
3715
  conf->types_hash_bucket_size = ngx_align(conf->types_hash_bucket_size,
3705
3716
  ngx_cacheline_size);
@@ -3978,13 +3989,16 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
3978
3989
  lsopt.sndbuf = -1;
3979
3990
  #if (NGX_HAVE_SETFIB)
3980
3991
  lsopt.setfib = -1;
3992
+ #endif
3993
+ #if (NGX_HAVE_TCP_FASTOPEN)
3994
+ lsopt.fastopen = -1;
3981
3995
  #endif
3982
3996
  lsopt.wildcard = u.wildcard;
3983
3997
  #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
3984
3998
  lsopt.ipv6only = 1;
3985
3999
  #endif
3986
4000
 
3987
- (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.addr,
4001
+ (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.socklen, lsopt.addr,
3988
4002
  NGX_SOCKADDR_STRLEN, 1);
3989
4003
 
3990
4004
  for (n = 2; n < cf->args->nelts; n++) {
@@ -4005,6 +4019,8 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
4005
4019
  #if (NGX_HAVE_SETFIB)
4006
4020
  if (ngx_strncmp(value[n].data, "setfib=", 7) == 0) {
4007
4021
  lsopt.setfib = ngx_atoi(value[n].data + 7, value[n].len - 7);
4022
+ lsopt.set = 1;
4023
+ lsopt.bind = 1;
4008
4024
 
4009
4025
  if (lsopt.setfib == NGX_ERROR) {
4010
4026
  ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
@@ -4015,6 +4031,23 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
4015
4031
  continue;
4016
4032
  }
4017
4033
  #endif
4034
+
4035
+ #if (NGX_HAVE_TCP_FASTOPEN)
4036
+ if (ngx_strncmp(value[n].data, "fastopen=", 9) == 0) {
4037
+ lsopt.fastopen = ngx_atoi(value[n].data + 9, value[n].len - 9);
4038
+ lsopt.set = 1;
4039
+ lsopt.bind = 1;
4040
+
4041
+ if (lsopt.fastopen == NGX_ERROR) {
4042
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
4043
+ "invalid fastopen \"%V\"", &value[n]);
4044
+ return NGX_CONF_ERROR;
4045
+ }
4046
+
4047
+ continue;
4048
+ }
4049
+ #endif
4050
+
4018
4051
  if (ngx_strncmp(value[n].data, "backlog=", 8) == 0) {
4019
4052
  lsopt.backlog = ngx_atoi(value[n].data + 8, value[n].len - 8);
4020
4053
  lsopt.set = 1;
@@ -4244,6 +4277,11 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
4244
4277
  #endif
4245
4278
  }
4246
4279
 
4280
+ if (ngx_strcmp(value[n].data, "proxy_protocol") == 0) {
4281
+ lsopt.proxy_protocol = 1;
4282
+ continue;
4283
+ }
4284
+
4247
4285
  ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
4248
4286
  "invalid parameter \"%V\"", &value[n]);
4249
4287
  return NGX_CONF_ERROR;
@@ -4469,7 +4507,7 @@ static ngx_http_method_name_t ngx_methods_names[] = {
4469
4507
  { (u_char *) "COPY", (uint32_t) ~NGX_HTTP_COPY },
4470
4508
  { (u_char *) "MOVE", (uint32_t) ~NGX_HTTP_MOVE },
4471
4509
  { (u_char *) "OPTIONS", (uint32_t) ~NGX_HTTP_OPTIONS },
4472
- { (u_char *) "PROPFIND" , (uint32_t) ~NGX_HTTP_PROPFIND },
4510
+ { (u_char *) "PROPFIND", (uint32_t) ~NGX_HTTP_PROPFIND },
4473
4511
  { (u_char *) "PROPPATCH", (uint32_t) ~NGX_HTTP_PROPPATCH },
4474
4512
  { (u_char *) "LOCK", (uint32_t) ~NGX_HTTP_LOCK },
4475
4513
  { (u_char *) "UNLOCK", (uint32_t) ~NGX_HTTP_UNLOCK },
@@ -4890,32 +4928,7 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
4890
4928
  {
4891
4929
  ngx_http_core_loc_conf_t *clcf = conf;
4892
4930
 
4893
- ngx_str_t *value, name;
4894
-
4895
- if (clcf->error_log) {
4896
- return "is duplicate";
4897
- }
4898
-
4899
- value = cf->args->elts;
4900
-
4901
- if (ngx_strcmp(value[1].data, "stderr") == 0) {
4902
- ngx_str_null(&name);
4903
-
4904
- } else {
4905
- name = value[1];
4906
- }
4907
-
4908
- clcf->error_log = ngx_log_create(cf->cycle, &name);
4909
- if (clcf->error_log == NULL) {
4910
- return NGX_CONF_ERROR;
4911
- }
4912
-
4913
- if (cf->args->nelts == 2) {
4914
- clcf->error_log->log_level = NGX_LOG_ERR;
4915
- return NGX_CONF_OK;
4916
- }
4917
-
4918
- return ngx_log_set_levels(cf, clcf->error_log);
4931
+ return ngx_log_set_log(cf, &clcf->error_log);
4919
4932
  }
4920
4933
 
4921
4934
 
@@ -82,6 +82,7 @@ typedef struct {
82
82
  unsigned ipv6only:1;
83
83
  #endif
84
84
  unsigned so_keepalive:2;
85
+ unsigned proxy_protocol:1;
85
86
 
86
87
  int backlog;
87
88
  int rcvbuf;
@@ -89,6 +90,9 @@ typedef struct {
89
90
  #if (NGX_HAVE_SETFIB)
90
91
  int setfib;
91
92
  #endif
93
+ #if (NGX_HAVE_TCP_FASTOPEN)
94
+ int fastopen;
95
+ #endif
92
96
  #if (NGX_HAVE_KEEPALIVE_TUNABLE)
93
97
  int tcp_keepidle;
94
98
  int tcp_keepintvl;
@@ -240,6 +244,7 @@ struct ngx_http_addr_conf_s {
240
244
  #if (NGX_HTTP_SPDY)
241
245
  unsigned spdy:1;
242
246
  #endif
247
+ unsigned proxy_protocol:1;
243
248
  };
244
249
 
245
250
 
@@ -53,6 +53,7 @@ ngx_str_t ngx_http_cache_status[] = {
53
53
  ngx_string("EXPIRED"),
54
54
  ngx_string("STALE"),
55
55
  ngx_string("UPDATING"),
56
+ ngx_string("REVALIDATED"),
56
57
  ngx_string("HIT")
57
58
  };
58
59
 
@@ -445,8 +446,7 @@ ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev)
445
446
  timer = c->wait_time - ngx_current_msec;
446
447
 
447
448
  if ((ngx_msec_int_t) timer <= 0) {
448
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
449
- "http file cache lock timeout");
449
+ ngx_log_error(NGX_LOG_INFO, ev->log, 0, "cache lock timeout");
450
450
  c->lock = 0;
451
451
  goto wakeup;
452
452
  }
@@ -504,7 +504,7 @@ ngx_http_file_cache_read(ngx_http_request_t *r, ngx_http_cache_t *c)
504
504
  return NGX_DECLINED;
505
505
  }
506
506
 
507
- if (h->body_start > c->body_start) {
507
+ if ((size_t) h->body_start > c->body_start) {
508
508
  ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
509
509
  "cache file \"%s\" has too long header",
510
510
  c->file.name.data);
@@ -875,6 +875,8 @@ ngx_http_file_cache_set_header(ngx_http_request_t *r, u_char *buf)
875
875
 
876
876
  c = r->cache;
877
877
 
878
+ ngx_memzero(h, sizeof(ngx_http_file_cache_header_t));
879
+
878
880
  h->valid_sec = c->valid_sec;
879
881
  h->last_modified = c->last_modified;
880
882
  h->date = c->date;
@@ -970,6 +972,116 @@ ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf)
970
972
  }
971
973
 
972
974
 
975
+ void
976
+ ngx_http_file_cache_update_header(ngx_http_request_t *r)
977
+ {
978
+ ssize_t n;
979
+ ngx_err_t err;
980
+ ngx_file_t file;
981
+ ngx_file_info_t fi;
982
+ ngx_http_cache_t *c;
983
+ ngx_http_file_cache_header_t h;
984
+
985
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
986
+ "http file cache update header");
987
+
988
+ c = r->cache;
989
+
990
+ ngx_memzero(&file, sizeof(ngx_file_t));
991
+
992
+ file.name = c->file.name;
993
+ file.log = r->connection->log;
994
+ file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR, NGX_FILE_OPEN, 0);
995
+
996
+ if (file.fd == NGX_INVALID_FILE) {
997
+ err = ngx_errno;
998
+
999
+ /* cache file may have been deleted */
1000
+
1001
+ if (err == NGX_ENOENT) {
1002
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1003
+ "http file cache \"%s\" not found",
1004
+ file.name.data);
1005
+ return;
1006
+ }
1007
+
1008
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log, err,
1009
+ ngx_open_file_n " \"%s\" failed", file.name.data);
1010
+ return;
1011
+ }
1012
+
1013
+ /*
1014
+ * make sure cache file wasn't replaced;
1015
+ * if it was, do nothing
1016
+ */
1017
+
1018
+ if (ngx_fd_info(file.fd, &fi) == NGX_FILE_ERROR) {
1019
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
1020
+ ngx_fd_info_n " \"%s\" failed", file.name.data);
1021
+ goto done;
1022
+ }
1023
+
1024
+ if (c->uniq != ngx_file_uniq(&fi)
1025
+ || c->length != ngx_file_size(&fi))
1026
+ {
1027
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1028
+ "http file cache \"%s\" changed",
1029
+ file.name.data);
1030
+ goto done;
1031
+ }
1032
+
1033
+ n = ngx_read_file(&file, (u_char *) &h,
1034
+ sizeof(ngx_http_file_cache_header_t), 0);
1035
+
1036
+ if (n == NGX_ERROR) {
1037
+ goto done;
1038
+ }
1039
+
1040
+ if ((size_t) n != sizeof(ngx_http_file_cache_header_t)) {
1041
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
1042
+ ngx_read_file_n " read only %z of %z from \"%s\"",
1043
+ n, sizeof(ngx_http_file_cache_header_t), file.name.data);
1044
+ goto done;
1045
+ }
1046
+
1047
+ if (h.last_modified != c->last_modified
1048
+ || h.crc32 != c->crc32
1049
+ || h.header_start != c->header_start
1050
+ || h.body_start != c->body_start)
1051
+ {
1052
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1053
+ "http file cache \"%s\" content changed",
1054
+ file.name.data);
1055
+ goto done;
1056
+ }
1057
+
1058
+ /*
1059
+ * update cache file header with new data,
1060
+ * notably h.valid_sec and h.date
1061
+ */
1062
+
1063
+ ngx_memzero(&h, sizeof(ngx_http_file_cache_header_t));
1064
+
1065
+ h.valid_sec = c->valid_sec;
1066
+ h.last_modified = c->last_modified;
1067
+ h.date = c->date;
1068
+ h.crc32 = c->crc32;
1069
+ h.valid_msec = (u_short) c->valid_msec;
1070
+ h.header_start = (u_short) c->header_start;
1071
+ h.body_start = (u_short) c->body_start;
1072
+
1073
+ (void) ngx_write_file(&file, (u_char *) &h,
1074
+ sizeof(ngx_http_file_cache_header_t), 0);
1075
+
1076
+ done:
1077
+
1078
+ if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {
1079
+ ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
1080
+ ngx_close_file_n " \"%s\" failed", file.name.data);
1081
+ }
1082
+ }
1083
+
1084
+
973
1085
  ngx_int_t
974
1086
  ngx_http_cache_send(ngx_http_request_t *r)
975
1087
  {