]> git.kaiwu.me - nginx.git/log
nginx.git
7 years agonginx-1.15.2-RELEASE release-1.15.2
Maxim Dounin [Tue, 24 Jul 2018 13:10:59 +0000 (16:10 +0300)]
nginx-1.15.2-RELEASE

7 years agoFixed NGX_TID_T_FMT format specification for uint64_t.
Maxim Dounin [Sun, 22 Jul 2018 01:03:40 +0000 (04:03 +0300)]
Fixed NGX_TID_T_FMT format specification for uint64_t.

Previously, "%uA" was used, which corresponds to ngx_atomic_uint_t.
Size of ngx_atomic_uint_t can be easily different from uint64_t,
leading to undefined results.

7 years agoStream ssl_preread: added SSLv2 Client Hello support.
Sergey Kandaurov [Wed, 18 Jul 2018 15:51:25 +0000 (18:51 +0300)]
Stream ssl_preread: added SSLv2 Client Hello support.

In particular, it was not possible to obtain SSLv2 protocol version.

7 years agoFixed invalid access to location defined as an empty string.
Ruslan Ermilov [Tue, 17 Jul 2018 12:30:43 +0000 (15:30 +0300)]
Fixed invalid access to location defined as an empty string.

7 years agoSSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov [Tue, 17 Jul 2018 09:53:23 +0000 (12:53 +0300)]
SSL: save sessions for upstream peers using a callback function.

In TLSv1.3, NewSessionTicket messages arrive after the handshake and
can come at any time.  Therefore we use a callback to save the session
when we know about it.  This approach works for < TLSv1.3 as well.
The callback function is set once per location on merge phase.

Since SSL_get_session() in BoringSSL returns an unresumable session for
TLSv1.3, peer save_session() methods have been updated as well to use a
session supplied within the callback.  To preserve API, the session is
cached in c->ssl->session.  It is preferably accessed in save_session()
methods by ngx_ssl_get_session() and ngx_ssl_get0_session() wrappers.

7 years agoSSL: use of the SSL_OP_NO_RENEGOTIATION option (ticket #1376).
Maxim Dounin [Mon, 16 Jul 2018 14:47:48 +0000 (17:47 +0300)]
SSL: use of the SSL_OP_NO_RENEGOTIATION option (ticket #1376).

The SSL_OP_NO_RENEGOTIATION option is available in OpenSSL 1.1.0h+ and can
save some CPU cycles on renegotiation attempts.

7 years agoSSL: fixed SSL_clear_options() usage with OpenSSL 1.1.0+.
Maxim Dounin [Mon, 16 Jul 2018 14:47:20 +0000 (17:47 +0300)]
SSL: fixed SSL_clear_options() usage with OpenSSL 1.1.0+.

In OpenSSL 1.1.0 the SSL_CTRL_CLEAR_OPTIONS macro was removed, so
conditional compilation test on it results in SSL_clear_options()
and SSL_CTX_clear_options() not being used.  Notably, this caused
"ssl_prefer_server_ciphers off" to not work in SNI-based virtual
servers if server preference was switched on in the default server.

It looks like the only possible fix is to test OPENSSL_VERSION_NUMBER
explicitly.

7 years agoSSL: logging levels of "unsupported protocol", "version too low".
Maxim Dounin [Mon, 16 Jul 2018 14:47:18 +0000 (17:47 +0300)]
SSL: logging levels of "unsupported protocol", "version too low".

Starting with OpenSSL 1.1.0, SSL_R_UNSUPPORTED_PROTOCOL instead of
SSL_R_UNKNOWN_PROTOCOL is reported when a protocol is disabled via
an SSL_OP_NO_* option.

Additionally, SSL_R_VERSION_TOO_LOW is reported when using MinProtocol
or when seclevel checks (as set by @SECLEVEL=n in the cipher string)
rejects a protocol, and this is what happens with SSLv3 and @SECLEVEL=1,
which is the default.

There is also the SSL_R_VERSION_TOO_HIGH error code, but it looks like
it is not possible to trigger it.

7 years agoEvents: added configuration check on the number of connections.
Maxim Dounin [Thu, 12 Jul 2018 16:50:07 +0000 (19:50 +0300)]
Events: added configuration check on the number of connections.

There should be at least one worker connection for each listening socket,
plus an additional connection for channel between worker and master,
or starting worker processes will fail.

7 years agoEvents: moved sockets cloning to ngx_event_init_conf().
Maxim Dounin [Thu, 12 Jul 2018 16:50:02 +0000 (19:50 +0300)]
Events: moved sockets cloning to ngx_event_init_conf().

Previously, listenings sockets were not cloned if the worker_processes
directive was specified after "listen ... reuseport".

This also simplifies upcoming configuration check on the number
of worker connections, as it needs to know the number of listening
sockets before cloning.

7 years agoStream ssl_preread: $ssl_preread_protocol variable.
Roman Arutyunyan [Wed, 11 Jul 2018 14:56:51 +0000 (17:56 +0300)]
Stream ssl_preread: $ssl_preread_protocol variable.

The variable keeps the latest SSL protocol version supported by the client.
The variable has the same format as $ssl_protocol.

The version is read from the client_version field of ClientHello.  If the
supported_versions extension is present in the ClientHello, then the version
is set to TLSv1.3.

7 years agoAllow resetting connections closed by "return 444" (ticket #905).
Ruslan Ermilov [Thu, 12 Jul 2018 09:50:20 +0000 (12:50 +0300)]
Allow resetting connections closed by "return 444" (ticket #905).

If reset_timedout_connection is on, TCP connections closed by
"return 444" will be reset instead of a normal close.

7 years agoResolver: retry sending queries on errors (ticket #1511).
Maxim Dounin [Thu, 5 Jul 2018 19:21:14 +0000 (22:21 +0300)]
Resolver: retry sending queries on errors (ticket #1511).

Errors when sending UDP datagrams can happen, e.g., when local IP address
changes (see fa0e093b64d7), or an unavailable DNS server on the LAN can cause
send() to fail with EHOSTDOWN on BSD systems.  If this happens during
initial query, retry sending immediately, to a different DNS server when
possible.  If this is not enough, allow normal resend to happen by ignoring
the return code of the second ngx_resolver_send_query() call, much like we
do in ngx_resolver_resend().

7 years agoSSL: logging level of "https proxy request" errors.
Maxim Dounin [Thu, 5 Jul 2018 17:45:29 +0000 (20:45 +0300)]
SSL: logging level of "https proxy request" errors.

The "http request" and "https proxy request" errors cannot happen
with HTTP due to pre-handshake checks in ngx_http_ssl_handshake(),
but can happen when SSL is used in stream and mail modules.

7 years agoVersion bump.
Maxim Dounin [Thu, 5 Jul 2018 17:44:58 +0000 (20:44 +0300)]
Version bump.

7 years agorelease-1.15.1 tag
Maxim Dounin [Tue, 3 Jul 2018 15:07:44 +0000 (18:07 +0300)]
release-1.15.1 tag

7 years agonginx-1.15.1-RELEASE release-1.15.1
Maxim Dounin [Tue, 3 Jul 2018 15:07:43 +0000 (18:07 +0300)]
nginx-1.15.1-RELEASE

7 years agoUpstream: fixed tcp_nopush with gRPC.
Maxim Dounin [Mon, 2 Jul 2018 16:03:04 +0000 (19:03 +0300)]
Upstream: fixed tcp_nopush with gRPC.

With gRPC it is possible that a request sending is blocked due to flow
control.  Moreover, further sending might be only allowed once the
backend sees all the data we've already sent.  With such a backend
it is required to clear the TCP_NOPUSH socket option to make sure all
the data we've sent are actually delivered to the backend.

As such, we now clear TCP_NOPUSH in ngx_http_upstream_send_request()
also on NGX_AGAIN if c->write->ready is set.  This fixes a test (which
waits for all the 64k bytes as per initial window before allowing more
bytes) with sendfile enabled when the body was written to a file
in a different context.

7 years agoUpstream: fixed unexpected tcp_nopush usage on peer connections.
Maxim Dounin [Mon, 2 Jul 2018 16:02:31 +0000 (19:02 +0300)]
Upstream: fixed unexpected tcp_nopush usage on peer connections.

Now tcp_nopush on peer connections is disabled if it is disabled on
the client connection, similar to how we handle c->sendfile.  Previously,
tcp_nopush was always used on upstream connections, regardless of
the "tcp_nopush" directive.

7 years agogRPC: clearing buffers in ngx_http_grpc_get_buf().
Maxim Dounin [Mon, 2 Jul 2018 16:02:08 +0000 (19:02 +0300)]
gRPC: clearing buffers in ngx_http_grpc_get_buf().

We copy input buffers to our buffers, so various flags might be
unexpectedly set in buffers returned by ngx_chain_get_free_buf().

In particular, the b->in_file flag might be set when the body was
written to a file in a different context.  With sendfile enabled this
in turn might result in protocol corruption if such a buffer was reused
for a control frame.

Make sure to clear buffers and set only fields we really need to be set.

7 years agoAdded FreeBSD support for "listen ... reuseport".
Ruslan Ermilov [Mon, 2 Jul 2018 10:54:33 +0000 (13:54 +0300)]
Added FreeBSD support for "listen ... reuseport".

7 years agoMIME: added font/woff2 type (ticket #1243).
Valentin Bartenev [Fri, 15 Jun 2018 14:29:55 +0000 (17:29 +0300)]
MIME: added font/woff2 type (ticket #1243).

7 years agoMIME: changed type for woff to font/woff (ticket #1243).
Valentin Bartenev [Fri, 15 Jun 2018 14:29:55 +0000 (17:29 +0300)]
MIME: changed type for woff to font/woff (ticket #1243).

According to RFC 8081 the previously used application/font-woff
type is deprecated.

7 years agoUpstream: ngx_http_upstream_random module.
Vladimir Homutov [Fri, 15 Jun 2018 08:46:14 +0000 (11:46 +0300)]
Upstream: ngx_http_upstream_random module.

The module implements random load-balancing algorithm with optional second
choice.  In the latter case, the best of two servers is chosen, accounting
number of connections and server weight.

Example:

upstream u {
    random [two [least_conn]];

    server 127.0.0.1:8080;
    server 127.0.0.1:8081;
    server 127.0.0.1:8082;
    server 127.0.0.1:8083;
}

7 years agoUpstream: improved peer selection concurrency for hash and ip_hash.
Ruslan Ermilov [Thu, 14 Jun 2018 04:03:50 +0000 (07:03 +0300)]
Upstream: improved peer selection concurrency for hash and ip_hash.

7 years agoResolver: require name servers.
Ruslan Ermilov [Wed, 13 Jun 2018 19:37:49 +0000 (22:37 +0300)]
Resolver: require name servers.

7 years agoResolver: allocate resolver from configuration pool.
Ruslan Ermilov [Wed, 13 Jun 2018 19:37:42 +0000 (22:37 +0300)]
Resolver: allocate resolver from configuration pool.

Before 4a8c9139e579, ngx_resolver_create() didn't use configuration
pool, and allocations were done using malloc().

In 016352c19049, when resolver gained support of several servers,
new allocations were done from the pool.

7 years agoUpstream: disable body cleanup with preserve_output (ticket #1565).
Maxim Dounin [Wed, 13 Jun 2018 12:28:11 +0000 (15:28 +0300)]
Upstream: disable body cleanup with preserve_output (ticket #1565).

With u->conf->preserve_output set the request body file might be used
after the response header is sent, so avoid cleaning it.  (Normally
this is not a problem as u->conf->preserve_output is only set with
r->request_body_no_buffering, but the request body might be already
written to a file in a different context.)

7 years agoHTTP/2: use scheme from original request for pushes (closes #1549).
Ruslan Ermilov [Thu, 7 Jun 2018 17:04:22 +0000 (20:04 +0300)]
HTTP/2: use scheme from original request for pushes (closes #1549).

Instead of the connection scheme, use scheme from the original request.
This fixes pushes when SSL is terminated by a proxy server in front of
nginx.

7 years agoAdded r->schema.
Ruslan Ermilov [Thu, 7 Jun 2018 17:01:41 +0000 (20:01 +0300)]
Added r->schema.

For HTTP/1, it keeps scheme from the absolute form of URI.
For HTTP/2, the :scheme request pseudo-header field value.

7 years agoRemoved extraneous check while processing request line.
Ruslan Ermilov [Thu, 7 Jun 2018 16:53:43 +0000 (19:53 +0300)]
Removed extraneous check while processing request line.

7 years agoHTTP/2: validate client request scheme.
Ruslan Ermilov [Thu, 7 Jun 2018 08:47:10 +0000 (11:47 +0300)]
HTTP/2: validate client request scheme.

The scheme is validated as per RFC 3986, Section 3.1.

7 years agoAllowed digits, '+', '-', and '.' in scheme names as per RFC 3986.
Ruslan Ermilov [Thu, 24 May 2018 09:06:35 +0000 (12:06 +0300)]
Allowed digits, '+', '-', and '.' in scheme names as per RFC 3986.

7 years agoSSL: removed extra prototype.
Sergey Kandaurov [Wed, 6 Jun 2018 10:31:05 +0000 (13:31 +0300)]
SSL: removed extra prototype.

7 years agoAdded missing space after ngx_close_socket_n.
Maxim Dounin [Tue, 5 Jun 2018 14:41:34 +0000 (17:41 +0300)]
Added missing space after ngx_close_socket_n.

7 years agoVersion bump.
Maxim Dounin [Tue, 5 Jun 2018 14:13:17 +0000 (17:13 +0300)]
Version bump.

7 years agorelease-1.15.0 tag
Maxim Dounin [Tue, 5 Jun 2018 13:47:25 +0000 (16:47 +0300)]
release-1.15.0 tag

7 years agonginx-1.15.0-RELEASE release-1.15.0
Maxim Dounin [Tue, 5 Jun 2018 13:47:25 +0000 (16:47 +0300)]
nginx-1.15.0-RELEASE

7 years agoStream: udp streams.
Roman Arutyunyan [Mon, 4 Jun 2018 16:50:00 +0000 (19:50 +0300)]
Stream: udp streams.

Previously, only one client packet could be processed in a udp stream session
even though multiple response packets were supported.  Now multiple packets
coming from the same client address and port are delivered to the same stream
session.

If it's required to maintain a single stream of data, nginx should be
configured in a way that all packets from a client are delivered to the same
worker.  On Linux and DragonFly BSD the "reuseport" parameter should be
specified for this.  Other systems do not currently provide appropriate
mechanisms.  For these systems a single stream of udp packets is only
guaranteed in single-worker configurations.

The proxy_response directive now specifies how many packets are expected in
response to a single client packet.

7 years agoEvents: moved ngx_recvmsg() to new file src/event/ngx_event_udp.c.
Roman Arutyunyan [Fri, 1 Jun 2018 13:55:49 +0000 (16:55 +0300)]
Events: moved ngx_recvmsg() to new file src/event/ngx_event_udp.c.

7 years agoEvents: get remote addresses before creating udp connection.
Roman Arutyunyan [Fri, 1 Jun 2018 10:12:57 +0000 (13:12 +0300)]
Events: get remote addresses before creating udp connection.

Previously, ngx_event_recvmsg() got remote socket addresses after creating
the connection object.  In preparation to handling multiple UDP packets in a
single session, this code was moved up.

7 years agoEvents: fixed handling zero-length client address.
Roman Arutyunyan [Fri, 1 Jun 2018 13:53:02 +0000 (16:53 +0300)]
Events: fixed handling zero-length client address.

On Linux recvmsg() syscall may return a zero-length client address when
receiving a datagram from an unbound unix datagram socket.  It is usually
assumed that socket address has at least the sa_family member.  Zero-length
socket address caused buffer over-read in functions which receive socket
address, for example ngx_sock_ntop().  Typically the over-read resulted in
unexpected socket family followed by session close.  Now a fake socket address
is allocated instead of a zero-length client address.

7 years agoLeave chain in ngx_chain_add_copy() in consistent state on errors.
Sergey Kandaurov [Mon, 4 Jun 2018 15:47:54 +0000 (18:47 +0300)]
Leave chain in ngx_chain_add_copy() in consistent state on errors.

7 years agoLimit req: improved handling of negative times.
Maxim Dounin [Wed, 30 May 2018 12:40:34 +0000 (15:40 +0300)]
Limit req: improved handling of negative times.

Negative times can appear since workers only update time on an event
loop iteration start.  If a worker was blocked for a long time during
an event loop iteration, it is possible that another worker already
updated the time stored in the node.  As such, time since last update
of the node (ms) will be negative.

Previous code used ngx_abs(ms) in the calculations.  That is, negative
times were effectively treated as positive ones.  As a result, it was
not possible to maintain high request rates, where the same node can be
updated multiple times from during an event loop iteration.
In particular, this affected setups with many SSL handshakes, see
http://mailman.nginx.org/pipermail/nginx/2018-May/056291.html.

Fix is to only update the last update time stored in the node if the
new time is larger than previously stored one.  If a future time is
stored in the node, we preserve this time as is.

To prevent breaking things on platforms without monotonic time available
if system time is updated backwards, a safety limit of 60 seconds is
used.  If the time stored in the node is more than 60 seconds in the future,
we assume that the time was changed backwards and update lr->last
to the current time.

7 years agoCore: fixed comment about ngx_current_msec after 81fae70d6cb8.
Ruslan Ermilov [Tue, 29 May 2018 13:15:19 +0000 (16:15 +0300)]
Core: fixed comment about ngx_current_msec after 81fae70d6cb8.

The value is no longer guaranteed to be based on milliseconds
elapsed since Epoch.

7 years agoWin32: fixed comment in ngx_gettimeofday() calculations.
Ruslan Ermilov [Tue, 29 May 2018 08:47:32 +0000 (11:47 +0300)]
Win32: fixed comment in ngx_gettimeofday() calculations.

7 years agoRemoved glibc crypt_r() bug workaround (ticket #1469).
Maxim Dounin [Wed, 23 May 2018 13:38:16 +0000 (16:38 +0300)]
Removed glibc crypt_r() bug workaround (ticket #1469).

The bug in question was fixed in glibc 2.3.2 and is no longer expected
to manifest itself on real servers.  On the other hand, the workaround
causes compilation problems on various systems.  Previously, we've
already fixed the code to compile with musl libc (fd6fd02f6a4d), and
now it is broken on Fedora 28 where glibc's crypt library was replaced
by libxcrypt.  So the workaround was removed.

7 years agoSyslog: install cleanup handler only once.
Vladimir Homutov [Mon, 14 May 2018 19:50:57 +0000 (22:50 +0300)]
Syslog: install cleanup handler only once.

If a socket was re-opened due to an error (02c2352d5b01 and fa0e093b64d7),
additional cleanup handler was installed each time.

7 years agoResolver: close UDP socket on error or incomplete send.
Ruslan Ermilov [Wed, 23 May 2018 07:41:38 +0000 (10:41 +0300)]
Resolver: close UDP socket on error or incomplete send.

7 years agoResolver: style.
Ruslan Ermilov [Wed, 23 May 2018 07:41:29 +0000 (10:41 +0300)]
Resolver: style.

7 years agoCore: silenced getsockopt(TCP_FASTOPEN) messages on FreeBSD.
Maxim Dounin [Mon, 21 May 2018 20:11:27 +0000 (23:11 +0300)]
Core: silenced getsockopt(TCP_FASTOPEN) messages on FreeBSD.

FreeBSD returns EINVAL when getsockopt(TCP_FASTOPEN) is called on a unix
domain socket, resulting in "getsockopt(TCP_FASTOPEN) ... failed" messages
during binary upgrade when unix domain listen sockets are present in
the configuration.  Added EINVAL to the list of ignored error codes.

8 years agoConfigure: fixed clang version detection (closes #1539).
Ruslan Ermilov [Tue, 24 Apr 2018 11:04:59 +0000 (14:04 +0300)]
Configure: fixed clang version detection (closes #1539).

While 325b3042edd6 fixed it on MINIX, it broke it on systems
that output the word "version" on several lines with "cc -v".
The fix is to only consider "clang version" or "LLVM version"
as clang version, but this time only using sed(1).

8 years agoSyslog: re-open syslog udp socket on send error (ticket #1477).
Vladimir Homutov [Tue, 8 May 2018 16:35:56 +0000 (19:35 +0300)]
Syslog: re-open syslog udp socket on send error (ticket #1477).

Previously, only unix domain sockets were reopened to tolerate cases when
local syslog server was restarted.  It makes sense to treat other cases
(for example, local IP address changes) similarly.

8 years agoSilenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov [Mon, 7 May 2018 09:54:37 +0000 (09:54 +0000)]
Silenced -Wcast-function-type warnings (closes #1546).

Cast to intermediate "void *" to lose compiler knowledge about the original
type and pass the warning.  This is not a real fix but rather a workaround.

Found by gcc8.

8 years agoSSL: deprecated the "ssl" directive.
Ruslan Ermilov [Wed, 25 Apr 2018 11:57:24 +0000 (14:57 +0300)]
SSL: deprecated the "ssl" directive.

8 years agoSSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin [Tue, 24 Apr 2018 12:29:01 +0000 (15:29 +0300)]
SSL: detect "listen ... ssl" without certificates (ticket #178).

In mail and stream modules, no certificate provided is a fatal condition,
much like with the "ssl" and "starttls" directives.

In http, "listen ... ssl" can be used in a non-default server without
certificates as long as there is a certificate in the default one, so
missing certificate is only fatal for default servers.

8 years agoMail: fixed error message about missing ssl_certificate_key.
Maxim Dounin [Tue, 24 Apr 2018 12:28:58 +0000 (15:28 +0300)]
Mail: fixed error message about missing ssl_certificate_key.

In 51e1f047d15d, the "ssl" directive name was incorrectly hardcoded
in the error message shown when there are some SSL keys defined, but
not for all certificates.  Right approach is to use the "mode" variable,
which can be either "ssl" or "starttls".

8 years agoCache: fixed cache valid slot to reject incorrect statuses.
Maxim Dounin [Wed, 18 Apr 2018 13:11:41 +0000 (16:11 +0300)]
Cache: fixed cache valid slot to reject incorrect statuses.

Previously, result of ngx_atoi() was assigned to an ngx_uint_t variable,
and errors reported by ngx_atoi() became positive, so the following check
in "status < 100" failed to catch them.  This resulted in the configurations
like "proxy_cache_valid 2xx 30s" being accepted as correct, while they
in fact do nothing.  Changing type to ngx_int_t fixes this, and such
configurations are now properly rejected.

8 years agoVersion bump.
Maxim Dounin [Wed, 18 Apr 2018 13:09:08 +0000 (16:09 +0300)]
Version bump.

8 years agorelease-1.13.12 tag
Maxim Dounin [Tue, 10 Apr 2018 14:11:10 +0000 (17:11 +0300)]
release-1.13.12 tag

8 years agonginx-1.13.12-RELEASE release-1.13.12
Maxim Dounin [Tue, 10 Apr 2018 14:11:09 +0000 (17:11 +0300)]
nginx-1.13.12-RELEASE

8 years agoUpstream: fixed u->conf->preserve_output (ticket #1519).
Maxim Dounin [Thu, 5 Apr 2018 13:56:12 +0000 (16:56 +0300)]
Upstream: fixed u->conf->preserve_output (ticket #1519).

Previously, ngx_http_upstream_process_header() might be called after
we've finished reading response headers and switched to a different read
event handler, leading to errors with gRPC proxying.  Additionally,
the u->conf->read_timeout timer might be re-armed during reading response
headers (while this is expected to be a single timeout on reading
the whole response header).

8 years agoVersion bump.
Maxim Dounin [Thu, 5 Apr 2018 13:53:27 +0000 (16:53 +0300)]
Version bump.

8 years agorelease-1.13.11 tag
Maxim Dounin [Tue, 3 Apr 2018 14:38:10 +0000 (17:38 +0300)]
release-1.13.11 tag

8 years agonginx-1.13.11-RELEASE release-1.13.11
Maxim Dounin [Tue, 3 Apr 2018 14:38:09 +0000 (17:38 +0300)]
nginx-1.13.11-RELEASE

8 years agoUpdated OpenSSL and PCRE used for win32 builds.
Maxim Dounin [Tue, 3 Apr 2018 00:54:09 +0000 (03:54 +0300)]
Updated OpenSSL and PCRE used for win32 builds.

8 years agoUpstream: fixed ngx_http_upstream_test_next() conditions.
Maxim Dounin [Mon, 2 Apr 2018 23:43:18 +0000 (02:43 +0300)]
Upstream: fixed ngx_http_upstream_test_next() conditions.

Previously, ngx_http_upstream_test_next() used an outdated condition on
whether it will be possible to switch to a different server or not.  It
did not take into account restrictions on non-idempotent requests, requests
with non-buffered request body, and the next upstream timeout.

For such requests, switching to the next upstream server was rejected
later in ngx_http_upstream_next(), resulting in nginx own error page
being returned instead of the original upstream response.

8 years agoCore: fixed build, broken by 63e91f263a49.
Vladimir Homutov [Mon, 2 Apr 2018 17:38:43 +0000 (20:38 +0300)]
Core: fixed build, broken by 63e91f263a49.

Both Solaris and Windows define "s_addr" as a macro.

8 years agoCore: revised the PROXY protocol v2 code.
Ruslan Ermilov [Mon, 2 Apr 2018 15:40:04 +0000 (18:40 +0300)]
Core: revised the PROXY protocol v2 code.

- use normal prefixes for types and macros
- removed some macros and types
- revised debug messages
- removed useless check of ngx_sock_ntop() returning 0
- removed special processing of AF_UNSPEC

8 years agoCore: style.
Vladimir Homutov [Tue, 27 Mar 2018 15:39:38 +0000 (18:39 +0300)]
Core: style.

8 years agoCore: added processing of version 2 of the PROXY protocol.
Vladimir Homutov [Thu, 22 Mar 2018 12:55:28 +0000 (15:55 +0300)]
Core: added processing of version 2 of the PROXY protocol.

The protocol used on inbound connection is auto-detected and corresponding
parser is used to extract passed addresses.  TLV parameters are ignored.

The maximum supported size of PROXY protocol header is 107 bytes
(similar to version 1).

8 years agoStream: set action before each recv/send while proxying.
Roman Arutyunyan [Thu, 22 Mar 2018 15:43:49 +0000 (18:43 +0300)]
Stream: set action before each recv/send while proxying.

Now it's clear from log error message if the error occurred on client or
upstream side.

8 years agogRPC: fixed possible sign extension of error and setting_value.
Maxim Dounin [Thu, 22 Mar 2018 16:26:25 +0000 (19:26 +0300)]
gRPC: fixed possible sign extension of error and setting_value.

All cases are harmless and should not happen on valid values, though can
result in bad values being shown incorrectly in logs.

Found by Coverity (CID 143031114303121430313).

8 years agoImproved code readability (closes #1512).
Ruslan Ermilov [Thu, 22 Mar 2018 15:13:33 +0000 (18:13 +0300)]
Improved code readability (closes #1512).

8 years agoConfigure: restored "no-threads" in OpenSSL builds.
Maxim Dounin [Thu, 22 Mar 2018 12:56:07 +0000 (15:56 +0300)]
Configure: restored "no-threads" in OpenSSL builds.

This was previously used, but was incorrectly removed in 83d54192e97b
while removing old threads remnants.  Instead of using it conditionally
when threads are not used, we now set in unconditionally, as even with
thread pools enabled we never call OpenSSL functions in threads.

This fixes resulting binary when using --with-openssl with OpenSSL 1.1.0+
and without -lpthread linked (notably on FreeBSD without PCRE).

8 years agoConfigure: fixed static compilation with OpenSSL 1.1.1.
Maxim Dounin [Thu, 22 Mar 2018 12:55:57 +0000 (15:55 +0300)]
Configure: fixed static compilation with OpenSSL 1.1.1.

OpenSSL now uses pthread_atfork(), and this requires -lpthread on Linux
to compile.  Introduced NGX_LIBPTHREAD to add it as appropriate, similar
to existing NGX_LIBDL.

8 years agoVersion bump.
Maxim Dounin [Thu, 22 Mar 2018 12:55:52 +0000 (15:55 +0300)]
Version bump.

8 years agorelease-1.13.10 tag
Maxim Dounin [Tue, 20 Mar 2018 15:58:30 +0000 (18:58 +0300)]
release-1.13.10 tag

8 years agonginx-1.13.10-RELEASE release-1.13.10
Maxim Dounin [Tue, 20 Mar 2018 15:58:30 +0000 (18:58 +0300)]
nginx-1.13.10-RELEASE

8 years agogRPC: fixed missing state save in frame header parsing.
Sergey Kandaurov [Tue, 20 Mar 2018 12:58:11 +0000 (15:58 +0300)]
gRPC: fixed missing state save in frame header parsing.

Previously, frame state wasn't saved if HEADERS frame payload
that begins with header fragment was not received at once.

8 years agoHTTP/2: improved frame info debugging.
Ruslan Ermilov [Mon, 19 Mar 2018 18:32:15 +0000 (21:32 +0300)]
HTTP/2: improved frame info debugging.

8 years agogRPC: fixed parsing response headers split on CONTINUATION frames.
Sergey Kandaurov [Mon, 19 Mar 2018 13:42:56 +0000 (16:42 +0300)]
gRPC: fixed parsing response headers split on CONTINUATION frames.

8 years agoFixed checking ngx_tcp_push() and ngx_tcp_nopush() return values.
Ruslan Ermilov [Mon, 19 Mar 2018 13:28:23 +0000 (16:28 +0300)]
Fixed checking ngx_tcp_push() and ngx_tcp_nopush() return values.

No functional changes.

8 years agoUpstream: fixed comments after 13f8dec720b5.
Ruslan Ermilov [Mon, 19 Mar 2018 13:22:09 +0000 (16:22 +0300)]
Upstream: fixed comments after 13f8dec720b5.

The fields "uri", "location", and "url" from ngx_http_upstream_conf_t
moved to ngx_http_proxy_loc_conf_t and ngx_http_proxy_vars_t, reflect
this change in create_loc_conf comments.

8 years agoConfigure: added gRPC module help message.
Sergey Kandaurov [Mon, 19 Mar 2018 09:41:36 +0000 (12:41 +0300)]
Configure: added gRPC module help message.

8 years agoContrib: vim syntax, update core and 3rd party module directives.
Gena Makhomed [Sun, 18 Mar 2018 09:11:14 +0000 (11:11 +0200)]
Contrib: vim syntax, update core and 3rd party module directives.

8 years agogRPC: special handling of "trailer only" responses.
Maxim Dounin [Sat, 17 Mar 2018 20:04:26 +0000 (23:04 +0300)]
gRPC: special handling of "trailer only" responses.

The gRPC protocol makes a distinction between HEADERS frame with
the END_STREAM flag set, and a HEADERS frame followed by an empty
DATA frame with the END_STREAM flag.  The latter is not permitted,
and results in errors not being propagated through nginx.  Instead,
gRPC clients complain that "server closed the stream without sending
trailers" (seen in grpc-go) or "13: Received RST_STREAM with error
code 2" (seen in grpc-c).

To fix this, nginx now returns HEADERS with the END_STREAM flag if
the response length is known to be 0, and we are not expecting
any trailer headers to be added.  And the response length is
explicitly set to 0 in the gRPC proxy if we see initial HEADERS frame
with the END_STREAM flag set.

8 years agogRPC: special handling of the TE request header.
Maxim Dounin [Sat, 17 Mar 2018 20:04:25 +0000 (23:04 +0300)]
gRPC: special handling of the TE request header.

According to the gRPC protocol specification, the "TE" header is used
to detect incompatible proxies, and at least grpc-c server rejects
requests without "TE: trailers".

To preserve the logic, we have to pass "TE: trailers" to the backend if
and only if the original request contains "trailers" in the "TE" header.
Note that no other TE values are allowed in HTTP/2, so we have to remove
anything else.

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).