]> git.kaiwu.me - nginx.git/log
nginx.git
8 years agoThe gRPC proxy module.
Maxim Dounin [Sat, 17 Mar 2018 20:04:24 +0000 (23:04 +0300)]
The gRPC proxy module.

The module allows passing requests to upstream gRPC servers.
The module is built by default as long as HTTP/2 support is compiled in.
Example configuration:

    grpc_pass 127.0.0.1:9000;

Alternatively, the "grpc://" scheme can be used:

    grpc_pass grpc://127.0.0.1:9000;

Keepalive support is available via the upstream keepalive module.  Note
that keepalive connections won't currently work with grpc-go as it fails
to handle SETTINGS_HEADER_TABLE_SIZE.

To use with SSL:

    grpc_pass grpcs://127.0.0.1:9000;

SSL connections use ALPN "h2" when available.  At least grpc-go works fine
without ALPN, so if ALPN is not available we just establish a connection
without it.

Tested with grpc-c++ and grpc-go.

8 years agoUpstream: u->conf->preserve_output flag.
Maxim Dounin [Sat, 17 Mar 2018 20:04:23 +0000 (23:04 +0300)]
Upstream: u->conf->preserve_output flag.

The flag can be used to continue sending request body even after we've
got a response from the backend.  In particular, this is needed for gRPC
proxying of bidirectional streaming RPCs, and also to send control frames
in other forms of RPCs.

8 years agoUpstream: u->request_body_blocked flag.
Maxim Dounin [Sat, 17 Mar 2018 20:04:22 +0000 (23:04 +0300)]
Upstream: u->request_body_blocked flag.

The flag indicates whether last ngx_output_chain() returned NGX_AGAIN
or not.  If the flag is set, we arm the u->conf->send_timeout timer.
The flag complements c->write->ready test, and allows to stop sending
the request body in an output filter due to protocol-specific flow
control.

8 years agoUpstream: trailers support, u->conf->pass_trailers flag.
Maxim Dounin [Sat, 17 Mar 2018 20:04:21 +0000 (23:04 +0300)]
Upstream: trailers support, u->conf->pass_trailers flag.

Basic trailer headers support allows one to access response trailers
via the $upstream_trailer_* variables.

Additionally, the u->conf->pass_trailers flag was introduced.  When the
flag is set, trailer headers from the upstream response are passed to
the client.  Like normal headers, trailer headers will be hidden
if present in u->conf->hide_headers_hash.

8 years agoHTTP/2: externalized various constants and interfaces.
Maxim Dounin [Sat, 17 Mar 2018 20:04:20 +0000 (23:04 +0300)]
HTTP/2: externalized various constants and interfaces.

8 years agoStyle.
Roman Arutyunyan [Mon, 12 Mar 2018 15:38:53 +0000 (18:38 +0300)]
Style.

8 years agoStream ssl_preread: $ssl_preread_alpn_protocols variable.
Roman Arutyunyan [Mon, 12 Mar 2018 13:03:08 +0000 (16:03 +0300)]
Stream ssl_preread: $ssl_preread_alpn_protocols variable.

The variable keeps a comma-separated list of protocol names from ALPN TLS
extension defined by RFC 7301.

8 years agoImproved code readablity.
Ruslan Ermilov [Wed, 7 Mar 2018 15:28:12 +0000 (18:28 +0300)]
Improved code readablity.

No functional changes.

8 years agoHTTP/2: unknown frames now logged at info level.
Maxim Dounin [Mon, 5 Mar 2018 18:35:13 +0000 (21:35 +0300)]
HTTP/2: unknown frames now logged at info level.

8 years agoStyle.
Maxim Dounin [Mon, 5 Mar 2018 18:35:08 +0000 (21:35 +0300)]
Style.

8 years agoAccess log: support for disabling escaping (ticket #1450).
Vladimir Homutov [Thu, 1 Mar 2018 08:42:55 +0000 (11:42 +0300)]
Access log: support for disabling escaping (ticket #1450).

Based on patches by Johannes Baiter <johannes.baiter@bsb-muenchen.de>
and Calin Don.

8 years agoCore: ngx_current_msec now uses monotonic time if available.
Maxim Dounin [Thu, 1 Mar 2018 17:25:50 +0000 (20:25 +0300)]
Core: ngx_current_msec now uses monotonic time if available.

When clock_gettime(CLOCK_MONOTONIC) (or faster variants, _FAST on FreeBSD,
and _COARSE on Linux) is available, we now use it for ngx_current_msec.
This should improve handling of timers if system time changes (ticket #189).

8 years agoPostpone filter: prevented uninitialized r->out.
Roman Arutyunyan [Thu, 1 Mar 2018 15:38:39 +0000 (18:38 +0300)]
Postpone filter: prevented uninitialized r->out.

The r->out chain link could be left uninitialized in case of error.
A segfault could happen if the subrequest handler accessed it.
The issue was introduced in commit 20f139e9ffa8.

8 years agoGeneric subrequests in memory.
Roman Arutyunyan [Wed, 28 Feb 2018 13:56:58 +0000 (16:56 +0300)]
Generic subrequests in memory.

Previously, only the upstream response body could be accessed with the
NGX_HTTP_SUBREQUEST_IN_MEMORY feature.  Now any response body from a subrequest
can be saved in a memory buffer.  It is available as a single buffer in r->out
and the buffer size is configured by the subrequest_output_buffer_size
directive.

Upstream, proxy and fastcgi code used to handle the old-style feature is
removed.

8 years agoModules compatibility: additional upstream metrics.
Vladimir Homutov [Thu, 22 Feb 2018 14:25:43 +0000 (17:25 +0300)]
Modules compatibility: additional upstream metrics.

8 years agoAuth basic: prevent null character in error log (ticket #1494).
Vadim Filimonov [Mon, 26 Feb 2018 14:52:20 +0000 (16:52 +0200)]
Auth basic: prevent null character in error log (ticket #1494).

8 years agoGenerate error for unsupported IPv6 transparent proxy.
Roman Arutyunyan [Thu, 22 Feb 2018 10:16:21 +0000 (13:16 +0300)]
Generate error for unsupported IPv6 transparent proxy.

On some platforms (for example, Linux with glibc 2.12-2.25) IPv4 transparent
proxying is available, but IPv6 transparent proxying is not.  The entire feature
is enabled in this case and NGX_HAVE_TRANSPARENT_PROXY macro is set to 1.
Previously, an attempt to enable transparency for an IPv6 socket was silently
ignored in this case and was usually followed by a bind(2) EADDRNOTAVAIL error
(ticket #1487).  Now the error is generated for unavailable IPv6 transparent
proxy.

8 years agoHTTP/2: style.
Ruslan Ermilov [Thu, 22 Feb 2018 09:42:29 +0000 (12:42 +0300)]
HTTP/2: style.

Unified the style of validity checks in ngx_http_v2_validate_header().

8 years agoGeo: fixed indentation.
Sergey Kandaurov [Wed, 21 Feb 2018 14:26:00 +0000 (17:26 +0300)]
Geo: fixed indentation.

8 years agoGeo: optimized configuration parser.
Ruslan Ermilov [Wed, 21 Feb 2018 12:50:43 +0000 (15:50 +0300)]
Geo: optimized configuration parser.

If the geo block parser has failed, doing more things is pointless.

8 years agoGeo: fixed memory allocation error handling (closes #1482).
Ruslan Ermilov [Wed, 21 Feb 2018 12:50:42 +0000 (15:50 +0300)]
Geo: fixed memory allocation error handling (closes #1482).

If during configuration parsing of the geo directive the memory
allocation has failed, pool used to parse configuration inside
the block, and sometimes the temporary pool were not destroyed.

8 years agoVersion bump.
Ruslan Ermilov [Wed, 21 Feb 2018 12:50:35 +0000 (15:50 +0300)]
Version bump.

8 years agorelease-1.13.9 tag
Maxim Dounin [Tue, 20 Feb 2018 14:08:49 +0000 (17:08 +0300)]
release-1.13.9 tag

8 years agonginx-1.13.9-RELEASE release-1.13.9
Maxim Dounin [Tue, 20 Feb 2018 14:08:48 +0000 (17:08 +0300)]
nginx-1.13.9-RELEASE

8 years agoHTTP/2: precalculate hash for "Cookie".
Maxim Dounin [Thu, 15 Feb 2018 16:06:22 +0000 (19:06 +0300)]
HTTP/2: precalculate hash for "Cookie".

There is no need to calculate hashes of static strings at runtime.  The
ngx_hash() macro can be used to do it during compilation instead, similarly
to how it is done in ngx_http_proxy_module.c for "Server" and "Date" headers.

8 years agoHTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
Ruslan Ermilov [Thu, 15 Feb 2018 14:51:37 +0000 (17:51 +0300)]
HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.

In particular, if a stream object allocation failed, and a client sent
the PRIORITY frame for this stream, ngx_http_v2_set_dependency() could
dereference a null pointer while trying to re-parent a dependency node.

8 years agoHTTP/2: push additional request headers (closes #1478).
Ruslan Ermilov [Thu, 15 Feb 2018 14:51:32 +0000 (17:51 +0300)]
HTTP/2: push additional request headers (closes #1478).

The Accept-Encoding, Accept-Language, and User-Agent header fields
are now copied from the original request to pushed requests.

8 years agoExpose more headers with NGX_HTTP_HEADERS.
Ruslan Ermilov [Thu, 15 Feb 2018 14:51:26 +0000 (17:51 +0300)]
Expose more headers with NGX_HTTP_HEADERS.

8 years agoCore: added a stub for additional zone configuration.
Vladimir Homutov [Thu, 15 Feb 2018 13:08:05 +0000 (16:08 +0300)]
Core: added a stub for additional zone configuration.

8 years agoHTTP/2: style.
Sergey Kandaurov [Wed, 14 Feb 2018 23:34:16 +0000 (02:34 +0300)]
HTTP/2: style.

8 years agoHTTP/2: fixed null pointer dereference with server push.
Ruslan Ermilov [Fri, 9 Feb 2018 20:20:08 +0000 (23:20 +0300)]
HTTP/2: fixed null pointer dereference with server push.

r->headers_in.host can be NULL in ngx_http_v2_push_resource().

This happens when a request is terminated with 400 before the :authority
or Host header is parsed, and either pushing is enabled on the server{}
level or error_page 400 redirects to a location with pushes configured.

Found by Coverity (CID 1429156).

8 years agoHTTP/2: fixed build with -Werror=unused-but-set-variable.
Ruslan Ermilov [Thu, 8 Feb 2018 09:11:30 +0000 (12:11 +0300)]
HTTP/2: fixed build with -Werror=unused-but-set-variable.

8 years agoHTTP/2: server push.
Ruslan Ermilov [Thu, 8 Feb 2018 06:55:03 +0000 (09:55 +0300)]
HTTP/2: server push.

Resources to be pushed are configured with the "http2_push" directive.

Also, preload links from the Link response headers, as described in
https://www.w3.org/TR/preload/#server-push-http-2, can be pushed, if
enabled with the "http2_push_preload" directive.

Only relative URIs with absolute paths can be pushed.

The number of concurrent pushes is normally limited by a client, but
cannot exceed a hard limit set by the "http2_max_concurrent_pushes"
directive.

8 years agoHTTP/2: changed prototypes of request pseudo-headers parsers.
Ruslan Ermilov [Thu, 8 Feb 2018 06:54:49 +0000 (09:54 +0300)]
HTTP/2: changed prototypes of request pseudo-headers parsers.

No functional changes.

8 years agoBasic support of the Link response header.
Ruslan Ermilov [Thu, 8 Feb 2018 06:54:18 +0000 (09:54 +0300)]
Basic support of the Link response header.

8 years agoDav: added error logging.
Roman Arutyunyan [Wed, 7 Feb 2018 13:44:29 +0000 (16:44 +0300)]
Dav: added error logging.

Previously, when request body was not available or was previously read in
memory rather than a file, client received HTTP 500 error, but no explanation
was logged in error log.  This could happen, for example, if request body was
read or discarded prior to error_page redirect, or if mirroring was enabled
along with dav.

8 years agoHTTP/2: removed unused field from ngx_http_v2_stream_t.
Sergey Kandaurov [Tue, 6 Feb 2018 17:02:59 +0000 (20:02 +0300)]
HTTP/2: removed unused field from ngx_http_v2_stream_t.

8 years agoContrib: vim syntax, update 3rd party module directives.
Gena Makhomed [Thu, 1 Feb 2018 09:15:14 +0000 (11:15 +0200)]
Contrib: vim syntax, update 3rd party module directives.

Add new directives for 3rd party modules.

8 years agoContrib: vim syntax, update core module directives.
Gena Makhomed [Thu, 1 Feb 2018 09:09:35 +0000 (11:09 +0200)]
Contrib: vim syntax, update core module directives.

"match" is block directive, "upstream_conf" is deprecated
by patch http://hg.nginx.org/nginx.org/rev/27c53e1cb4b6

8 years agoUpstream: removed X-Powered-By from the list of special headers.
Ruslan Ermilov [Tue, 30 Jan 2018 19:23:58 +0000 (22:23 +0300)]
Upstream: removed X-Powered-By from the list of special headers.

After 1e720b0be7ec, it's neither specially processed nor copied
when redirecting with X-Accel-Redirect.

8 years agoSSL: using default server context in session remove (closes #1464).
Sergey Kandaurov [Tue, 30 Jan 2018 14:46:31 +0000 (17:46 +0300)]
SSL: using default server context in session remove (closes #1464).

This fixes segfault in configurations with multiple virtual servers sharing
the same port, where a non-default virtual server block misses certificate.

8 years agoHTTP/2: finalize request as bad if parsing of pseudo-headers fails.
Ruslan Ermilov [Tue, 30 Jan 2018 11:44:31 +0000 (14:44 +0300)]
HTTP/2: finalize request as bad if parsing of pseudo-headers fails.

This is in line when the required pseudo-headers are missing, and
avoids spurious zero statuses in access.log.

8 years agoHTTP/2: more style, comments, and debugging.
Ruslan Ermilov [Mon, 29 Jan 2018 13:06:33 +0000 (16:06 +0300)]
HTTP/2: more style, comments, and debugging.

8 years agoHTTP/2: handle duplicate INITIAL_WINDOW_SIZE settings.
Ruslan Ermilov [Mon, 29 Jan 2018 12:54:36 +0000 (15:54 +0300)]
HTTP/2: handle duplicate INITIAL_WINDOW_SIZE settings.

8 years agoFixed --test-build-eventport on macOS 10.12 and later.
Ruslan Ermilov [Tue, 16 Jan 2018 10:52:03 +0000 (13:52 +0300)]
Fixed --test-build-eventport on macOS 10.12 and later.

In macOS 10.12, CLOCK_REALTIME and clockid_t were added, but not timer_t.

8 years agoUpstream: fixed "header already sent" alerts on backend errors.
Maxim Dounin [Thu, 11 Jan 2018 18:43:49 +0000 (21:43 +0300)]
Upstream: fixed "header already sent" alerts on backend errors.

Following ad3f342f14ba046c (1.9.13), it is possible that a request where
header was already sent will be finalized with NGX_HTTP_BAD_GATEWAY,
triggering an attempt to return additional error response and the
"header already sent" alert as a result.

In particular, it is trivial to reproduce the problem with a HEAD request
and caching enabled.  With caching enabled nginx will change HEAD to GET
and will set u->pipe->downstream_error to suppress sending the response
body to the client.  When a backend-related error occurs (for example,
proxy_read_timeout expires), ngx_http_finalize_upstream_request() will
be called with NGX_HTTP_BAD_GATEWAY.  After ad3f342f14ba046c this will
result in ngx_http_finalize_request(NGX_HTTP_BAD_GATEWAY).

Fix is to move u->pipe->downstream_error handling to a later point,
where all special response codes are changed to NGX_ERROR.

Reported by Jan Prachar,
http://mailman.nginx.org/pipermail/nginx-devel/2018-January/010737.html.

8 years agoYear 2018.
Maxim Dounin [Thu, 11 Jan 2018 18:43:24 +0000 (21:43 +0300)]
Year 2018.

8 years agoContrib: vim syntax, update core module directives.
Gena Makhomed [Thu, 28 Dec 2017 10:01:05 +0000 (12:01 +0200)]
Contrib: vim syntax, update core module directives.

Removed non-existent directives and directive redefinitions.

8 years agoContrib: vim syntax, update 3rd party module directives.
Gena Makhomed [Thu, 28 Dec 2017 09:49:44 +0000 (11:49 +0200)]
Contrib: vim syntax, update 3rd party module directives.

3rd party modules list synchronized with FreeBSD nginx-devel port.

8 years agoVersion bump.
Maxim Dounin [Fri, 29 Dec 2017 21:15:07 +0000 (00:15 +0300)]
Version bump.

8 years agorelease-1.13.8 tag
Maxim Dounin [Tue, 26 Dec 2017 16:01:12 +0000 (19:01 +0300)]
release-1.13.8 tag

8 years agonginx-1.13.8-RELEASE release-1.13.8
Maxim Dounin [Tue, 26 Dec 2017 16:01:11 +0000 (19:01 +0300)]
nginx-1.13.8-RELEASE

8 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Tue, 26 Dec 2017 14:48:49 +0000 (17:48 +0300)]
Updated OpenSSL used for win32 builds.

8 years agoContrib: vim syntax, listen options.
Gena Makhomed [Mon, 25 Dec 2017 16:30:01 +0000 (18:30 +0200)]
Contrib: vim syntax, listen options.

8 years agoContrib: vim syntax, update core module directives.
Gena Makhomed [Mon, 25 Dec 2017 15:57:01 +0000 (17:57 +0200)]
Contrib: vim syntax, update core module directives.

8 years agoContrib: updated vim syntax rules for variables.
Maxim Dounin [Mon, 25 Dec 2017 16:41:00 +0000 (19:41 +0300)]
Contrib: updated vim syntax rules for variables.

Non-quoted parameters are allowed to contain variables in curly brackets
(see d91a8c4ac6bb), so vim syntax rules were adjusted accordingly.

8 years agoAllowed configuration token to start with a variable.
Roman Arutyunyan [Thu, 21 Dec 2017 10:29:40 +0000 (13:29 +0300)]
Allowed configuration token to start with a variable.

Specifically, it is now allowed to start with a variable expression with braces:
${name}.  The opening curly bracket in such a token was previously considered
the start of a new block.  Variables located anywhere else in a token worked
fine: foo${name}.

8 years agoFixed capabilities version.
Roman Arutyunyan [Tue, 19 Dec 2017 16:00:27 +0000 (19:00 +0300)]
Fixed capabilities version.

Previously, capset(2) was called with the 64-bit capabilities version
_LINUX_CAPABILITY_VERSION_3.  With this version Linux kernel expected two
copies of struct __user_cap_data_struct, while only one was submitted.  As a
result, random stack memory was accessed and random capabilities were requested
by the worker.  This sometimes caused capset() errors.  Now the 32-bit version
_LINUX_CAPABILITY_VERSION_1 is used instead.  This is OK since CAP_NET_RAW is
a 32-bit capability (CAP_NET_RAW = 13).

8 years agoImproved the capabilities feature detection.
Roman Arutyunyan [Mon, 18 Dec 2017 18:09:39 +0000 (21:09 +0300)]
Improved the capabilities feature detection.

Previously included file sys/capability.h mentioned in capset(2) man page,
belongs to the libcap-dev package, which may not be installed on some Linux
systems when compiling nginx.  This prevented the capabilities feature from
being detected and compiled on that systems.

Now linux/capability.h system header is included instead.  Since capset()
declaration is located in sys/capability.h, now capset() syscall is defined
explicitly in code using the SYS_capset constant, similarly to other
Linux-specific features in nginx.

8 years agoRetain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan [Wed, 13 Dec 2017 17:40:53 +0000 (20:40 +0300)]
Retain CAP_NET_RAW capability for transparent proxying.

The capability is retained automatically in unprivileged worker processes after
changing UID if transparent proxying is enabled at least once in nginx
configuration.

The feature is only available in Linux.

8 years agoUse sysconf to determine cacheline size at runtime.
Debayan Ghosh [Mon, 11 Dec 2017 16:28:11 +0000 (16:28 +0000)]
Use sysconf to determine cacheline size at runtime.

Determine cacheline size at runtime if supported
using sysconf(_SC_LEVEL1_DCACHE_LINESIZE). In case not supported,
fallback to compile time defaults.

8 years agoConfigure: set default cacheline size to 64 for aarch64 platforms.
Debayan Ghosh [Mon, 11 Dec 2017 15:05:35 +0000 (15:05 +0000)]
Configure: set default cacheline size to 64 for aarch64 platforms.

8 years agoConfigure: fixed SO_BINDANY comment.
Maxim Dounin [Thu, 7 Dec 2017 14:09:36 +0000 (17:09 +0300)]
Configure: fixed SO_BINDANY comment.

8 years agoConfigure: moved IP_BIND_ADDRESS_NO_PORT test.
Maxim Dounin [Thu, 7 Dec 2017 14:09:33 +0000 (17:09 +0300)]
Configure: moved IP_BIND_ADDRESS_NO_PORT test.

In 2c7b488a61fb, IP_BIND_ADDRESS_NO_PORT test was accidentally placed
between SO_BINDANY, IP_TRANSPARENT, and IP_BINDANY tests.  Moved it after
these tests.

8 years agoProxy: escape explicit space in URI in default cache key.
Roman Arutyunyan [Mon, 20 Nov 2017 17:50:35 +0000 (20:50 +0300)]
Proxy: escape explicit space in URI in default cache key.

If the flag space_in_uri is set, the URI in HTTP upstream request is escaped to
convert space to %20.  However this flag is not checked while creating the
default cache key.  This leads to different cache keys for requests
'/foo bar' and '/foo%20bar', while the upstream requests are identical.

Additionally, the change fixes background cache updates when the client URI
contains unescaped space.  Default cache key in a subrequest is always based on
escaped URI, while the main request may not escape it.  As a result, background
cache update subrequest may update a different cache entry.

8 years agoInherit valid_unparsed_uri in cloned subrequests (ticket #1430).
Roman Arutyunyan [Mon, 20 Nov 2017 18:11:19 +0000 (21:11 +0300)]
Inherit valid_unparsed_uri in cloned subrequests (ticket #1430).

Inheriting this flag will make the cloned subrequest behave consistently with
the parent.  Specifically, the upstream HTTP request and cache key created by
the proxy module may depend directly on unparsed_uri if valid_unparsed_uri flag
is set.  Previously, the flag was zero for cloned requests, which could make
background update proxy a request different than its parent and cache the result
with a different key.  For example, if client URI contained the escaped slash
character %2F, it was used as is by the proxy module in the main request, but
was unescaped in the subrequests.

Similar problems exist in the slice module.

8 years agoProxy: simplified conditions of using unparsed uri.
Roman Arutyunyan [Mon, 20 Nov 2017 10:47:17 +0000 (13:47 +0300)]
Proxy: simplified conditions of using unparsed uri.

Previously, the unparsed uri was explicitly allowed to be used only by the main
request.  However the valid_unparsed_uri flag is nonzero only in the main
request, which makes the main request check pointless.

8 years agoUpstream: flush low-level buffers on write retry.
Patryk Lesiewicz [Fri, 1 Dec 2017 23:59:14 +0000 (15:59 -0800)]
Upstream: flush low-level buffers on write retry.

If the data to write is bigger than what the socket can send, and the
reminder is smaller than NGX_SSL_BUFSIZE, then SSL_write() fails with
SSL_ERROR_WANT_WRITE. The reminder of payload however is successfully
copied to the low-level buffer and all the output chain buffers are
flushed. This means that retry logic doesn't work because
ngx_http_upstream_process_non_buffered_request() checks only if there's
anything in the output chain buffers and ignores the fact that something
may be buffered in low-level parts of the stack.

Signed-off-by: Patryk Lesiewicz <patryk@google.com>
8 years agoUpstream keepalive: clean read delayed flag in stored connections.
Roman Arutyunyan [Tue, 28 Nov 2017 11:00:00 +0000 (14:00 +0300)]
Upstream keepalive: clean read delayed flag in stored connections.

If a connection with the read delayed flag set was stored in the keepalive
cache, and after picking it from the cache a read timer was set on that
connection, this timer was considered a delay timer rather than a socket read
event timer as expected.  The latter timeout is usually much longer than the
former, which caused a significant delay in request processing.

The issue manifested itself with proxy_limit_rate and upstream keepalive
enabled and exists since 973ee2276300 (1.7.7) when proxy_limit_rate was
introduced.

8 years agoAutoindex: discard request body (ticket #1439).
Maxim Dounin [Mon, 4 Dec 2017 14:30:02 +0000 (17:30 +0300)]
Autoindex: discard request body (ticket #1439).

8 years agoRemoved unused FreeBSD-specific definitions in ngx_posix_config.h.
Sergey Kandaurov [Tue, 28 Nov 2017 10:09:54 +0000 (13:09 +0300)]
Removed unused FreeBSD-specific definitions in ngx_posix_config.h.

8 years agoFixed "changing binary" when reaper is not init.
Ruslan Ermilov [Tue, 28 Nov 2017 09:00:24 +0000 (12:00 +0300)]
Fixed "changing binary" when reaper is not init.

On some systems, it's possible that reaper of orphaned processes is
set to something other than "init" process.  On such systems, the
changing binary procedure did not work.

The fix is to check if PPID has changed, instead of assuming it's
always 1 for orphaned processes.

8 years agoConfigure: fixed clang detection on MINIX.
Maxim Dounin [Thu, 23 Nov 2017 13:33:40 +0000 (16:33 +0300)]
Configure: fixed clang detection on MINIX.

As per POSIX, basic regular expressions have no alternations, and the
interpretation of the "\|" construct is undefined.  At least on MINIX
and Solaris grep interprets "\|" as literal "|", and not as an alternation
as GNU grep does.  Removed such constructs introduced in f1daa0356a1d.
This fixes clang detection on MINIX.

8 years agoVersion bump.
Maxim Dounin [Thu, 23 Nov 2017 13:32:58 +0000 (16:32 +0300)]
Version bump.

8 years agorelease-1.13.7 tag
Maxim Dounin [Tue, 21 Nov 2017 15:09:44 +0000 (18:09 +0300)]
release-1.13.7 tag

8 years agonginx-1.13.7-RELEASE release-1.13.7
Maxim Dounin [Tue, 21 Nov 2017 15:09:43 +0000 (18:09 +0300)]
nginx-1.13.7-RELEASE

8 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Tue, 21 Nov 2017 14:32:12 +0000 (17:32 +0300)]
Updated OpenSSL used for win32 builds.

8 years agoFixed worker_shutdown_timeout in various cases.
Maxim Dounin [Mon, 20 Nov 2017 13:31:07 +0000 (16:31 +0300)]
Fixed worker_shutdown_timeout in various cases.

The ngx_http_upstream_process_upgraded() did not handle c->close request,
and upgraded connections do not use the write filter.  As a result,
worker_shutdown_timeout did not affect upgraded connections (ticket #1419).
Fix is to handle c->close in the ngx_http_request_handler() function, thus
covering most of the possible cases in http handling.

Additionally, mail proxying did not handle neither c->close nor c->error,
and thus worker_shutdown_timeout did not work for mail connections.  Fix is
to add c->close handling to ngx_mail_proxy_handler().

Also, added explicit handling of c->close to stream proxy,
ngx_stream_proxy_process_connection().  This improves worker_shutdown_timeout
handling in stream, it will no longer wait for some data being transferred
in a connection before closing it, and will also provide appropriate
logging at the "info" level.

8 years agoGzip: support for a zlib variant from Intel.
Maxim Dounin [Sat, 18 Nov 2017 01:03:27 +0000 (04:03 +0300)]
Gzip: support for a zlib variant from Intel.

A zlib variant from Intel as available from https://github.com/jtkukunas/zlib
uses 64K hash instead of scaling it from the specified memory level, and
also uses 16-byte padding in one of the window-sized memory buffers, and can
force window bits to 13 if compression level is set to 1 and appropriate
compile options are used.  As a result, nginx complained with "gzip filter
failed to use preallocated memory" alerts.

This change improves deflate_state allocation detection by testing that
items is 1 (deflate_state is the only allocation where items is 1).
Additionally, on first failure to use preallocated memory we now assume
that we are working with the Intel's modified zlib, and switch to using
appropriate preallocations.  If this does not help, we complain with the
usual alerts.

Previous version of this patch was published at
http://mailman.nginx.org/pipermail/nginx/2014-July/044568.html.
The zlib variant in question is used by default in ClearLinux from Intel,
see http://mailman.nginx.org/pipermail/nginx-ru/2017-October/060421.html,
http://mailman.nginx.org/pipermail/nginx-ru/2017-November/060544.html.

8 years agoXslt: fixed parameters parsing (ticket #1416).
Ruslan Ermilov [Thu, 16 Nov 2017 10:20:47 +0000 (13:20 +0300)]
Xslt: fixed parameters parsing (ticket #1416).

If parameters were specified in xslt_stylesheet without variables,
any request except the first would cause an internal server error.

8 years agoSSI: fixed type.
hucongcong [Thu, 26 Oct 2017 16:30:38 +0000 (00:30 +0800)]
SSI: fixed type.

8 years agoFastCGI: adjust buffer position when parsing incomplete records.
Maxim Dounin [Thu, 9 Nov 2017 12:35:20 +0000 (15:35 +0300)]
FastCGI: adjust buffer position when parsing incomplete records.

Previously, nginx failed to move buffer position when parsing an incomplete
record header, and due to this wasn't be able to continue parsing once
remaining bytes of the record header were received.

This can affect response header parsing, potentially generating spurious errors
like "upstream sent unexpected FastCGI request id high byte: 1 while reading
response header from upstream".  While this is very unlikely, since usually
record headers are written in a single buffer, this still can happen in real
life, for example, if a record header will be split across two TCP packets
and the second packet will be delayed.

This does not affect non-buffered response body proxying, due to "buf->pos =
buf->last;" at the start of the ngx_http_fastcgi_non_buffered_filter()
function.  Also this does not affect buffered response body proxying, as
each input buffer is only passed to the filter once.

8 years agoCore: free shared memory zones only after reconfiguration.
Maxim Dounin [Tue, 17 Oct 2017 16:52:16 +0000 (19:52 +0300)]
Core: free shared memory zones only after reconfiguration.

This is what usually happens for zones no longer used in the new
configuration, but zones where size or tag were changed were freed
when creating new memory zones.  If reconfiguration failed (for
example, due to a conflicting listening socket), this resulted in a
segmentation fault in the master process.

Reported by Zhihua Cao,
http://mailman.nginx.org/pipermail/nginx-devel/2017-October/010536.html.

8 years agoPostpone filter: handled ngx_http_postpone_filter_add() failures.
Sergey Kandaurov [Mon, 16 Oct 2017 10:13:25 +0000 (13:13 +0300)]
Postpone filter: handled ngx_http_postpone_filter_add() failures.

In particular, if ngx_http_postpone_filter_add() fails in ngx_chain_add_copy(),
the output chain of the postponed request was left in an invalid state.

8 years agoFixed type of ngx_conf_t.handler_conf.
Ruslan Ermilov [Thu, 12 Oct 2017 21:32:26 +0000 (00:32 +0300)]
Fixed type of ngx_conf_t.handler_conf.

The type should have been changed in c9b243802a17 along with
changing ngx_conf_handler_pt.

8 years agoSSL: include <openssl/hmac.h>.
Alessandro Ghedini [Wed, 11 Oct 2017 22:43:50 +0000 (15:43 -0700)]
SSL: include <openssl/hmac.h>.

This header carries the definition of HMAC_Init_ex(). In OpenSSL this
header is included by <openssl/ssl.h>, but it's not so in BoringSSL.

It's probably a good idea to explicitly include this header anyway,
regardless of whether it's included by other headers or not.

8 years agoUpstream: disabled upgrading in subrequests.
Roman Arutyunyan [Wed, 11 Oct 2017 14:38:21 +0000 (17:38 +0300)]
Upstream: disabled upgrading in subrequests.

Upgrading an upstream connection is usually followed by reading from the client
which a subrequest is not allowed to do.  Moreover, accessing the header_in
request field while processing upgraded connection ends up with a null pointer
dereference since the header_in buffer is only created for the the main request.

8 years agoUpstream: fixed $upstream_status when upstream returns 503/504.
Ruslan Ermilov [Wed, 11 Oct 2017 19:04:28 +0000 (22:04 +0300)]
Upstream: fixed $upstream_status when upstream returns 503/504.

If proxy_next_upstream includes http_503/http_504, and upstream
returns 503/504, $upstream_status converted this to 502 for any
values except the last one.

8 years agoVersion bump.
Ruslan Ermilov [Wed, 11 Oct 2017 19:04:11 +0000 (22:04 +0300)]
Version bump.

8 years agorelease-1.13.6 tag
Maxim Dounin [Tue, 10 Oct 2017 15:22:51 +0000 (18:22 +0300)]
release-1.13.6 tag

8 years agonginx-1.13.6-RELEASE release-1.13.6
Maxim Dounin [Tue, 10 Oct 2017 15:22:50 +0000 (18:22 +0300)]
nginx-1.13.6-RELEASE

8 years agoUpstream: fixed error handling of stale and revalidated cache send.
Sergey Kandaurov [Mon, 9 Oct 2017 22:04:54 +0000 (01:04 +0300)]
Upstream: fixed error handling of stale and revalidated cache send.

The NGX_DONE value returned from ngx_http_upstream_cache_send() indicates
that upstream was already finalized in ngx_http_upstream_process_headers().
It was treated as a generic error which resulted in duplicate finalization.

Handled NGX_HTTP_UPSTREAM_INVALID_HEADER from ngx_http_upstream_cache_send().
Previously, it could return within ngx_http_upstream_finalize_request(), and
since it's below NGX_HTTP_SPECIAL_RESPONSE, a client connection could stuck.

8 years agoUpstream: even better handling of invalid headers in cache files.
Maxim Dounin [Mon, 9 Oct 2017 12:59:10 +0000 (15:59 +0300)]
Upstream: even better handling of invalid headers in cache files.

When parsing of headers in a cache file fails, already parsed headers
need to be cleared, and protocol state needs to be reinitialized.  To do
so, u->request_sent is now set to ensure ngx_http_upstream_reinit() will
be called.

This change complements improvements in 46ddff109e72.

8 years agoUpstream hash: reordered peer checks.
Maxim Dounin [Thu, 5 Oct 2017 14:43:05 +0000 (17:43 +0300)]
Upstream hash: reordered peer checks.

This slightly reduces cost of selecting a peer if all or almost all peers
failed, see ticket #1030.  There should be no measureable difference with
other workloads.

8 years agoUpstream hash: limited number of tries in consistent case.
Maxim Dounin [Thu, 5 Oct 2017 14:42:59 +0000 (17:42 +0300)]
Upstream hash: limited number of tries in consistent case.

While this may result in non-ideal distribution of requests if nginx
won't be able to select a server in a reasonable number of attempts,
this still looks better than severe performance degradation observed
if there is no limit and there are many points configured (ticket #1030).
This is also in line with what we do for other hash balancing methods.

8 years agoFixed build without IPv6, broken by 874171c3c71a.
Maxim Dounin [Thu, 5 Oct 2017 13:50:35 +0000 (16:50 +0300)]
Fixed build without IPv6, broken by 874171c3c71a.

8 years agoFixed handling of unix sockets in $binary_remote_addr.
Maxim Dounin [Wed, 4 Oct 2017 18:19:42 +0000 (21:19 +0300)]
Fixed handling of unix sockets in $binary_remote_addr.

Previously, unix sockets were treated as AF_INET ones, and this may
result in buffer overread on Linux, where unbound unix sockets have
2-byte addresses.

Note that it is not correct to use just sun_path as a binary representation
for unix sockets.  This will result in an empty string for unbound unix
sockets, and thus behaviour of limit_req and limit_conn will change when
switching from $remote_addr to $binary_remote_addr.  As such, normal text
representation is used.

Reported by Stephan Dollberg.

8 years agoFixed handling of non-null-terminated unix sockets.
Maxim Dounin [Wed, 4 Oct 2017 18:19:38 +0000 (21:19 +0300)]
Fixed handling of non-null-terminated unix sockets.

At least FreeBSD, macOS, NetBSD, and OpenBSD can return unix sockets
with non-null-terminated sun_path.  Additionally, the address may become
non-null-terminated if it does not fit into the buffer provided and was
truncated (may happen on macOS, NetBSD, and Solaris, which allow unix socket
addresess larger than struct sockaddr_un).  As such, ngx_sock_ntop() might
overread the sockaddr provided, as it used "%s" format and thus assumed
null-terminated string.

To fix this, the ngx_strnlen() function was introduced, and it is now used
to calculate correct length of sun_path.

8 years agoFixed buffer overread with unix sockets after accept().
Maxim Dounin [Wed, 4 Oct 2017 18:19:33 +0000 (21:19 +0300)]
Fixed buffer overread with unix sockets after accept().

Some OSes (notably macOS, NetBSD, and Solaris) allow unix socket addresses
larger than struct sockaddr_un.  Moreover, some of them (macOS, Solaris)
return socklen of the socket address before it was truncated to fit the
buffer provided.  As such, on these systems socklen must not be used without
additional check that it is within the buffer provided.

Appropriate checks added to ngx_event_accept() (after accept()),
ngx_event_recvmsg() (after recvmsg()), and ngx_set_inherited_sockets()
(after getsockname()).

We also obtain socket addresses via getsockname() in
ngx_connection_local_sockaddr(), but it does not need any checks as
it is only used for INET and INET6 sockets (as there can be no
wildcard unix sockets).

8 years agoHTTP/2: enforce writing the sync request body buffer to file.
Valentin Bartenev [Wed, 4 Oct 2017 18:15:15 +0000 (21:15 +0300)]
HTTP/2: enforce writing the sync request body buffer to file.

The sync flag of HTTP/2 request body buffer is used when the size of request
body is unknown or bigger than configured "client_body_buffer_size".  In this
case the buffer points to body data inside the global receive buffer that is
used for reading all HTTP/2 connections in the worker process.  Thus, when the
sync flag is set, the buffer must be flushed to a temporary file, otherwise
the request body data can be overwritten.

Previously, the sync buffer wasn't flushed to a temporary file if the whole
body was received in one DATA frame with the END_STREAM flag and wasn't
copied into the HTTP/2 body preread buffer.  As a result, the request body
might be corrupted (ticket #1384).

Now, setting r->request_body_in_file_only enforces writing the sync buffer
to a temporary file in all cases.