]> git.kaiwu.me - nginx.git/log
nginx.git
8 years agoConfigure: fixed PCRE requirement check by ngx_http_rewrite_module.
Samuel Martin [Wed, 19 Jul 2017 09:05:50 +0000 (12:05 +0300)]
Configure: fixed PCRE requirement check by ngx_http_rewrite_module.

The http_rewrite module cannot be selected when http is disabled.
Fixed the PCRE check condition to avoid irrelevant check failure.
This is a regression from 4d874b4d82ed.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
8 years agoParenthesized ASCII-related calculations.
Valentin Bartenev [Mon, 17 Jul 2017 14:23:51 +0000 (17:23 +0300)]
Parenthesized ASCII-related calculations.

This also fixes potential undefined behaviour in the range and slice filter
modules, caused by local overflows of signed integers in expressions.

8 years agoStyle: aligned ngx_null_command.
Ruslan Ermilov [Wed, 12 Jul 2017 08:34:04 +0000 (11:34 +0300)]
Style: aligned ngx_null_command.

8 years agoCore: fixed error message on setsockopt(SO_REUSEPORT) failure.
Maxim Dounin [Tue, 11 Jul 2017 17:06:52 +0000 (20:06 +0300)]
Core: fixed error message on setsockopt(SO_REUSEPORT) failure.

The error is fatal when configuring a new socket, so the ", ignored" part
is not appropriate and was removed.

8 years agoCore: disabled SO_REUSEPORT when testing config (ticket #1300).
Maxim Dounin [Tue, 11 Jul 2017 16:59:56 +0000 (19:59 +0300)]
Core: disabled SO_REUSEPORT when testing config (ticket #1300).

When closing a socket with SO_REUSEPORT, Linux drops all connections waiting
in this socket's listen queue.  Previously, it was believed to only result
in connection resets when reconfiguring nginx to use smaller number of worker
processes.  It also results in connection resets during configuration
testing though.

Workaround is to avoid using SO_REUSEPORT when testing configuration.  It
should prevent listening sockets from being created if a conflicting socket
already exists, while still preserving detection of other possible errors.
It should also cover UDP sockets.

The only downside of this approach seems to be that a configuration testing
won't be able to properly report the case when nginx was compiled with
SO_REUSEPORT, but the kernel is not able to set it.  Such errors will be
reported on a real start instead.

8 years agoVersion bump.
Maxim Dounin [Tue, 11 Jul 2017 16:59:16 +0000 (19:59 +0300)]
Version bump.

8 years agorelease-1.13.3 tag
Maxim Dounin [Tue, 11 Jul 2017 13:18:31 +0000 (16:18 +0300)]
release-1.13.3 tag

8 years agonginx-1.13.3-RELEASE release-1.13.3
Maxim Dounin [Tue, 11 Jul 2017 13:18:30 +0000 (16:18 +0300)]
nginx-1.13.3-RELEASE

8 years agoRange filter: avoid negative range start.
Maxim Dounin [Tue, 11 Jul 2017 13:06:26 +0000 (16:06 +0300)]
Range filter: avoid negative range start.

Suffix ranges no longer allowed to set negative start values, to prevent
ranges with negative start from appearing even if total size protection
will be removed.

8 years agoRange filter: protect from total size overflows.
Maxim Dounin [Tue, 11 Jul 2017 13:06:23 +0000 (16:06 +0300)]
Range filter: protect from total size overflows.

The overflow can be used to circumvent the restriction on total size of
ranges introduced in c2a91088b0c0 (1.1.2).  Additionally, overflow
allows producing ranges with negative start (such ranges can be created
by using a suffix, "bytes=-100"; normally this results in 200 due to
the total size check).  These can result in the following errors in logs:

[crit] ... pread() ... failed (22: Invalid argument)
[alert] ... sendfile() failed (22: Invalid argument)

When using cache, it can be also used to reveal cache file header.
It is believed that there are no other negative effects, at least with
standard nginx modules.

In theory, this can also result in memory disclosure and/or segmentation
faults if multiple ranges are allowed, and the response is returned in a
single in-memory buffer.  This never happens with standard nginx modules
though, as well as known 3rd party modules.

Fix is to properly protect from possible overflow when incrementing size.

8 years agoVariables: use ngx_http_variable_null_value where appropriate.
Ruslan Ermilov [Fri, 7 Jul 2017 11:34:21 +0000 (14:34 +0300)]
Variables: use ngx_http_variable_null_value where appropriate.

8 years agoResolver: cancelable resend timer event.
Ruslan Ermilov [Tue, 4 Jul 2017 15:50:41 +0000 (18:50 +0300)]
Resolver: cancelable resend timer event.

It is safe because re-sending still works during graceful shutdown as
long as resolving takes place (and resolve tasks set their own timeouts
that are not cancelable).

Also, the new ctx->cancelable flag can be set to make resolve task's
timeout event cancelable.

8 years agoResolver: factored out setting a timer for resolver timeout.
Sergey Kandaurov [Tue, 4 Jul 2017 15:46:30 +0000 (18:46 +0300)]
Resolver: factored out setting a timer for resolver timeout.

No functional changes.

8 years agoSlab: fixed small allocations on systems with large pagesize.
Ruslan Ermilov [Tue, 4 Jul 2017 15:32:30 +0000 (18:32 +0300)]
Slab: fixed small allocations on systems with large pagesize.

Notably, on ppc64 with 64k pagesize, slab 0 (of size 8) requires
128 64-bit elements for bitmasks.  The code bogusly assumed that
one uintptr_t is enough for bitmasks plus at least one free slot.

8 years agoSlab: style.
Ruslan Ermilov [Tue, 4 Jul 2017 15:32:28 +0000 (18:32 +0300)]
Slab: style.

8 years agoResolver: fixed possible use-after-free while resolving SRV.
Roman Arutyunyan [Tue, 4 Jul 2017 15:07:29 +0000 (18:07 +0300)]
Resolver: fixed possible use-after-free while resolving SRV.

Resolving an SRV record includes resolving its host names in subrequests.
Previously, if memory allocation failed while reporting a subrequest result
after receiving a response from a DNS server, the SRV resolve handler was
called immediately with the NGX_ERROR state.  However, if the SRV record
included another copy of the resolved name, it was reported once again.
This could trigger the use-after-free memory access after SRV resolve
handler freed the resolve context by calling ngx_resolve_name_done().

Now the SRV resolve handler is called only when all its subrequests are
completed.

9 years agoProxy: split configured header names and values.
Piotr Sikora [Wed, 15 Mar 2017 22:55:35 +0000 (15:55 -0700)]
Proxy: split configured header names and values.

Previously, each configured header was represented in one of two ways,
depending on whether or not its value included any variables.

If the value didn't include any variables, then it would be represented
as as a single script that contained complete header line with HTTP/1.1
delimiters, i.e.:

     "Header: value\r\n"

But if the value included any variables, then it would be represented
as a series of three scripts: first contained header name and the ": "
delimiter, second evaluated to header value, and third contained only
"\r\n", i.e.:

     "Header: "
     "$value"
     "\r\n"

This commit changes that, so that each configured header is represented
as a series of two scripts: first contains only header name, and second
contains (or evaluates to) only header value, i.e.:

    "Header"
    "$value"

or

    "Header"
    "value"

This not only makes things more consistent, but also allows header name
and value to be accessed separately.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
8 years agoVersion bump.
Maxim Dounin [Mon, 3 Jul 2017 13:58:08 +0000 (16:58 +0300)]
Version bump.

8 years agorelease-1.13.2 tag
Maxim Dounin [Tue, 27 Jun 2017 14:44:18 +0000 (17:44 +0300)]
release-1.13.2 tag

8 years agonginx-1.13.2-RELEASE release-1.13.2
Maxim Dounin [Tue, 27 Jun 2017 14:44:17 +0000 (17:44 +0300)]
nginx-1.13.2-RELEASE

8 years agoRange filter: allowed ranges on empty files (ticket #1031).
Maxim Dounin [Mon, 26 Jun 2017 21:53:46 +0000 (00:53 +0300)]
Range filter: allowed ranges on empty files (ticket #1031).

As per RFC 2616 / RFC 7233, any range request to an empty file
is expected to result in 416 Range Not Satisfiable response, as
there cannot be a "byte-range-spec whose first-byte-pos is less
than the current length of the entity-body".  On the other hand,
this makes use of byte-range requests inconvenient in some cases,
as reported for the slice module here:

http://mailman.nginx.org/pipermail/nginx-devel/2017-June/010177.html

This commit changes range filter to instead return 200 if the file
is empty and the range requested starts at 0.

8 years agoUpstream: introduced ngx_http_upstream_ssl_handshake_handler().
Maxim Dounin [Thu, 22 Jun 2017 18:09:06 +0000 (21:09 +0300)]
Upstream: introduced ngx_http_upstream_ssl_handshake_handler().

This change reworks 13a5f4765887 to only run posted requests once,
with nothing on stack.  Running posted requests with other request
functions on stack may result in use-after-free in case of errors,
similar to the one reported in #788.

To only run posted request once, a separate function was introduced
to be used as ssl handshake handler in c->ssl->handler,
ngx_http_upstream_ssl_handshake_handler().  The ngx_http_run_posted_requests()
is only called in this function, and not in ngx_http_upstream_ssl_handshake()
which may be called directly on stack.

Additionaly, ngx_http_upstream_ssl_handshake_handler() now does appropriate
debug logging of the current subrequest, similar to what is done in other
event handlers.

8 years agoUpstream: fixed running posted requests (ticket #788).
Roman Arutyunyan [Wed, 14 Jun 2017 17:13:41 +0000 (20:13 +0300)]
Upstream: fixed running posted requests (ticket #788).

Previously, the upstream resolve handler always called
ngx_http_run_posted_requests() to run posted requests after processing the
resolver response.  However, if the handler was called directly from the
ngx_resolve_name() function (for example, if the resolver response was cached),
running posted requests from the handler could lead to the following errors:

- If the request was scheduled for termination, it could actually be terminated
in the resolve handler.  Upper stack frames could reference the freed request
object in this case.

- If a significant number of requests were posted, and for each of them the
resolve handler was called directly from the ngx_resolve_name() function,
posted requests could be run recursively and lead to stack overflow.

Now ngx_http_run_posted_requests() is only called from asynchronously invoked
resolve handlers.

8 years agoResolver: added the "async" flag to resolver context.
Roman Arutyunyan [Wed, 14 Jun 2017 15:13:31 +0000 (18:13 +0300)]
Resolver: added the "async" flag to resolver context.

The flag indicates that the resolve handler is called asynchronously after the
resolve function ngx_resolve_name()/ngx_resolve_addr() exited.

8 years agoResolver: fixed allocation error handling while resolving SRV.
Bart Warmerdam [Mon, 19 Jun 2017 11:25:42 +0000 (14:25 +0300)]
Resolver: fixed allocation error handling while resolving SRV.

8 years agoIntroduced ngx_rwlock_downgrade().
Ruslan Ermilov [Fri, 16 Jun 2017 15:15:58 +0000 (18:15 +0300)]
Introduced ngx_rwlock_downgrade().

8 years agoAdded memory barrier semantics to ngx_rwlock_unlock().
Ruslan Ermilov [Fri, 16 Jun 2017 15:15:53 +0000 (18:15 +0300)]
Added memory barrier semantics to ngx_rwlock_unlock().

9 years agoHeaders filter: added "add_trailer" directive.
Piotr Sikora [Fri, 24 Mar 2017 10:37:34 +0000 (03:37 -0700)]
Headers filter: added "add_trailer" directive.

Trailers added using this directive are evaluated after response body
is processed by output filters (but before it's written to the wire),
so it's possible to use variables calculated from the response body
as the trailer value.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
9 years agoHTTP/2: added support for trailers in HTTP responses.
Piotr Sikora [Fri, 24 Mar 2017 10:37:34 +0000 (03:37 -0700)]
HTTP/2: added support for trailers in HTTP responses.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
9 years agoAdded support for trailers in HTTP responses.
Piotr Sikora [Fri, 24 Mar 2017 10:37:34 +0000 (03:37 -0700)]
Added support for trailers in HTTP responses.

Example:

   ngx_table_elt_t  *h;

   h = ngx_list_push(&r->headers_out.trailers);
   if (h == NULL) {
       return NGX_ERROR;
   }

   ngx_str_set(&h->key, "Fun");
   ngx_str_set(&h->value, "with trailers");
   h->hash = ngx_hash_key_lc(h->key.data, h->key.len);

The code above adds "Fun: with trailers" trailer to the response.

Modules that want to emit trailers must set r->expect_trailers = 1
in header filter, otherwise they might not be emitted for HTTP/1.1
responses that aren't already chunked.

This change also adds $sent_trailer_* variables.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
8 years agoGzip: fixed style in $gzip_ratio variable handler.
Ruslan Ermilov [Wed, 14 Jun 2017 09:49:20 +0000 (12:49 +0300)]
Gzip: fixed style in $gzip_ratio variable handler.

The current style in variable handlers returning NGX_OK is to either set
v->not_found to 1, or to initialize the entire ngx_http_variable_value_t
structure.

In theory, always setting v->valid = 1 for NGX_OK would be useful, which
would mean that the value was computed and is thus valid, including the
special case of v->not_found = 1.  But currently that's not the case and
causes the (v->valid || v->not_found) check to access an uninitialized
v->valid value, which is safe only because its value doesn't matter when
v->not_found is set.

8 years agoRemoved excessive casts for ngx_file_info().
Ruslan Ermilov [Wed, 14 Jun 2017 09:29:52 +0000 (12:29 +0300)]
Removed excessive casts for ngx_file_info().

8 years agoConfigure: use .exe for binaries for all win32 compilers.
Orgad Shaneh [Tue, 6 Jun 2017 16:37:34 +0000 (19:37 +0300)]
Configure: use .exe for binaries for all win32 compilers.

8 years agoConfigure: fix compilation on MSYS2 / MinGW64.
Orgad Shaneh [Tue, 6 Jun 2017 15:13:39 +0000 (18:13 +0300)]
Configure: fix compilation on MSYS2 / MinGW64.

8 years agoHTTP/2: reject HTTP/2 requests without ":scheme" pseudo-header.
Piotr Sikora [Tue, 13 Jun 2017 14:01:08 +0000 (17:01 +0300)]
HTTP/2: reject HTTP/2 requests without ":scheme" pseudo-header.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
8 years agoUserid: ngx_http_get_indexed_variable() error handling.
Sergey Kandaurov [Wed, 7 Jun 2017 15:46:36 +0000 (18:46 +0300)]
Userid: ngx_http_get_indexed_variable() error handling.

When evaluating a mapped $reset_uid variable in the userid filter,
if get_handler set to ngx_http_map_variable() returned an error,
this previously resulted in a NULL pointer dereference.

8 years agoFixed segfault in try_files with nested location.
Sergey Kandaurov [Wed, 7 Jun 2017 15:46:35 +0000 (18:46 +0300)]
Fixed segfault in try_files with nested location.

If memory allocation of a new r->uri.data storage failed, reset its length as
well.  Request URI is used in ngx_http_finalize_request() for debug logging.

8 years agoSSI: return NGX_ERROR when timefmt memory allocation failed.
Sergey Kandaurov [Wed, 7 Jun 2017 12:21:42 +0000 (15:21 +0300)]
SSI: return NGX_ERROR when timefmt memory allocation failed.

Previously, when using NGX_HTTP_SSI_ERROR, error was ignored in ssi processing,
thus timefmt could be accessed later in ngx_http_ssi_date_gmt_local_variable()
as part of "set" handler, or NULL format pointer could be passed to strftime().

8 years agoHTTP/2: don't send SETTINGS ACK before already queued DATA frames.
Piotr Sikora [Fri, 2 Jun 2017 12:05:32 +0000 (15:05 +0300)]
HTTP/2: don't send SETTINGS ACK before already queued DATA frames.

Previously, SETTINGS ACK was sent immediately upon receipt of SETTINGS
frame, before already queued DATA frames created using old SETTINGS.

This incorrect behavior was source of interoperability issues, because
peers rely on the fact that new SETTINGS are in effect after receiving
SETTINGS ACK.

Reported by Feng Li.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
8 years agoHTTP/2: make SETTINGS ACK frame reusable.
Piotr Sikora [Fri, 2 Jun 2017 12:05:28 +0000 (15:05 +0300)]
HTTP/2: make SETTINGS ACK frame reusable.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
8 years agoHTTP/2: send SETTINGS ACK after applying all SETTINGS params.
Piotr Sikora [Fri, 2 Jun 2017 12:05:24 +0000 (15:05 +0300)]
HTTP/2: send SETTINGS ACK after applying all SETTINGS params.

This avoids sending unnecessary SETTINGS ACK in case of PROTOCOL_ERROR.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
8 years agoHTTP/2: emit new frames only after applying all SETTINGS params.
Piotr Sikora [Fri, 2 Jun 2017 12:05:20 +0000 (15:05 +0300)]
HTTP/2: emit new frames only after applying all SETTINGS params.

Previously, new frames could be emitted in the middle of applying
new (and already acknowledged) SETTINGS params, which is illegal.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
8 years agoConfigure: enabled rpath for NetBSD.
Sergey Kandaurov [Fri, 2 Jun 2017 09:55:31 +0000 (12:55 +0300)]
Configure: enabled rpath for NetBSD.

8 years agoConfigure: disabled IP_PKTINFO feature on certain platforms.
Roman Arutyunyan [Thu, 1 Jun 2017 12:44:23 +0000 (15:44 +0300)]
Configure: disabled IP_PKTINFO feature on certain platforms.

On Cygwin and NetBSD 7.0+ struct in_pktinfo has no ipi_spec_dst field, which
caused nginx compilation error.  Now presence of this field is ensured by the
IP_PKTINFO feature test.

The problem was introduced by dbb0c854e308 (1.13.0).

8 years agoStyle.
Maxim Dounin [Thu, 1 Jun 2017 13:49:14 +0000 (16:49 +0300)]
Style.

8 years agoUpstream: style.
Piotr Sikora [Wed, 31 May 2017 20:51:36 +0000 (13:51 -0700)]
Upstream: style.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
8 years agoHeaders filter: style.
Piotr Sikora [Wed, 31 May 2017 20:51:35 +0000 (13:51 -0700)]
Headers filter: style.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
8 years agoHTTP/2: add debug logging of pseudo-headers and cookies.
Piotr Sikora [Tue, 30 May 2017 14:42:27 +0000 (17:42 +0300)]
HTTP/2: add debug logging of pseudo-headers and cookies.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
8 years agoVersion bump.
Valentin Bartenev [Tue, 30 May 2017 16:29:45 +0000 (19:29 +0300)]
Version bump.

8 years agorelease-1.13.1 tag
Maxim Dounin [Tue, 30 May 2017 14:55:23 +0000 (17:55 +0300)]
release-1.13.1 tag

8 years agonginx-1.13.1-RELEASE release-1.13.1
Maxim Dounin [Tue, 30 May 2017 14:55:22 +0000 (17:55 +0300)]
nginx-1.13.1-RELEASE

8 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Tue, 30 May 2017 14:14:00 +0000 (17:14 +0300)]
Updated OpenSSL used for win32 builds.

8 years agoFixed background requests with asynchronous operations.
Roman Arutyunyan [Mon, 29 May 2017 20:33:38 +0000 (23:33 +0300)]
Fixed background requests with asynchronous operations.

If the main request was finalized while a background request performed an
asynchronous operation, the main request ended up in ngx_http_writer() and was
not finalized until a network event or a timeout.  For example, cache
background update with aio enabled made nginx unable to process further client
requests or close the connection, keeping it open until client closes it.

Now regular finalization of the main request is not suspended because of an
asynchronous operation in another request.

If a background request was terminated while an asynchronous operation was in
progress, background request's write event handler was changed to
ngx_http_request_finalizer() and never called again.

Now, whenever a request is terminated while an asynchronous operation is in
progress, connection error flag is set to make further finalizations of any
request with this connection lead to termination.

These issues appeared in 1aeaae6e9446 (not yet released).

8 years agoConfigure: sched_setaffinity() test moved to auto/unix.
Maxim Dounin [Mon, 29 May 2017 13:48:30 +0000 (16:48 +0300)]
Configure: sched_setaffinity() test moved to auto/unix.

The sched_setaffinity() function was introduced in DragonFly BSD 4.7,
so it is no longer Linux-specific.

Prodded by Sepherosa Ziehau.

8 years agoStyle: changed checks of ngx_ssl_create_connection() to != NGX_OK.
Maxim Dounin [Mon, 29 May 2017 13:34:35 +0000 (16:34 +0300)]
Style: changed checks of ngx_ssl_create_connection() to != NGX_OK.

In http these checks were changed in a6d6d762c554, though mail module
was missed at that time.  Since then, the stream module was introduced
based on mail, using "== NGX_ERROR" check.

8 years agoSSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin [Mon, 29 May 2017 13:34:29 +0000 (16:34 +0300)]
SSL: set TCP_NODELAY on SSL connections before handshake.

With OpenSSL 1.1.0+, the workaround for handshake buffer size as introduced
in a720f0b0e083 (ticket #413) no longer works, as OpenSSL no longer exposes
handshake buffers, see https://github.com/openssl/openssl/commit/2e7dc7cd688.
Moreover, it is no longer possible to adjust handshake buffers at all now.

To avoid additional RTT if handshake uses more than 4k we now set TCP_NODELAY
on SSL connections before handshake.  While this still results in sub-optimal
network utilization due to incomplete packets being sent, it seems to be
better than nothing.

8 years agoIntroduced ngx_tcp_nodelay().
Ruslan Ermilov [Fri, 26 May 2017 19:52:48 +0000 (22:52 +0300)]
Introduced ngx_tcp_nodelay().

8 years agoBackground subrequests for cache updates.
Roman Arutyunyan [Thu, 25 May 2017 12:57:59 +0000 (15:57 +0300)]
Background subrequests for cache updates.

Previously, cache background update might not work as expected, making client
wait for it to complete before receiving the final part of a stale response.
This could happen if the response could not be sent to the client socket in one
filter chain call.

Now background cache update is done in a background subrequest.  This type of
subrequest does not block any other subrequests or the main request.

8 years agoFixed deferred accept with EPOLLRDHUP enabled (ticket #1278).
Roman Arutyunyan [Wed, 24 May 2017 10:17:08 +0000 (13:17 +0300)]
Fixed deferred accept with EPOLLRDHUP enabled (ticket #1278).

Previously, the read event of the accepted connection was marked ready, but not
available.  This made EPOLLRDHUP-related code (for example, in ngx_unix_recv())
expect more data from the socket, leading to unexpected behavior.

For example, if SSL, PROXY protocol and deferred accept were enabled on a listen
socket, the client connection was aborted due to unexpected return value of
c->recv().

8 years agoHTTP/2: fixed segfault when memory allocation failed.
Valentin Bartenev [Tue, 23 May 2017 17:19:39 +0000 (20:19 +0300)]
HTTP/2: fixed segfault when memory allocation failed.

If allocation of cleanup handler in the HTTP/2 header filter failed, then
a stream might be freed with a HEADERS frame left in the output queue.

Now the HEADERS frame is accounted in the queue before trying to allocate
the cleanup handler.

8 years agoContrib: proper syntax parsing in vim syntax highlighting.
Maxim Dounin [Mon, 22 May 2017 13:34:47 +0000 (16:34 +0300)]
Contrib: proper syntax parsing in vim syntax highlighting.

Instead of highlighting directives in arbitrary positions, proper
parsing of nginx.conf syntax was implemented, matching what nginx does
internally.  This allows vim to correctly highlight various complex cases,
including:

    return 301 http://example.com/path#fragment";

and also avoids highlighting of parameters as directives, as in

    server_name missing.semicolon.example.com
    index index.php;

where "index" is not a directive but a parameter of the "server_name"
directive due to missing semicolon.

Most important downside of this approach seems to be that there is no
easy way to introduce directive-specific parameters.  As such, only "listen"
directive parameters were preserved.

8 years agoCache: ignore long locked entries during forced expire.
Dmitry Volyntsev [Thu, 18 May 2017 15:39:16 +0000 (18:39 +0300)]
Cache: ignore long locked entries during forced expire.

Abnormally exited workers may leave locked cache entries, this can
result in the cache size on disk exceeding max_size and shared memory
exhaustion.

This change mitigates the issue by ignoring locked entries during forced
expire.  It also increases the visibility of the problem by logging such
entries.

8 years agoUpstream: fixed u->headers_in.headers allocation error handling.
Sergey Kandaurov [Thu, 18 May 2017 11:17:00 +0000 (14:17 +0300)]
Upstream: fixed u->headers_in.headers allocation error handling.

Previously, an allocation error resulted in uninitialized memory access
when evaluating $upstream_http_ variables.

On a related note, see r->headers_out.headers cleanup work in 0cdee26605f3.

8 years agoConfigure: recent Sun C versions.
Maxim Dounin [Mon, 15 May 2017 17:09:44 +0000 (20:09 +0300)]
Configure: recent Sun C versions.

8 years agoConfigure: disabled gcc atomics with Sun C (ticket #1261).
Maxim Dounin [Mon, 15 May 2017 17:09:43 +0000 (20:09 +0300)]
Configure: disabled gcc atomics with Sun C (ticket #1261).

Oracle Developer Studio 12.5 introduced GCC-compatible __sync builtins.
Unfortunately, these builtins are neither GCC-compatible (they generate
warnings when used with volatile), nor working (unexpectedly fail on
unpredictable combinations of code layout and compiler flags).  As such,
the gcc builtin atomic operations configure test explicitly disabled when
compiling with Sun C.

8 years agoConfigure: style.
Maxim Dounin [Mon, 15 May 2017 17:09:40 +0000 (20:09 +0300)]
Configure: style.

8 years agoRealip: allow hostnames in set_real_ip_from (ticket #1180).
Ruslan Ermilov [Mon, 15 May 2017 14:17:01 +0000 (17:17 +0300)]
Realip: allow hostnames in set_real_ip_from (ticket #1180).

8 years agoAccess: simplified rule parser code.
Ruslan Ermilov [Mon, 15 May 2017 14:16:32 +0000 (17:16 +0300)]
Access: simplified rule parser code.

9 years agoSSL: allowed renegotiation in client mode with OpenSSL < 1.1.0.
Sergey Kandaurov [Wed, 3 May 2017 12:15:56 +0000 (15:15 +0300)]
SSL: allowed renegotiation in client mode with OpenSSL < 1.1.0.

In ac9b1df5b246 (1.13.0) we attempted to allow renegotiation in client mode,
but when using OpenSSL 1.0.2 or older versions it was additionally disabled
by SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS.

9 years agoAdded missing "fall through" comments (ticket #1259).
Maxim Dounin [Thu, 27 Apr 2017 13:57:18 +0000 (16:57 +0300)]
Added missing "fall through" comments (ticket #1259).

Found by gcc7 (-Wimplicit-fallthrough).

9 years agoDon't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov [Tue, 25 Apr 2017 20:39:13 +0000 (23:39 +0300)]
Don't pretend we support HTTP major versions >1 as HTTP/1.1.

9 years agoVersion bump.
Ruslan Ermilov [Tue, 25 Apr 2017 20:39:06 +0000 (23:39 +0300)]
Version bump.

9 years agorelease-1.13.0 tag
Maxim Dounin [Tue, 25 Apr 2017 14:18:22 +0000 (17:18 +0300)]
release-1.13.0 tag

9 years agonginx-1.13.0-RELEASE release-1.13.0
Maxim Dounin [Tue, 25 Apr 2017 14:18:21 +0000 (17:18 +0300)]
nginx-1.13.0-RELEASE

9 years agoHTTP/2: reduced difference to HTTP/1.x in reading request body.
Valentin Bartenev [Mon, 24 Apr 2017 11:17:13 +0000 (14:17 +0300)]
HTTP/2: reduced difference to HTTP/1.x in reading request body.

Particularly, this eliminates difference in behavior for requests without body
and deduplicates code.

Prodded by Piotr Sikora.

9 years agoHTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
Valentin Bartenev [Mon, 24 Apr 2017 11:16:57 +0000 (14:16 +0300)]
HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.

It's required by RFC 7540.  While there is no real harm from such frames,
that should help to detect broken clients.

Based on a patch by Piotr Sikora.

9 years agoGzip static: use an appropriate error on memory allocation failure.
Sergey Kandaurov [Thu, 20 Apr 2017 15:26:38 +0000 (18:26 +0300)]
Gzip static: use an appropriate error on memory allocation failure.

9 years agoCleaned up r->headers_out.headers allocation error handling.
Sergey Kandaurov [Thu, 20 Apr 2017 15:26:37 +0000 (18:26 +0300)]
Cleaned up r->headers_out.headers allocation error handling.

If initialization of a header failed for some reason after ngx_list_push(),
leaving the header as is can result in uninitialized memory access by
the header filter or the log module.  The fix is to clear partially
initialized headers in case of errors.

For the Cache-Control header, the fix is to postpone pushing
r->headers_out.cache_control until its value is completed.

9 years agoCore: signal sender pid logging.
Igor Sysoev [Thu, 20 Apr 2017 10:58:16 +0000 (13:58 +0300)]
Core: signal sender pid logging.

9 years agoSub filter: restored ngx_http_set_ctx() at the proper place.
Sergey Kandaurov [Tue, 18 Apr 2017 16:55:23 +0000 (19:55 +0300)]
Sub filter: restored ngx_http_set_ctx() at the proper place.

Previously, ngx_http_sub_header_filter() could fail with a partially
initialized context, later accessed in ngx_http_sub_body_filter()
if called from the perl content handler.

The issue had appeared in 2c045e5b8291 (1.9.4).

A better fix would be to handle ngx_http_send_header() errors in
the perl module, though this doesn't seem to be easy enough.

9 years agoSSL: compatibility with OpenSSL master branch.
Sergey Kandaurov [Tue, 18 Apr 2017 13:08:46 +0000 (16:08 +0300)]
SSL: compatibility with OpenSSL master branch.

The SSL_CTRL_SET_CURVES_LIST macro is removed in the OpenSSL master branch.
SSL_CTX_set1_curves_list is preserved as compatibility with previous versions.

9 years agoSSL: disabled renegotiation detection in client mode.
Sergey Kandaurov [Tue, 18 Apr 2017 13:08:44 +0000 (16:08 +0300)]
SSL: disabled renegotiation detection in client mode.

CVE-2009-3555 is no longer relevant and mitigated by the renegotiation
info extension (secure renegotiation).  On the other hand, unexpected
renegotiation still introduces potential security risks, and hence we do
not allow renegotiation on the server side, as we never request renegotiation.

On the client side the situation is different though.  There are backends
which explicitly request renegotiation, and disabled renegotiation
introduces interoperability problems.  This change allows renegotiation
on the client side, and fixes interoperability problems as observed with
such backends (ticket #872).

Additionally, with TLSv1.3 the SSL_CB_HANDSHAKE_START flag is currently set
by OpenSSL when receiving a NewSessionTicket message, and was detected by
nginx as a renegotiation attempt.  This looks like a bug in OpenSSL, though
this change also allows better interoperability till the problem is fixed.

9 years agoSSL: added support for TLSv1.3 in ssl_protocols directive.
Sergey Kandaurov [Tue, 18 Apr 2017 12:12:38 +0000 (15:12 +0300)]
SSL: added support for TLSv1.3 in ssl_protocols directive.

Support for the TLSv1.3 protocol will be introduced in OpenSSL 1.1.1.

9 years agoSet UDP datagram source address (ticket #1239).
Roman Arutyunyan [Tue, 11 Apr 2017 13:41:53 +0000 (16:41 +0300)]
Set UDP datagram source address (ticket #1239).

Previously, the source IP address of a response UDP datagram could differ from
the original datagram destination address.  This could happen if the server UDP
socket is bound to a wildcard address and the network interface chosen to output
the response packet has a different default address than the destination address
of the original packet.  For example, if two addresses from the same network are
configured on an interface.

Now source address is set explicitly if a response is sent for a server UDP
socket bound to a wildcard address.

9 years agoCore: removed extra ngx_alloc() and ngx_calloc() prototypes.
Sergey Kandaurov [Tue, 18 Apr 2017 10:01:19 +0000 (13:01 +0300)]
Core: removed extra ngx_alloc() and ngx_calloc() prototypes.

9 years agoEnabled IPV6_RECVPKTINFO / IPV6_PKTINFO on macOS.
Sergey Kandaurov [Mon, 17 Apr 2017 11:42:12 +0000 (14:42 +0300)]
Enabled IPV6_RECVPKTINFO / IPV6_PKTINFO on macOS.

This change allows setting the destination IPv6 address of a UDP datagram
received on a wildcard socket.

9 years agoAdded support for the "308 Permanent Redirect" (ticket #877).
Simon Leblanc [Tue, 11 Apr 2017 01:13:46 +0000 (03:13 +0200)]
Added support for the "308 Permanent Redirect" (ticket #877).

9 years agoMail: configurable socket buffer sizes.
Vladimir Homutov [Mon, 3 Apr 2017 14:30:34 +0000 (17:30 +0300)]
Mail: configurable socket buffer sizes.

The "rcvbuf" and "sndbuf" parameters are now supported by
the "listen" directive.

9 years agoStream: configurable socket buffer sizes.
Vladimir Homutov [Mon, 3 Apr 2017 14:29:19 +0000 (17:29 +0300)]
Stream: configurable socket buffer sizes.

The "rcvbuf" and "sndbuf" parameters are now supported by
the "listen" directive.

9 years agoCore: improved JSON escaping.
Valentin Bartenev [Wed, 12 Apr 2017 19:47:57 +0000 (22:47 +0300)]
Core: improved JSON escaping.

Two-character representations are now used for \b, \f, \n, \r, and \t.

9 years agoUse ngx_calloc_buf() where appropriate.
Ruslan Ermilov [Wed, 12 Apr 2017 19:21:04 +0000 (22:21 +0300)]
Use ngx_calloc_buf() where appropriate.

9 years agoVersion bump.
Ruslan Ermilov [Wed, 12 Apr 2017 19:14:24 +0000 (22:14 +0300)]
Version bump.

9 years agorelease-1.11.13 tag
Maxim Dounin [Tue, 4 Apr 2017 15:01:57 +0000 (18:01 +0300)]
release-1.11.13 tag

9 years agonginx-1.11.13-RELEASE release-1.11.13
Maxim Dounin [Tue, 4 Apr 2017 15:01:57 +0000 (18:01 +0300)]
nginx-1.11.13-RELEASE

9 years agoUpstream: allow recovery from "429 Too Many Requests" response.
Piotr Sikora [Fri, 24 Mar 2017 09:48:03 +0000 (02:48 -0700)]
Upstream: allow recovery from "429 Too Many Requests" response.

This change adds "http_429" parameter to "proxy_next_upstream" for
retrying rate-limited requests, and to "proxy_cache_use_stale" for
serving stale cached responses after being rate-limited.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
9 years agoAdded support for "429 Too Many Requests" response (RFC6585).
Piotr Sikora [Fri, 24 Mar 2017 09:48:03 +0000 (02:48 -0700)]
Added support for "429 Too Many Requests" response (RFC6585).

This change adds reason phrase in status line and pretty response body
when "429" status code is used in "return", "limit_conn_status" and/or
"limit_req_status" directives.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
9 years agoFixed type.
hucongcong [Mon, 3 Apr 2017 06:29:40 +0000 (14:29 +0800)]
Fixed type.

9 years agoSlice filter: prevented slice redirection (ticket #1219).
Roman Arutyunyan [Fri, 31 Mar 2017 18:47:56 +0000 (21:47 +0300)]
Slice filter: prevented slice redirection (ticket #1219).

When a slice subrequest was redirected to a new location, its context was lost.
After its completion, a new slice subrequest for the same slice was created.
This could lead to infinite loop.  Now the slice module makes sure each slice
subrequest starts output with the slice context available.

9 years agoSlice filter: allowed at most one subrequest at a time.
Roman Arutyunyan [Tue, 28 Mar 2017 11:03:57 +0000 (14:03 +0300)]
Slice filter: allowed at most one subrequest at a time.

Previously, if slice main request write handler was called while a slice
subrequest was running, a new subrequest for the same slice was started.

9 years agoMoved handling of wev->delayed to the connection event handler.
Maxim Dounin [Sun, 2 Apr 2017 11:32:29 +0000 (14:32 +0300)]
Moved handling of wev->delayed to the connection event handler.

With post_action or subrequests, it is possible that the timer set for
wev->delayed will expire while the active subrequest write event handler
is not ready to handle this.  This results in request hangs as observed
with limit_rate / sendfile_max_chunk and post_action (ticket #776) or
subrequests (ticket #1228).

Moving the handling to the connection event handler fixes the hangs observed,
and also slightly simplifies the code.