Commit graph

5832 commits

Author SHA1 Message Date
Otto Kekäläinen
f66a37934a Fixed spelling. 2016-06-08 08:27:41 +03:00
Valentin Bartenev
da10c88894 Fixed an error log message. 2016-06-07 17:44:20 +03:00
Sergey Kandaurov
aa86ee53b5 Configure: revised GCC version processing.
Now GCC 6 and onwards will use -Wno-unused-parameter.
2016-06-07 12:15:56 +03:00
Sergey Kandaurov
32415c48a8 Version bump. 2016-06-07 12:26:34 +03:00
Maxim Dounin
6a17768e30 release-1.11.1 tag 2016-05-31 16:43:49 +03:00
Maxim Dounin
381adb4711 nginx-1.11.1-RELEASE 2016-05-31 16:43:49 +03:00
Maxim Dounin
eaa1428c51 Core: skip special buffers on writing (ticket #981).
A special last buffer with cl->buf->pos set to NULL can be present in
a chain when writing request body if chunked encoding was used.  This
resulted in a NULL pointer dereference if it happened to be the only
buffer left after a do...while loop iteration in ngx_write_chain_to_file().

The problem originally appeared in nginx 1.3.9 with chunked encoding
support.  Additionally, rev. 3832b608dc8d (nginx 1.9.13) changed the
minimum number of buffers to trigger this from IOV_MAX (typically 1024)
to NGX_IOVS_PREALLOCATE (typically 64).

Fix is to skip such buffers in ngx_chain_to_iovec(), much like it is
done in other places.
2016-05-31 05:13:30 +03:00
Maxim Dounin
406202bf51 Trailing spaces removed. 2016-05-30 18:09:41 +03:00
Valentin Bartenev
305b52b44e HTTP/2: unbreak build on MSVC. 2016-05-24 21:54:32 +03:00
Valentin Bartenev
e92d7bd21e Version bump. 2016-05-24 21:54:32 +03:00
Maxim Dounin
54f4da0450 release-1.11.0 tag 2016-05-24 18:54:42 +03:00
Maxim Dounin
f55ae4f496 nginx-1.11.0-RELEASE 2016-05-24 18:54:41 +03:00
Maxim Dounin
cf10a5e2ae Updated OpenSSL used for win32 builds. 2016-05-24 17:44:01 +03:00
Maxim Dounin
00cf50c68c Fixed build on MSVC. 2016-05-24 17:43:58 +03:00
Valentin Bartenev
f4c72efa4c HTTP/2: implemented preread buffer for request body (closes #959).
Previously, the stream's window was kept zero in order to prevent a client
from sending the request body before it was requested (see 887cca40ba6a for
details).  Until such initial window was acknowledged all requests with
data were rejected (see 0aa07850922f for details).

That approach revealed a number of problems:

 1. Some clients (notably MS IE/Edge, Safari, iOS applications) show an error
    or even crash if a stream is rejected;

 2. This requires at least one RTT for every request with body before the
    client receives window update and able to send data.

To overcome these problems the new directive "http2_body_preread_size" is
introduced.  It sets the initial window and configures a special per stream
preread buffer that is used to save all incoming data before the body is
requested and processed.

If the directive's value is lower than the default initial window (65535),
as previously, all streams with data will be rejected until the new window
is acknowledged.  Otherwise, no special processing is used and all requests
with data are welcome right from the connection start.

The default value is chosen to be 64k, which is bigger than the default
initial window.  Setting it to zero is fully complaint to the previous
behavior.
2016-05-24 17:37:52 +03:00
Ruslan Ermilov
05c36257f6 Realip: detect duplicate real_ip_header directive. 2016-05-23 19:17:24 +03:00
Dmitry Volyntsev
1de8821b24 Realip: port support in X-Real-IP and X-Forwarded-For.
Now, the module extracts optional port which may accompany an
IP address.  This custom extension is introduced, among other
things, in order to facilitate logging of original client ports.
Addresses with ports are expected to be in the RFC 3986 format,
that is, with IPv6 addresses in square brackets.  E.g.,
"X-Real-IP: [2001:0db8::1]:12345" sets client port ($remote_port)
to 12345.
2016-05-23 18:44:23 +03:00
Dmitry Volyntsev
5234222b04 Realip: take client port from PROXY protocol header.
Previously, when the client address was changed to the one from
the PROXY protocol header, the client port ($remote_port) was
reset to zero.  Now the client port is also changed to the one
from the PROXY protocol header.
2016-05-23 18:44:22 +03:00
Dmitry Volyntsev
c4b6ea614e Added the $realip_remote_port variable. 2016-05-23 18:44:22 +03:00
Dmitry Volyntsev
6433b194e1 Added the $proxy_protocol_port variable. 2016-05-23 18:44:21 +03:00
Maxim Dounin
fc978084d5 Renamed "u" to "sockaddr" in listen options types. 2016-05-23 16:37:28 +03:00
Ruslan Ermilov
a6400247ef Introduced the ngx_sockaddr_t type.
It's properly aligned and can hold any supported sockaddr.
2016-05-23 16:37:20 +03:00
Ruslan Ermilov
748b77db95 Stream: fixed duplicate listen address detection.
The 6f8254ae61b8 change inadvertently fixed the duplicate port
detection similar to how it was fixed for mail in b2920b517490.
It also revealed another issue: the socket type (tcp vs. udp)
wasn't taken into account.
2016-05-23 12:50:59 +03:00
Ruslan Ermilov
04d95aee1a Use ngx_cmp_sockaddr() where appropriate. 2016-05-20 19:10:42 +03:00
Valentin Bartenev
c21b8c2024 HTTP/2: the "421 Misdirected Request" response (closes #848).
Since 4fbef397c753 nginx rejects with the 400 error any attempts of
requesting different host over the same connection, if the relevant
virtual server requires verification of a client certificate.

While requesting hosts other than negotiated isn't something legal
in HTTP/1.x, the HTTP/2 specification explicitly permits such requests
for connection reuse and has introduced a special response code 421.

According to RFC 7540 Section 9.1.2 this code can be sent by a server
that is not configured to produce responses for the combination of
scheme and authority that are included in the request URI.  And the
client may retry the request over a different connection.

Now this code is used for requests that aren't authorized in current
connection.  After receiving the 421 response a client will be able
to open a new connection, provide the required certificate and retry
the request.

Unfortunately, not all clients currently are able to handle it well.
Notably Chrome just shows an error, while at least the latest version
of Firefox retries the request over a new connection.
2016-05-20 18:41:17 +03:00
Ruslan Ermilov
bf89326f24 Belatedly changed the ngx_create_listening() prototype.
The function is called only with "struct sockaddr *" since 0.7.58.
2016-05-20 17:02:04 +03:00
Maxim Dounin
889b8b9312 SSL: removed default DH parameters.
Using the same DH parameters on multiple servers is believed to be subject
to precomputation attacks, see http://weakdh.org/.  Additionally, 1024 bits
are not enough in the modern world as well.  Let users provide their own
DH parameters with the ssl_dhparam directive if they want to use EDH ciphers.

Note that SSL_CTX_set_dh_auto() as provided by OpenSSL 1.1.0 uses fixed
DH parameters from RFC 5114 and RFC 3526, and therefore subject to the same
precomputation attacks.  We avoid using it as well.

This change also fixes compilation with OpenSSL 1.1.0-pre5 (aka Beta 2),
as OpenSSL developers changed their policy after releasing Beta 1 and
broke API once again by making the DH struct opaque (see ticket #860).
2016-05-19 14:46:32 +03:00
Maxim Dounin
1d28f99a9e SSL: support for multiple curves (ticket #885).
OpenSSL 1.0.2+ allows configuring a curve list instead of a single curve
previously supported.  This allows use of different curves depending on
what client supports (as available via the elliptic_curves extension),
and also allows use of different curves in an ECDHE key exchange and
in the ECDSA certificate.

The special value "auto" was introduced (now the default for ssl_ecdh_curve),
which means "use an internal list of curves as available in the OpenSSL
library used".  For versions prior to OpenSSL 1.0.2 it maps to "prime256v1"
as previously used.  The default in 1.0.2b+ prefers prime256v1 as well
(and X25519 in OpenSSL 1.1.0+).

As client vs. server preference of curves is controlled by the
same option as used for ciphers (SSL_OP_CIPHER_SERVER_PREFERENCE),
the ssl_prefer_server_ciphers directive now controls both.
2016-05-19 14:46:32 +03:00
Maxim Dounin
df6791fa79 SSL: style. 2016-05-19 14:46:32 +03:00
Maxim Dounin
d8f309670b SSL: error messages style. 2016-05-19 14:46:32 +03:00
Maxim Dounin
3dc95a5597 SSL: support for multiple certificates (ticket #814). 2016-05-19 14:46:32 +03:00
Maxim Dounin
677f032704 SSL: support for per-certificate chains.
The SSL_CTX_add0_chain_cert() function as introduced in OpenSSL 1.0.2 now
used instead of SSL_CTX_add_extra_chain_cert().

SSL_CTX_add_extra_chain_cert() adds extra certs for all certificates
in the context, while SSL_CTX_add0_chain_cert() only to a particular
certificate.  There is no difference unless multiple certificates are used,
though it is important when using multiple certificates.

Additionally, SSL_CTX_select_current_cert() is now called before using
a chain to make sure correct chain will be returned.
2016-05-19 14:46:32 +03:00
Maxim Dounin
9b134ce774 SSL: made it possible to iterate though all certificates.
A pointer to a previously configured certificate now stored in a certificate.
This makes it possible to iterate though all certificates configured in
the SSL context.  This is now used to configure OCSP stapling for all
certificates, and in ngx_ssl_session_id_context().

As SSL_CTX_use_certificate() frees previously loaded certificate of the same
type, and we have no way to find out if it's the case, X509_free() calls
are now posponed till ngx_ssl_cleanup_ctx().

Note that in OpenSSL 1.0.2+ this can be done without storing things in exdata
using the SSL_CTX_set_current_cert() and SSL_CTX_get0_certificate() functions.
These are not yet available in all supported versions though, so it's easier
to continue to use exdata for now.
2016-05-19 14:46:32 +03:00
Maxim Dounin
8932cc0170 OCSP stapling: additional function to configure stapling on a cert. 2016-05-19 14:46:32 +03:00
Maxim Dounin
a940933978 OCSP stapling: staple now extracted via SSL_get_certificate().
This makes it possible to properly return OCSP staple with multiple
certificates configured.

Note that it only works properly in OpenSSL 1.0.1d+, 1.0.0k, 0.9.8y+.
In older versions SSL_get_certificate() fails to return correct certificate
when the certificate status callback is called.
2016-05-19 14:46:32 +03:00
Maxim Dounin
307205d051 OCSP stapling: staple now stored in certificate, not SSL context. 2016-05-19 14:46:32 +03:00
Maxim Dounin
660928c29d OCSP stapling: staple provided in arguments. 2016-05-19 14:46:32 +03:00
Maxim Dounin
04c4212de9 Added overflow checks for version numbers (ticket #762).
Both minor and major versions are now limited to 999 maximum.  In case of
r->http_minor, this limit is already implied by the code.  Major version,
r->http_major, in theory can be up to 65535 with current code, but such
values are very unlikely to become real (and, additionally, such values
are not allowed by RFC 7230), so the same test was used for r->http_major.
2016-05-18 16:21:32 +03:00
Maxim Dounin
b5cdf67888 Events: close descriptors on errors in ngx_epoll_test_rdhup(). 2016-05-18 15:57:30 +03:00
Maxim Dounin
a2089c6dab Events: changed ngx_epoll_test_rdhup() to use existing epollfd. 2016-05-18 15:57:29 +03:00
Maxim Dounin
cbc94b5b3b Fixed work with --test-build-epoll after f7849bfb6d21. 2016-05-18 15:57:28 +03:00
Maxim Dounin
bdff3e7a5a Cache: fixed updating bypassed cached errors (ticket #827). 2016-05-16 20:37:38 +03:00
Maxim Dounin
ca94b7d3ee Dav: return 501 on PUT with ranges (ticket #948). 2016-05-16 20:37:23 +03:00
Valentin Bartenev
b24752465d Fixed an error log message about epoll_wait() timeout.
The errno value is unset in case of epoll_wait() timeout.
2016-05-16 16:22:34 +03:00
Valentin Bartenev
b32d9b87cf Improved EPOLLRDHUP handling.
When it's known that the kernel supports EPOLLRDHUP, there is no need in
additional recv() call to get EOF or error when the flag is absent in the
event generated by the kernel.  A special runtime test is done at startup
to detect if EPOLLRDHUP is actually supported by the kernel because
epoll_ctl() silently ignores unknown flags.

With this knowledge it's now possible to drop the "ready" flag for partial
read.  Previously, the "ready" flag was kept until the recv() returned EOF
or error.  In particular, this change allows the lingering close heuristics
(which relies on the "ready" flag state) to actually work on Linux, and not
wait for more data in most cases.

The "available" flag is now used in the read event with the semantics similar
to the corresponding counter in kqueue.
2016-05-13 17:19:23 +03:00
Dmitry Volyntsev
eb11242a8e Map: support of complex values in resulting strings. 2016-05-12 16:43:19 +03:00
Ruslan Ermilov
9003b8a6e6 Removed a surplus condition from ngx_parse_inet6_url().
No functional changes, since the condition was always true.
2016-05-11 17:55:30 +03:00
Valentin Bartenev
85e7f29d53 Core: fixed port handling in ngx_parse_inet6_url().
This fixes buffer over-read when no port is specified in cases
similar to 5df5d7d771f6, and catches missing port separator.
2016-05-11 17:55:20 +03:00
Ruslan Ermilov
9a72fc4fae Removed unused flag unexpected_eof from ngx_connection_t. 2016-04-28 16:30:19 +03:00
Vladimir Homutov
24251be5e9 Variable $request_id.
The variable contains text representation based on random data, usable as
a unique request identifier.
2016-04-26 19:31:46 +03:00