summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)AuthorFilesLines
2019-06-17Perl: disabled not_modified filter (ticket #1786).Maxim Dounin1-0/+2
Embedded perl does not set any request fields needed for conditional requests processing. Further, filter finalization in the not_modified filter can cause segmentation faults due to cleared ctx as in ticket #1786. Before 5fb1e57c758a (1.7.3) the not_modified filter was implicitly disabled for perl responses, as r->headers_out.last_modified_time was -1. This change restores this behaviour by using the explicit r->disable_not_modified flag. Note that this patch doesn't try to address perl module robustness against filter finalization and other errors returned from filter chains. It should be eventually reworked to handle errors instead of ignoring them.
2019-06-05Limit req: limit_req_dry_run directive.Roman Arutyunyan1-4/+25
A new directive limit_req_dry_run allows enabling the dry run mode. In this mode requests are neither rejected nor delayed, but reject/delay status is logged as usual.
2019-06-03Upstream: background cache update before cache send (ticket #1782).Roman Arutyunyan1-11/+8
In case of filter finalization, essential request fields like r->uri, r->args etc could be changed, which affected the cache update subrequest. Also, after filter finalization r->cache could be set to NULL, leading to null pointer dereference in ngx_http_upstream_cache_background_update(). The fix is to create background cache update subrequest before sending the cached response. Since initial introduction in 1aeaae6e9446 (1.11.10) background cache update subrequest was created after sending the cached response because otherwise it blocked the parent request output. In 9552758a786e (1.13.1) background subrequests were introduced to eliminate the delay before sending the final part of the cached response. This also made it possible to create the background cache update subrequest before sending the response. Note that creating the subrequest earlier does not change the fact that in case of filter finalization the background cache update subrequest will likely not have enough time to successfully update the cache entry. Filter finalization leads to the main request termination as soon the current iteration of request processing is complete.
2019-05-23Upstream hash: fall back to round-robin if hash key is empty.Niklas Keller2-4/+4
2019-05-27Version bump.Roman Arutyunyan1-2/+2
2019-05-21release-1.17.0 tagMaxim Dounin1-0/+1
2019-05-21nginx-1.17.0-RELEASErelease-1.17.0Maxim Dounin1-0/+62
2016-04-11SSL: removed OpenSSL 0.9.7 compatibility.Sergey Kandaurov4-56/+6
2019-05-13Range filter: fixed duplicate last buffers.Maxim Dounin1-4/+4
In ngx_http_range_singlepart_body() special buffers where passed unmodified, including ones after the end of the range. As such, if the last buffer of a response was sent separately as a special buffer, two buffers with b->last_buf set were present in the response. In particular, this might result in a duplicate final chunk when using chunked transfer encoding (normally range filter and chunked transfer encoding are not used together, but this may happen if there are trailers in the response). This also likely to cause problems in HTTP/2. Fix is to skip all special buffers after we've sent the last part of the range requested. These special buffers are not meaningful anyway, since we set b->last_buf in the buffer with the last part of the range, and everything is expected to be flushed due to it. Additionally, ngx_http_next_body_filter() is now called even if no buffers are to be passed to it. This ensures that various write events are properly propagated through the filter chain. In particular, this fixes test failures observed with the above change and aio enabled.
2019-05-13Range filter: fixed loss of incoming chain links.Maxim Dounin1-9/+45
Filters are not allowed to change incoming chain links, and should allocate their own links if any modifications are needed. Nevertheless ngx_http_range_singlepart_body() modified incoming chain links in some cases, notably at the end of the requested range. No problems caused by this are currently known, mostly because of limited number of possible modifications and the position of the range body filter in the filter chain. Though this behaviour is clearly incorrect and tests demonstrate that it can at least cause some proxy buffers being lost when using proxy_force_ranges, leading to less effective handling of responses. Fix is to always allocate new chain links in ngx_http_range_singlepart_body(). Links are explicitly freed to ensure constant memory usage with long-lived requests.
2019-05-08Unconditional compilation of the postpone filter.Roman Arutyunyan2-18/+2
Postpone filter is an essential part of subrequest functionality. In absence of it a subrequest response body is sent to the client out of order with respect to the main request header and body, as well as other subrequests. For in-memory subrequests the response is also sent to the client instead of being stored in memory. Currently the postpone filter is automatically enabled if one of the following standard modules which are known to create subrequests is enabled: ssi, slice, addition. However a third-party module that creates subrequests can still be built without the postpone filter or be dynamically loaded in nginx built without it.
2019-04-24Variables support in proxy_upload_rate and proxy_download_rate.Ruslan Ermilov2-12/+20
2019-04-24Variables support in limit_rate and limit_rate_after (ticket #293).Ruslan Ermilov6-44/+57
2019-04-24Added ngx_http_set_complex_value_size_slot().Ruslan Ermilov4-0/+138
If a complex value is expected to be of type size_t, and the compiled value is constant, the constant size_t value is remembered at compile time. The value is accessed through ngx_http_complex_value_size() which either returns the remembered constant or evaluates the expression and parses it as size_t.
2019-04-09Core: enabled "include" in any context (ticket #1615).Vladimir Homutov1-1/+1
2019-04-24Version bump.Vladimir Homutov1-2/+2
2019-04-16release-1.15.12 tagMaxim Dounin1-0/+1
2019-04-16nginx-1.15.12-RELEASErelease-1.15.12Maxim Dounin1-0/+20
2019-04-16Updated PCRE used for win32 builds.Maxim Dounin1-1/+1
2019-04-15Fixed incorrect length handling in ngx_utf8_length().Maxim Dounin1-1/+1
Previously, ngx_utf8_decode() was called from ngx_utf8_length() with incorrect length, potentially resulting in out-of-bounds read when handling invalid UTF-8 strings. In practice out-of-bounds reads are not possible though, as autoindex, the only user of ngx_utf8_length(), provides null-terminated strings, and ngx_utf8_decode() anyway returns an errors when it sees a null in the middle of an UTF-8 sequence. Reported by Yunbin Liu.
2019-04-15OCSP stapling: fixed segfault with dynamic certificate loading.Maxim Dounin1-0/+5
If OCSP stapling was enabled with dynamic certificate loading, with some OpenSSL versions (1.0.2o and older, 1.1.0h and older; fixed in 1.0.2p, 1.1.0i, 1.1.1) a segmentation fault might happen. The reason is that during an abbreviated handshake the certificate callback is not called, but the certificate status callback was called (https://github.com/openssl/openssl/issues/1662), leading to NULL being returned from SSL_get_certificate(). Fix is to explicitly check SSL_get_certificate() result.
2019-04-15Version bump.Maxim Dounin1-2/+2
2019-04-09release-1.15.11 tagMaxim Dounin1-0/+1
2019-04-09nginx-1.15.11-RELEASErelease-1.15.11Maxim Dounin1-0/+14
2019-04-04Win32: avoid using CFLAGS, just add define instead.Maxim Dounin1-2/+1
With CFLAGS set as in 7da71a7b141a, OpenSSL compilation drops various non-important compiler options. To avoid this, a define is added instead - OpenSSL is smart enough to recognize -D... in Configure arguments.
2019-04-04Win32: defined pdb path.Maxim Dounin1-1/+1
By default, MSVC uses vc<version>.pdb in the current directory. With the "-Fd" switch it is directed to be in the objs directory instead.
2019-04-04Win32: preserving binary compatibility with Windows XP - Vista.Sergey Kandaurov1-1/+2
OpenSSL 1.1.0 and above uses BCrypt if available (Windows 7 or higher). This results in an unusable binary on older Windows versions, when building with newer Windows SDK (such as 7.0A). Using CFLAGS to define _WIN32_WINNT allows to set a desired ABI and make sure the binary works with Windows XP. To not mix with other potential CFLAGS uses, it is set in GNUmakefile.
2019-04-04Win32: skip building OpenSSL tests to conserve time and space.Sergey Kandaurov1-1/+1
When building OpenSSL 1.1.1b, as used for win32 builds, with tests it takes about twice as long and near ~1GB of additional disk space. Using "no-tests" OpenSSL configuration option allows to skip them. Since such an option is supported since OpenSSL 1.1.1 only, it is residing here and not in configure.
2019-04-03OCSP stapling: open ssl_stapling_file in binary-mode.Sergey Kandaurov1-1/+1
OCSP response uses the DER format and as such needs to be opened in binary-mode. This only has any effect under Win32.
2019-03-26SSL: missing free calls in $ssl_client_s_dn and $ssl_client_i_dn.Nikolay Morozov1-0/+2
If X509_get_issuer_name() or X509_get_subject_name() returned NULL, this could lead to a certificate reference leak. It cannot happen in practice though, since each function returns an internal pointer to a mandatory subfield of the certificate successfully decoded by d2i_X509() during certificate message processing (closes #1751).
2019-03-26Version bump.Sergey Kandaurov1-2/+2
2019-03-26release-1.15.10 tagMaxim Dounin1-0/+1
2019-03-26nginx-1.15.10-RELEASErelease-1.15.10Maxim Dounin1-0/+60
2019-03-06Listen port ranges.Roman Arutyunyan2-29/+119
A range is specified with a dash. For each port in a range a separate listen socket is created. Examples: listen 8080-9000; listen example.com:80-88;
2019-03-20Removed sorting of getaddrinfo() results.Roman Arutyunyan1-14/+5
Previously the ngx_inet_resolve_host() function sorted addresses in a way that IPv4 addresses came before IPv6 addresses. This was implemented in eaf95350d75c (1.3.10) along with the introduction of getaddrinfo() which could resolve host names to IPv6 addresses. Since the "listen" directive only used the first address, sorting allowed to preserve "listen" compatibility with the previous behavior and with the behavior of nginx built without IPv6 support. Now "listen" uses all resolved addresses which makes sorting pointless.
2019-03-15Multiple addresses in "listen".Roman Arutyunyan11-427/+276
Previously only one address was used by the listen directive handler even if host name resolved to multiple addresses. Now a separate listening socket is created for each address.
2019-03-09SSL: support for parsing PEM certificates from memory.Maxim Dounin1-25/+43
This makes it possible to provide certificates directly via variables in ssl_certificate / ssl_certificate_key directives, without using intermediate files.
2019-03-09SSL: removed redundant "pkey" variable.Maxim Dounin1-3/+2
It was accidentally introduced in 77436d9951a1 (1.15.9). In MSVC 2015 and more recent MSVC versions it triggers warning C4456 (declaration of 'pkey' hides previous local declaration). Previously, all such warnings were resolved in 2a621245f4cf. Reported by Steve Stevenson.
2019-03-05SSL: moved c->ssl->handshaked check in server name callback.Maxim Dounin1-6/+6
Server name callback is always called by OpenSSL, even if server_name extension is not present in ClientHello. As such, checking c->ssl->handshaked before the SSL_get_servername() result should help to more effectively prevent renegotiation in OpenSSL 1.1.0 - 1.1.0g, where neither SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS nor SSL_OP_NO_RENEGOTIATION is available.
2019-03-03SSL: use of the SSL_OP_NO_CLIENT_RENEGOTIATION option.Maxim Dounin1-0/+4
The SSL_OP_NO_CLIENT_RENEGOTIATION option was introduced in LibreSSL 2.5.1. Unlike OpenSSL's SSL_OP_NO_RENEGOTIATION, it only disables client-initiated renegotiation, and hence can be safely used on all SSL contexts.
2019-03-03SSL: fixed potential leak on memory allocation errors.Maxim Dounin7-8/+15
If ngx_pool_cleanup_add() fails, we have to clean just created SSL context manually, thus appropriate call added. Additionally, ngx_pool_cleanup_add() moved closer to ngx_ssl_create() in the ngx_http_ssl_module, to make sure there are no leaks due to intermediate code.
2019-03-03SSL: server name callback changed to return fatal errors.Maxim Dounin2-7/+28
Notably this affects various allocation errors, and should generally improve things if an allocation error actually happens during a callback. Depending on the OpenSSL version, returning an error can result in either SSL_R_CALLBACK_FAILED or SSL_R_CLIENTHELLO_TLSEXT error from SSL_do_handshake(), so both errors were switched to the "info" level.
2019-03-03SSL: server name callback changed to return SSL_TLSEXT_ERR_OK.Maxim Dounin2-6/+25
OpenSSL 1.1.1 does not save server name to the session if server name callback returns anything but SSL_TLSEXT_ERR_OK, thus breaking the $ssl_server_name variable in resumed sessions. Since $ssl_server_name can be used even if we've selected the default server and there are no other servers, it looks like the only viable solution is to always return SSL_TLSEXT_ERR_OK regardless of the actual result. To fix things in the stream module as well, added a dummy server name callback which always returns SSL_TLSEXT_ERR_OK.
2019-03-03Version bump.Maxim Dounin1-2/+2
2019-02-26release-1.15.9 tagMaxim Dounin1-0/+1
2019-02-26nginx-1.15.9-RELEASErelease-1.15.9Maxim Dounin1-0/+53
2019-02-26Updated OpenSSL used for win32 builds.Maxim Dounin1-1/+1
2019-02-25SSL: fixed possible segfault with dynamic certificates.Maxim Dounin3-4/+4
A virtual server may have no SSL context if it does not have certificates defined, so we have to use config of the ngx_http_ssl_module from the SSL context in the certificate callback. To do so, it is now passed as the argument of the callback. The stream module doesn't really need any changes, but was modified as well to match http code.
2019-02-25SSL: adjusted session id context with dynamic certificates.Maxim Dounin5-8/+31
Dynamic certificates re-introduce problem with incorrect session reuse (AKA "virtual host confusion", CVE-2014-3616), since there are no server certificates to generate session id context from. To prevent this, session id context is now generated from ssl_certificate directives as specified in the configuration. This approach prevents incorrect session reuse in most cases, while still allowing sharing sessions across multiple machines with ssl_session_ticket_key set as long as configurations are identical.
2019-02-25SSL: dynamic certificate loading in the stream module.Maxim Dounin2-4/+179