]> git.kaiwu.me - nginx.git/log
nginx.git
9 years agoHTTP/2: fix $bytes_sent variable.
Piotr Sikora [Sun, 26 Mar 2017 08:25:02 +0000 (01:25 -0700)]
HTTP/2: fix $bytes_sent variable.

Previously, its value accounted for payloads of HEADERS, CONTINUATION
and DATA frames, as well as frame headers of HEADERS and DATA frames,
but it didn't account for frame headers of CONTINUATION frames.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
9 years agoCopy filter: wake up subrequests after aio operations.
Maxim Dounin [Tue, 28 Mar 2017 15:15:42 +0000 (18:15 +0300)]
Copy filter: wake up subrequests after aio operations.

Previously, connection write handler was called, resulting in wake up
of the active subrequest.  This change makes it possible to read data
in non-active subrequests as well.  For example, this allows SSI to
process instructions in non-active subrequests earlier and start
additional subrequests if needed, reducing overall response time.

9 years agoThreads: fixed request hang with aio_write and subrequests.
Maxim Dounin [Tue, 28 Mar 2017 15:15:41 +0000 (18:15 +0300)]
Threads: fixed request hang with aio_write and subrequests.

If the subrequest is already finalized, the handler set with aio_write
may still be used by sendfile in threads when using range requests
(see also e4c1f5b32868, and the original note in 9fd738b85fad).  Calling
already finalized subrequest's r->write_event_handler in practice
results in request hang in some cases.

Fix is to trigger connection event handler if the subrequest was already
finalized.

9 years agoSimplified and improved sendfile() code on Linux.
Maxim Dounin [Tue, 28 Mar 2017 15:15:39 +0000 (18:15 +0300)]
Simplified and improved sendfile() code on Linux.

The ngx_linux_sendfile() function is now used for both normal sendfile()
and sendfile in threads.  The ngx_linux_sendfile_thread() function was
modified to use the same interface as ngx_linux_sendfile(), and is simply
called from ngx_linux_sendfile() when threads are enabled.

Special return code NGX_DONE is used to indicate that a thread task was
posted and no further actions are needed.

If number of bytes sent is less that what we were sending, we now always
retry sending.  This is needed for sendfile() in threads as the number
of bytes we are sending might have been changed since the thread task
was posted.  And this is also needed for Linux 4.3+, as sendfile() might
be interrupted at any time and provides no indication if it was interrupted
or not (ticket #1174).

9 years agoFixed ngx_open_cached_file() error handling.
Sergey Kandaurov [Tue, 28 Mar 2017 11:21:38 +0000 (14:21 +0300)]
Fixed ngx_open_cached_file() error handling.

If of.err is 0, it means that there was a memory allocation error
and no further logging and/or processing is needed.  The of.failed
string can be only accessed if of.err is not 0.

9 years agoCore: set nginx_shared_zone name via ngx_str_set().
Ruslan Ermilov [Tue, 28 Mar 2017 08:28:51 +0000 (11:28 +0300)]
Core: set nginx_shared_zone name via ngx_str_set().

9 years agoUse ngx_array_init() to initialize arrays.
Ruslan Ermilov [Tue, 28 Mar 2017 08:28:42 +0000 (11:28 +0300)]
Use ngx_array_init() to initialize arrays.

9 years agoVersion bump.
Ruslan Ermilov [Tue, 28 Mar 2017 08:28:36 +0000 (11:28 +0300)]
Version bump.

9 years agorelease-1.11.12 tag
Maxim Dounin [Fri, 24 Mar 2017 15:05:06 +0000 (18:05 +0300)]
release-1.11.12 tag

9 years agonginx-1.11.12-RELEASE release-1.11.12
Maxim Dounin [Fri, 24 Mar 2017 15:05:05 +0000 (18:05 +0300)]
nginx-1.11.12-RELEASE

9 years agoFixed CPU hog while freeing hc->busy after e662cbf1b932 (1.11.11).
Maxim Dounin [Fri, 24 Mar 2017 13:26:12 +0000 (16:26 +0300)]
Fixed CPU hog while freeing hc->busy after e662cbf1b932 (1.11.11).

Reported by Richard Stanway,
http://mailman.nginx.org/pipermail/nginx/2017-March/053296.html.

9 years agoSimplified code about duplicate root/alias directive.
Ruslan Ermilov [Wed, 22 Mar 2017 20:36:35 +0000 (23:36 +0300)]
Simplified code about duplicate root/alias directive.

9 years agoUnified error messages about duplicate directives.
Ruslan Ermilov [Wed, 22 Mar 2017 19:49:52 +0000 (22:49 +0300)]
Unified error messages about duplicate directives.

9 years agoVersion bump.
Ruslan Ermilov [Wed, 22 Mar 2017 19:49:42 +0000 (22:49 +0300)]
Version bump.

9 years agorelease-1.11.11 tag
Maxim Dounin [Tue, 21 Mar 2017 15:04:22 +0000 (18:04 +0300)]
release-1.11.11 tag

9 years agonginx-1.11.11-RELEASE release-1.11.11
Maxim Dounin [Tue, 21 Mar 2017 15:04:22 +0000 (18:04 +0300)]
nginx-1.11.11-RELEASE

9 years agoAdded HTTP/2 to win32 builds.
Maxim Dounin [Tue, 21 Mar 2017 14:28:15 +0000 (17:28 +0300)]
Added HTTP/2 to win32 builds.

9 years agoFixed a comment.
Ruslan Ermilov [Fri, 17 Mar 2017 09:09:31 +0000 (12:09 +0300)]
Fixed a comment.

9 years agoConfigure: fixed --without_http.
Ruslan Ermilov [Thu, 16 Mar 2017 17:38:31 +0000 (20:38 +0300)]
Configure: fixed --without_http.

Instead of turning off some randomly selected http modules
when --without-http is specified, just don't process the
whole http modules section.

9 years agoConfigure: fixed build with --with-stream.
Ruslan Ermilov [Thu, 16 Mar 2017 17:38:26 +0000 (20:38 +0300)]
Configure: fixed build with --with-stream.

Some combinations of options might cause the builds with the
--with-stream option to break due to invalid value of the
STREAM_INCS make variable, e.g.

auto/configure \
    --with-stream \
    --with-http_perl_module=dynamic \
    --without-http_memcached_module \
    --without-http_empty_gif_module \
    --without-http_browser_module \
    --without-http_upstream_hash_module \
    --without-http_upstream_ip_hash_module \
    --without-http_upstream_least_conn_module \
    --without-http_upstream_keepalive_module \
    --without-http_upstream_zone_module \

Explicit initialization of ngx_module_libs and ngx_module_link
matches what we already do when processing mail modules, and
is also required after the next change.

9 years agoAdded missing "static" specifier found by gcc -Wtraditional.
Ruslan Ermilov [Thu, 16 Mar 2017 16:01:05 +0000 (19:01 +0300)]
Added missing "static" specifier found by gcc -Wtraditional.

This has somehow escaped from fbdaad9b0e7b.

9 years agoStyle.
Maxim Dounin [Tue, 7 Mar 2017 15:51:17 +0000 (18:51 +0300)]
Style.

9 years agoIntroduced worker_shutdown_timeout.
Maxim Dounin [Tue, 7 Mar 2017 15:51:16 +0000 (18:51 +0300)]
Introduced worker_shutdown_timeout.

The directive configures a timeout to be used when gracefully shutting down
worker processes.  When the timer expires, nginx will try to close all
the connections currently open to facilitate shutdown.

9 years agoCancelable timers are now preserved if there are other timers.
Maxim Dounin [Tue, 7 Mar 2017 15:51:15 +0000 (18:51 +0300)]
Cancelable timers are now preserved if there are other timers.

There is no need to cancel timers early if there are other timers blocking
shutdown anyway.  Preserving such timers allows nginx to continue some
periodic work till the shutdown is actually possible.

With the new approach, timers with ev->cancelable are simply ignored when
checking if there are any timers left during shutdown.

9 years agoCore: introduced ngx_rbtree_next().
Maxim Dounin [Tue, 7 Mar 2017 15:51:13 +0000 (18:51 +0300)]
Core: introduced ngx_rbtree_next().

9 years agoAccess log: removed dead ev->timedout check in flush timer handler.
Maxim Dounin [Tue, 7 Mar 2017 15:51:12 +0000 (18:51 +0300)]
Access log: removed dead ev->timedout check in flush timer handler.

The ev->timedout flag is set on first timer expiration, and never reset
after it.  Due to this the code to stop the timer when the timer was
canceled never worked (except in a very specific time frame immediately
after start), and the timer was always armed again.  This essentially
resulted in a buffer flush at the end of an event loop iteration.

This behaviour actually seems to be better than just stopping the flush
timer for the whole shutdown, so it is preserved as is instead of fixing
the code to actually remove the timer.  It will be further improved by
upcoming changes to preserve cancelable timers if there are other timers
blocking shutdown.

9 years agoConverted hc->busy/hc->free to use chain links.
Maxim Dounin [Tue, 7 Mar 2017 15:49:31 +0000 (18:49 +0300)]
Converted hc->busy/hc->free to use chain links.

Most notably, this fixes possible buffer overflows if number of large
client header buffers in a virtual server is different from the one in
the default server.

Reported by Daniil Bondarev.

9 years agoRemoved casts not needed after 1f513d7f1b45.
Ruslan Ermilov [Tue, 7 Mar 2017 08:47:58 +0000 (11:47 +0300)]
Removed casts not needed after 1f513d7f1b45.

9 years agoMail: don't emit separator in capability lists for APOP.
Sergey Kandaurov [Mon, 6 Mar 2017 14:56:23 +0000 (17:56 +0300)]
Mail: don't emit separator in capability lists for APOP.

Notably, this fixes CAPA and AUTH output.

The bug had appeared in nginx 1.11.6 (73b451d304c0).

9 years agoAdded missing "static" specifiers found by gcc -Wtraditional.
Ruslan Ermilov [Mon, 6 Mar 2017 08:09:47 +0000 (11:09 +0300)]
Added missing "static" specifiers found by gcc -Wtraditional.

9 years agoAdded missing static specifiers.
Eran Kornblau [Thu, 2 Mar 2017 13:46:00 +0000 (08:46 -0500)]
Added missing static specifiers.

9 years agoContrib: vim syntax, update 3rd party module directives.
othree [Wed, 1 Mar 2017 15:41:39 +0000 (23:41 +0800)]
Contrib: vim syntax, update 3rd party module directives.

9 years agoFixed background update with "if".
Maxim Dounin [Mon, 27 Feb 2017 19:36:15 +0000 (22:36 +0300)]
Fixed background update with "if".

Cloned subrequests should inherit r->content_handler.  This way they will
be able to use the same location configuration as the original request
if there are "if" directives in the configuration.

Without r->content_handler inherited, the following configuration tries
to access a static file in the update request:

    location / {
        set $true 1;
        if ($true) {
            # nothing
        }

        proxy_pass http://backend;
        proxy_cache one;
        proxy_cache_use_stale updating;
        proxy_cache_background_update on;
    }

See http://mailman.nginx.org/pipermail/nginx/2017-February/053019.html for
initial report.

9 years agoContrib: vim syntax, update core module directives.
othree [Fri, 24 Feb 2017 10:05:58 +0000 (18:05 +0800)]
Contrib: vim syntax, update core module directives.

9 years agoContrib: vim syntax, listen option and SSL/Mail protocol keywords.
othree [Wed, 22 Feb 2017 04:26:41 +0000 (12:26 +0800)]
Contrib: vim syntax, listen option and SSL/Mail protocol keywords.

9 years agoFixed ngx_parse_size() / ngx_parse_offset() with 0-length strings.
Maxim Dounin [Fri, 17 Feb 2017 14:01:27 +0000 (17:01 +0300)]
Fixed ngx_parse_size() / ngx_parse_offset() with 0-length strings.

9 years agoTrailing space removed.
Maxim Dounin [Thu, 16 Feb 2017 15:37:22 +0000 (18:37 +0300)]
Trailing space removed.

9 years agoDocs: changes.xslt regenerated.
Maxim Dounin [Thu, 16 Feb 2017 15:33:03 +0000 (18:33 +0300)]
Docs: changes.xslt regenerated.

9 years agoDocs: changes.xml dates converted to ISO 8601 format.
Maxim Dounin [Thu, 16 Feb 2017 15:32:49 +0000 (18:32 +0300)]
Docs: changes.xml dates converted to ISO 8601 format.

Dates in ISO 8601 format are in line with what is used in nginx.org news,
and are generally less ambiguous and easier to work with.

The changes.xml was converted using sed:

$ sed 's/date="\(..\)\.\(..\)\.\(....\)"/date="\3-\2-\1"/g' changes.xml

Appropriate changes to changes.xsls were introduced.

9 years agoVersion bump.
Maxim Dounin [Thu, 16 Feb 2017 15:20:14 +0000 (18:20 +0300)]
Version bump.

9 years agorelease-1.11.10 tag
Maxim Dounin [Tue, 14 Feb 2017 15:36:04 +0000 (18:36 +0300)]
release-1.11.10 tag

9 years agonginx-1.11.10-RELEASE release-1.11.10
Maxim Dounin [Tue, 14 Feb 2017 15:36:04 +0000 (18:36 +0300)]
nginx-1.11.10-RELEASE

9 years agoGzip: free chain links on the hot path (ticket #1046).
Maxim Dounin [Mon, 13 Feb 2017 18:45:01 +0000 (21:45 +0300)]
Gzip: free chain links on the hot path (ticket #1046).

9 years agoUpstream: read handler cleared on upstream finalization.
Maxim Dounin [Fri, 10 Feb 2017 17:24:26 +0000 (20:24 +0300)]
Upstream: read handler cleared on upstream finalization.

With "proxy_ignore_client_abort off" (the default), upstream module changes
r->read_event_handler to ngx_http_upstream_rd_check_broken_connection().
If the handler is not cleared during upstream finalization, it can be
triggered later, causing unexpected effects, if, for example, a request
was redirected to a different location using error_page or X-Accel-Redirect.
In particular, it makes "proxy_ignore_client_abort on" non-working after
a redirection in a configuration like this:

    location = / {
        error_page 502 = /error;
        proxy_pass http://127.0.0.1:8082;
    }

    location /error {
        proxy_pass http://127.0.0.1:8083;
        proxy_ignore_client_abort on;
    }

It is also known to cause segmentation faults with aio used, see
http://mailman.nginx.org/pipermail/nginx-ru/2015-August/056570.html.

Fix is to explicitly set r->read_event_handler to ngx_http_block_reading()
during upstream finalization, similar to how it is done in the request body
reading code and in the limit_req module.

9 years agoCache: increased cache header Vary and ETag lengths to 128.
Maxim Dounin [Fri, 10 Feb 2017 14:49:19 +0000 (17:49 +0300)]
Cache: increased cache header Vary and ETag lengths to 128.

This allows to store larger ETag values for proxy_cache_revalidate,
including ones generated as SHA256, and cache responses with longer
Vary (ticket #826).

In particular, this fixes caching of Amazon S3 responses with CORS
enabled, which now use "Vary: Origin, Access-Control-Request-Headers,
Access-Control-Request-Method".

Cache version bumped accordingly.

9 years agoSlice filter: fetch slices in cloned subrequests.
Roman Arutyunyan [Fri, 10 Feb 2017 13:33:12 +0000 (16:33 +0300)]
Slice filter: fetch slices in cloned subrequests.

Previously, slice subrequest location was selected based on request URI.
If request is then redirected to a new location, its context array is cleared,
making the slice module loose current slice range information.  This lead to
broken output.  Now subrequests with the NGX_HTTP_SUBREQUEST_CLONE flag are
created for slices.  Such subrequests stay in the same location as the parent
request and keep the right slice context.

9 years agoUpstream: proxy_cache_background_update and friends.
Roman Arutyunyan [Fri, 10 Feb 2017 12:13:41 +0000 (15:13 +0300)]
Upstream: proxy_cache_background_update and friends.

The directives enable cache updates in subrequests.

9 years agoCache: support for stale-while-revalidate and stale-if-error.
Roman Arutyunyan [Thu, 22 Dec 2016 11:25:34 +0000 (14:25 +0300)]
Cache: support for stale-while-revalidate and stale-if-error.

Previously, there was no way to enable the proxy_cache_use_stale behavior by
reading the backend response.  Now, stale-while-revalidate and stale-if-error
Cache-Control extensions (RFC 5861) are supported.  They specify, how long a
stale response can be used when a cache entry is being updated, or in case of
an error.

9 years agoRequest body: commented out debug printing of old buffers.
Maxim Dounin [Wed, 8 Feb 2017 16:36:03 +0000 (19:36 +0300)]
Request body: commented out debug printing of old buffers.

This is not really needed in practice, and causes excessive debug output
in some of our tests.

9 years agoRequest body: c->error on "100 Continue" errors (ticket #1194).
Maxim Dounin [Wed, 8 Feb 2017 16:35:31 +0000 (19:35 +0300)]
Request body: c->error on "100 Continue" errors (ticket #1194).

9 years agoSSL: clear error queue after OPENSSL_init_ssl().
Sergey Kandaurov [Mon, 6 Feb 2017 15:38:06 +0000 (18:38 +0300)]
SSL: clear error queue after OPENSSL_init_ssl().

The function may leave error in the error queue while returning success,
e.g., when taking a DSO reference to itself as of OpenSSL 1.1.0d:
https://git.openssl.org/?p=openssl.git;a=commit;h=4af9f7f

Notably, this fixes alert seen with statically linked OpenSSL on some platforms.

While here, check OPENSSL_init_ssl() return value.

9 years agoSSL: fixed ssl_buffer_size on SNI virtual hosts (ticket #1192).
Maxim Dounin [Thu, 2 Feb 2017 17:29:16 +0000 (20:29 +0300)]
SSL: fixed ssl_buffer_size on SNI virtual hosts (ticket #1192).

Previously, buffer size was not changed from the one saved during
initial ngx_ssl_create_connection(), even if the buffer itself was not
yet created.  Fix is to change c->ssl->buffer_size in the SNI callback.

Note that it should be also possible to update buffer size even in non-SNI
virtual hosts as long as the buffer is not yet allocated.  This looks
like an overcomplication though.

9 years agoConfigure: removed execute bit from auto/unix.
Sergey Kandaurov [Wed, 1 Feb 2017 17:04:06 +0000 (20:04 +0300)]
Configure: removed execute bit from auto/unix.

9 years agoVariables: generic prefix variables.
Dmitry Volyntsev [Tue, 31 Jan 2017 18:19:58 +0000 (21:19 +0300)]
Variables: generic prefix variables.

9 years agoImplemented the "server_tokens build" option.
Ruslan Ermilov [Tue, 31 Jan 2017 09:09:40 +0000 (12:09 +0300)]
Implemented the "server_tokens build" option.

Based on a patch by Tom Thorogood.

9 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Fri, 27 Jan 2017 16:06:35 +0000 (19:06 +0300)]
Updated OpenSSL used for win32 builds.

9 years agoUpstream: removed unused bl_time and bl_state fields.
Maxim Dounin [Thu, 26 Jan 2017 13:16:48 +0000 (16:16 +0300)]
Upstream: removed unused bl_time and bl_state fields.

9 years agoUpstream: removed unused ngx_http_upstream_conf_t.timeout field.
Thibault Charbonnier [Wed, 25 Jan 2017 01:52:39 +0000 (17:52 -0800)]
Upstream: removed unused ngx_http_upstream_conf_t.timeout field.

9 years agoUpstream: removed compatibility shims from ngx_http_upstream_t.
Vladimir Homutov [Wed, 25 Jan 2017 12:39:22 +0000 (15:39 +0300)]
Upstream: removed compatibility shims from ngx_http_upstream_t.

The type is no longer modified in NGINX Plus.

9 years agoVersion bump.
Vladimir Homutov [Thu, 26 Jan 2017 08:44:55 +0000 (11:44 +0300)]
Version bump.

9 years agorelease-1.11.9 tag
Maxim Dounin [Tue, 24 Jan 2017 14:02:19 +0000 (17:02 +0300)]
release-1.11.9 tag

9 years agonginx-1.11.9-RELEASE release-1.11.9
Maxim Dounin [Tue, 24 Jan 2017 14:02:18 +0000 (17:02 +0300)]
nginx-1.11.9-RELEASE

9 years agoUpdated zlib and PCRE used for win32 builds.
Maxim Dounin [Tue, 24 Jan 2017 13:41:29 +0000 (16:41 +0300)]
Updated zlib and PCRE used for win32 builds.

9 years agoUpstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin [Fri, 20 Jan 2017 18:14:19 +0000 (21:14 +0300)]
Upstream: fixed cache corruption and socket leaks with aio_write.

The ngx_event_pipe() function wasn't called on write events with
wev->delayed set.  As a result, threaded writing results weren't
properly collected in ngx_event_pipe_write_to_downstream() when a
write event was triggered for a completed write.

Further, this wasn't detected, as p->aio was reset by a thread completion
handler, and results were later collected in ngx_event_pipe_read_upstream()
instead of scheduling a new write of additional data.  If this happened
on the last reading from an upstream, last part of the response was never
written to the cache file.

Similar problems might also happen in case of timeouts when writing to
client, as this also results in ngx_event_pipe() not being called on write
events.  In this scenario socket leaks were observed.

Fix is to check if p->writing is set in ngx_event_pipe_read_upstream(), and
therefore collect results of previous write operations in case of read events
as well, similar to how we do so in ngx_event_pipe_write_downstream().
This is enough to fix the wev->delayed case.  Additionally, we now call
ngx_event_pipe() from ngx_http_upstream_process_request() if there are
uncollected write operations (p->writing and !p->aio).  This also fixes
the wev->timedout case.

9 years agoRemoved pthread mutex / conditional variables debug messages.
Maxim Dounin [Fri, 20 Jan 2017 18:14:18 +0000 (21:14 +0300)]
Removed pthread mutex / conditional variables debug messages.

These messages doesn't seem to be needed in practice and only make
debugging logs harder to read.

9 years agoFixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin [Fri, 20 Jan 2017 18:12:48 +0000 (21:12 +0300)]
Fixed trailer construction with limit on FreeBSD and macOS.

The ngx_chain_coalesce_file() function may produce more bytes to send then
requested in the limit passed, as it aligns the last file position
to send to memory page boundary.  As a result, (limit - send) may become
negative.  This resulted in big positive number when converted to size_t
while calling ngx_output_chain_to_iovec().

Another part of the problem is in ngx_chain_coalesce_file(): it changes cl
to the next chain link even if the current buffer is only partially sent
due to limit.

Therefore, if a file buffer was not expected to be fully sent due to limit,
and was followed by a memory buffer, nginx called sendfile() with a part
of the file buffer, and the memory buffer in trailer.  If there were enough
room in the socket buffer, this resulted in a part of the file buffer being
skipped, and corresponding part of the memory buffer sent instead.

The bug was introduced in 8e903522c17a (1.7.8).  Configurations affected
are ones using limits, that is, limit_rate and/or sendfile_max_chunk, and
memory buffers after file ones (may happen when using subrequests or
with proxying with disk buffering).

Fix is to explicitly check if (send < limit) before constructing trailer
with ngx_output_chain_to_iovec().  Additionally, ngx_chain_coalesce_file()
was modified to preserve unfinished file buffers in cl.

9 years agoImproved connection draining with small number of connections.
Maxim Dounin [Fri, 20 Jan 2017 11:03:20 +0000 (14:03 +0300)]
Improved connection draining with small number of connections.

Closing up to 32 connections might be too aggressive if worker_connections
is set to a comparable number (and/or there are only a small number of
reusable connections).  If an occasional connection shorage happens in
such a configuration, it leads to closing all reusable connections instead
of gradually reducing keepalive timeout to a smaller value.  To improve
granularity in such configurations we now close no more than 1/8 of all
reusable connections at once.

Suggested by Joel Cunningham.

9 years agoAdded cycle parameter to ngx_drain_connections().
Maxim Dounin [Fri, 20 Jan 2017 11:03:19 +0000 (14:03 +0300)]
Added cycle parameter to ngx_drain_connections().

No functional changes, mostly style.

9 years agoStream: client SSL certificates were not checked in some cases.
Vladimir Homutov [Thu, 19 Jan 2017 13:20:07 +0000 (16:20 +0300)]
Stream: client SSL certificates were not checked in some cases.

If ngx_stream_ssl_init_connection() succeeded immediately, the check was not
done.

The bug had appeared in 1.11.8 (41cb1b64561d).

9 years agoStream: fixed handling of non-ssl sessions.
Vladimir Homutov [Thu, 19 Jan 2017 13:17:05 +0000 (16:17 +0300)]
Stream: fixed handling of non-ssl sessions.

A missing check could cause ngx_stream_ssl_handler() to be applied
to a non-ssl session, which resulted in a null pointer dereference
if ssl_verify_client is enabled.

The bug had appeared in 1.11.8 (41cb1b64561d).

9 years agoMail: make it possible to disable SASL EXTERNAL.
Sergey Kandaurov [Thu, 12 Jan 2017 16:22:03 +0000 (19:22 +0300)]
Mail: make it possible to disable SASL EXTERNAL.

9 years agoStream: avoid infinite loop in case of socket read error.
Vladimir Homutov [Wed, 11 Jan 2017 09:01:56 +0000 (12:01 +0300)]
Stream: avoid infinite loop in case of socket read error.

9 years agoYear 2017.
Ruslan Ermilov [Tue, 10 Jan 2017 14:13:06 +0000 (17:13 +0300)]
Year 2017.

9 years agoVersion bump.
Ruslan Ermilov [Tue, 10 Jan 2017 14:13:01 +0000 (17:13 +0300)]
Version bump.

9 years agorelease-1.11.8 tag
Maxim Dounin [Tue, 27 Dec 2016 14:23:08 +0000 (17:23 +0300)]
release-1.11.8 tag

9 years agonginx-1.11.8-RELEASE release-1.11.8
Maxim Dounin [Tue, 27 Dec 2016 14:23:07 +0000 (17:23 +0300)]
nginx-1.11.8-RELEASE

9 years agoStream: speed up TCP peer recovery.
Roman Arutyunyan [Mon, 26 Dec 2016 11:27:05 +0000 (14:27 +0300)]
Stream: speed up TCP peer recovery.

Previously, an unavailable peer was considered recovered after a successful
proxy session to this peer.  Until then, only a single client connection per
fail_timeout was allowed to be proxied to the peer.

Since stream sessions can be long, it may take indefinite time for a peer to
recover, limiting the ability of the peer to receive new connections.

Now, a peer is considered recovered after a successful TCP connection is
established to it.  Balancers are notified of this event via the notify()
callback.

9 years agoWin32: compatiblity with OpenSSL 1.1.0.
Maxim Dounin [Sat, 24 Dec 2016 15:01:14 +0000 (18:01 +0300)]
Win32: compatiblity with OpenSSL 1.1.0.

OpenSSL 1.1.0 now uses normal "nmake; nmake install" instead of using
custom "ms\do_ms.bat" script and "ms\nt.mak" makefile.  And Configure
now requires --prefix to be absolute, and no longer derives --openssldir
from prefix (so it's specified explicitly).  Generated libraries are now
called "libcrypto.lib" and "libssl.lib" instead of "libeay32.lib"
and "ssleay32.lib".  Appropriate tests added to support both old and new
variants.

Additionally, openssl/lhash.h now triggers warning C4090 ('function' :
different 'const' qualifiers), so the warning was disabled.

9 years agoWin32: support 64-bit compilation with MSVC.
Maxim Dounin [Sat, 24 Dec 2016 15:01:14 +0000 (18:01 +0300)]
Win32: support 64-bit compilation with MSVC.

There are lots of C4244 warnings (conversion from 'type1' to 'type2',
possible loss of data), so they were disabled.

The same applies to C4267 warnings (conversion from 'size_t' to 'type',
possible loss of data), most notably - conversion from ngx_str_t.len to
ngx_variable_value_t.len (which is unsigned:28).  Additionally, there
is at least one case when it is not possible to fix the warning properly
without introducing win32-specific code: recv() on win32 uses "int len",
while POSIX defines "size_t len".

The ssize_t type now properly defined for 64-bit compilation with MSVC.
Caught by warning C4305 (truncation from '__int64' to 'ssize_t'), on
"cutoff = NGX_MAX_SIZE_T_VALUE / 10" in ngx_atosz()).

Several C4334 warnings (result of 32-bit shift implicitly converted to 64 bits)
were fixed by adding explicit conversions.

Several C4214 warnings (nonstandard extension used: bit field types other
than int) in ngx_http_script.h fixed by changing bit field types from
uintptr_t to unsigned.

9 years agoWin32: fixed some warnings reported by Borland C.
Maxim Dounin [Sat, 24 Dec 2016 15:01:14 +0000 (18:01 +0300)]
Win32: fixed some warnings reported by Borland C.

Most notably, warning W8012 (comparing signed and unsigned values) reported
in multiple places where an unsigned value of small type (e.g., u_short) is
promoted to an int and compared to an unsigned value.

Warning W8072 (suspicious pointer arithmetic) disabled, it is reported
when we increment base pointer in ngx_shm_alloc().

9 years agoWin32: minimized redefinition of ssize_t.
Maxim Dounin [Sat, 24 Dec 2016 15:01:14 +0000 (18:01 +0300)]
Win32: minimized redefinition of ssize_t.

All variants of GCC have ssize_t available, there is no need to
redefine it.

9 years agoWin32: minimized redefinition of intptr_t/uintptr_t.
Maxim Dounin [Sat, 24 Dec 2016 15:01:14 +0000 (18:01 +0300)]
Win32: minimized redefinition of intptr_t/uintptr_t.

These types are available with MSVC (at least since 2003, in stddef.h),
all variants of GCC (in stdint.h) and Watcom C.  We need to define them
only for Borland C.

9 years agoWin32: stdint.h used for MinGW GCC.
Maxim Dounin [Sat, 24 Dec 2016 15:01:14 +0000 (18:01 +0300)]
Win32: stdint.h used for MinGW GCC.

There is no need to restrict stdint.h only to MinGW-w64 GCC, it is
available with MinGW GCC as well.

9 years agoWin32: fixed building with newer versions of MinGW GCC.
Maxim Dounin [Sat, 24 Dec 2016 15:01:14 +0000 (18:01 +0300)]
Win32: fixed building with newer versions of MinGW GCC.

Macro to indicate that off_t was defined has been changed, so we now
additionally define the new one.

9 years agoWin32: added a variable to specify compiler.
Maxim Dounin [Sat, 24 Dec 2016 15:01:14 +0000 (18:01 +0300)]
Win32: added a variable to specify compiler.

This allows to set a different one from command line when needed.
For example, to configure nginx with gcc as a compiler one could
use "make -f misc/GNUmakefile win32 CC=gcc".

9 years agoSSL: support AES256 encryption of tickets.
Maxim Dounin [Fri, 23 Dec 2016 14:28:20 +0000 (17:28 +0300)]
SSL: support AES256 encryption of tickets.

This implies ticket key size of 80 bytes instead of previously used 48,
as both HMAC and AES keys are 32 bytes now.  When an old 48-byte ticket key
is provided, we fall back to using backward-compatible AES128 encryption.

OpenSSL switched to using AES256 in 1.1.0, and we are providing equivalent
security.  While here, order of HMAC and AES keys was reverted to make
the implementation compatible with keys used by OpenSSL with
SSL_CTX_set_tlsext_ticket_keys().

Prodded by Christian Klinger.

9 years agoFixed missing "Location" field with some relative redirects.
Ruslan Ermilov [Thu, 22 Dec 2016 08:58:52 +0000 (11:58 +0300)]
Fixed missing "Location" field with some relative redirects.

Relative redirects did not work with directory redirects and
auto redirects issued by nginx.

9 years agoCore: relative redirects (closes #1000).
Ruslan Ermilov [Wed, 21 Dec 2016 20:10:51 +0000 (23:10 +0300)]
Core: relative redirects (closes #1000).

The current version of HTTP/1.1 standard allows relative references in
redirects (https://tools.ietf.org/html/rfc7231#section-7.1.2).

Allow this form for redirects generated by nginx by introducing the new
directive absolute_redirect.

9 years agoLimited recursion when evaluating variables.
Ruslan Ermilov [Wed, 21 Dec 2016 19:01:24 +0000 (22:01 +0300)]
Limited recursion when evaluating variables.

Unlimited recursion might cause stack exhaustion in some misconfigurations.

9 years agoStream: client SSL certificates verification support.
Vladimir Homutov [Tue, 20 Dec 2016 09:05:14 +0000 (12:05 +0300)]
Stream: client SSL certificates verification support.

New directives: "ssl_verify_client", "ssl_verify_depth",
"ssl_client_certificate", "ssl_trusted_certificate", and
"ssl_crl".

New variables: $ssl_client_cert, $ssl_client_raw_cert,
$ssl_client_s_dn, $ssl_client_i_dn, $ssl_client_serial,
$ssl_client_fingerprint, $ssl_client_verify, $ssl_client_v_start,
$ssl_client_v_end, and $ssl_client_v_remain.

9 years agoStream ssl_preread: relaxed SSL version check.
Roman Arutyunyan [Mon, 19 Dec 2016 11:02:39 +0000 (14:02 +0300)]
Stream ssl_preread: relaxed SSL version check.

SSL version 3.0 can be specified by the client at the record level for
compatibility reasons.  Previously, ssl_preread module rejected such
connections, presuming they don't have SNI.  Now SSL 3.0 is allowed at
the record level.

9 years agoConfigure: detect nginx version for nginx.pm at make time.
Ruslan Ermilov [Fri, 16 Dec 2016 16:54:37 +0000 (19:54 +0300)]
Configure: detect nginx version for nginx.pm at make time.

9 years agoResolver: fixed handling of partially resolved SRV.
Dmitry Volyntsev [Fri, 16 Dec 2016 15:21:55 +0000 (18:21 +0300)]
Resolver: fixed handling of partially resolved SRV.

The resolver handles SRV requests in two stages.  In the first
stage it gets all SRV RRs, and in the second stage it resolves
the names from SRV RRs into addresses.

Previously, if a response to an SRV request was cached, the
queries to resolve names were not limited by a timeout.  If a
response to any of these queries was not received, the SRV
request could never complete.

If a response to an SRV request was not cached, and some of the
queries to resolve names timed out, NGX_RESOLVE_TIMEDOUT was
returned instead of successfully resolved addresses.

To fix both issues, resolving of names is now always limited by
a timeout.

9 years agoResolver: fixed a race between parallel name and addr resolves.
Dmitry Volyntsev [Fri, 16 Dec 2016 15:21:55 +0000 (18:21 +0300)]
Resolver: fixed a race between parallel name and addr resolves.

Previously, ngx_resolve_name() and ngx_resolve_addr() may have
rescheduled the resend timer while it was already in progress.

9 years agoResolver: fixed possible premature stop of the resend timer.
Dmitry Volyntsev [Fri, 16 Dec 2016 15:21:42 +0000 (18:21 +0300)]
Resolver: fixed possible premature stop of the resend timer.

Previously, ngx_resolve_name_done() and ngx_resolve_addr_done()
may have stopped the resend timer prematurely while srv_resend_queue
was not empty.

9 years agoResolver: fixed possible use-after-free in worker on fast shutdown.
Ruslan Ermilov [Fri, 16 Dec 2016 11:53:28 +0000 (14:53 +0300)]
Resolver: fixed possible use-after-free in worker on fast shutdown.

The fix in a3dc657f4e95 was incomplete.

9 years agoResolver: fixed possible use-after-free in worker on fast shutdown.
Ruslan Ermilov [Thu, 15 Dec 2016 18:44:34 +0000 (21:44 +0300)]
Resolver: fixed possible use-after-free in worker on fast shutdown.

9 years agoSSL: backed out changeset e7cb5deb951d, reimplemented properly.
Maxim Dounin [Thu, 15 Dec 2016 16:00:23 +0000 (19:00 +0300)]
SSL: backed out changeset e7cb5deb951d, reimplemented properly.

Changeset e7cb5deb951d breaks build on CentOS 5 with "dereferencing
type-punned pointer will break strict-aliasing rules" warning.  It is
backed out.

Instead, to keep builds with BoringSSL happy, type of the "value"
variable changed to "char *", and an explicit cast added before calling
ngx_parse_http_time().

9 years agoSSL: fix call to BIO_get_mem_data().
Piotr Sikora [Tue, 13 Dec 2016 22:19:30 +0000 (14:19 -0800)]
SSL: fix call to BIO_get_mem_data().

Fixes build with BoringSSL.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
9 years agoAccess log: support for json escaping.
Valentin Bartenev [Thu, 15 Dec 2016 13:25:42 +0000 (16:25 +0300)]
Access log: support for json escaping.