summaryrefslogtreecommitdiffhomepage
path: root/src/http (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2016-03-28Upstream: proxy_next_upstream non_idempotent.Maxim Dounin6-1/+12
By default, requests with non-idempotent methods (POST, LOCK, PATCH) are no longer retried in case of errors if a request was already sent to a backend. Previous behaviour can be restored by using "proxy_next_upstream ... non_idempotent".
2016-03-28Upstream: cached connections now tested against next_upstream.Maxim Dounin1-49/+42
Much like normal connections, cached connections are now tested against u->conf->next_upstream, and u->state->status is now always set. This allows to disable additional tries even with upstream keepalive by using "proxy_next_upstream off".
2016-03-28Sub filter: fixed allocation alignment.Roman Arutyunyan1-4/+4
2016-03-23Resolver: added support for SRV records.Dmitry Volyntsev1-1/+1
2016-03-22Backed out server_tokens changes.Maxim Dounin5-163/+45
Backed out changesets: cf3e75cfa951, 6b72414dfb4f, 602dc42035fe, e5076b96fd01.
2016-03-23Cache: fixed slots accounting error introduced in c9d680b00744.Dmitry Volyntsev1-2/+2
2016-03-22Reconsidered server_tokens with an empty value.Ruslan Ermilov3-20/+11
An empty value will be treated as "off".
2016-03-21HTTP/2: improved debugging of sending control frames.Valentin Bartenev1-2/+13
2016-03-18Cache: added watermark to reduce IO load when keys_zone is full.Dmitry Volyntsev2-5/+34
When a keys_zone is full then each next request to the cache is penalized. That is, the cache has to evict older files to get a slot from the keys_zone synchronously. The patch introduces new behavior in this scenario. Manager will try to maintain available free slots in the keys_zone by cleaning old files in the background.
2016-03-18Cache: report error if slab allocator fails during cache loading.Dmitry Volyntsev2-0/+8
2016-03-18Threads: writing via threads pools in event pipe.Maxim Dounin3-1/+126
The "aio_write" directive is introduced, which enables use of aio for writing. Currently it is meaningful only with "aio threads". Note that aio operations can be done by both event pipe and output chain, so proper mapping between r->aio and p->aio is provided when calling ngx_event_pipe() and in output filter. In collaboration with Valentin Bartenev.
2016-03-18Threads: task pointer stored in ngx_file_t.Maxim Dounin1-2/+3
This simplifies the interface of the ngx_thread_read() function. Additionally, most of the thread operations now explicitly set file->thread_task, file->thread_handler and file->thread_ctx, to facilitate use of thread operations in other places. (Potential problems remain with sendfile in threads though - it uses file->thread_handler as set in ngx_output_chain(), and it should not be overwritten to an incompatible one.) In collaboration with Valentin Bartenev.
2016-03-16Style.Ruslan Ermilov1-4/+4
2016-03-15Win32: fixed build after cf3e75cfa951.Ruslan Ermilov1-0/+4
2016-03-15Win32: fixed build after cf3e75cfa951.Ruslan Ermilov1-0/+4
2016-03-15Added variables support to server_tokens.Ruslan Ermilov5-47/+166
It can now be set to "off" conditionally, e.g. using the map directive. An empty value will disable the emission of the Server: header and the signature in error messages generated by nginx. Any other value is treated as "on", meaning that full nginx version is emitted in the Server: header and error messages generated by nginx.
2016-03-08Upstream: avoid closing client connection in edge case.Justin Li1-0/+5
If proxy_cache is enabled, and proxy_no_cache tests true, it was previously possible for the client connection to be closed after a 304. The fix is to recheck r->header_only after the final cacheability is determined, and end the request if no longer cacheable. Example configuration: proxy_cache foo; proxy_cache_bypass 1; proxy_no_cache 1; If a client sends If-None-Match, and the upstream server returns 200 with a matching ETag, no body should be returned to the client. At the start of ngx_http_upstream_send_response proxy_no_cache is not yet tested, thus cacheable is still 1 and downstream_error is set. However, by the time the downstream_error check is done in process_request, proxy_no_cache has been tested and cacheable is set to 0. The client connection is then closed, regardless of keepalive.
2016-03-10Upstream: fixed "zero size buf" alerts with cache (ticket #918).Maxim Dounin1-1/+2
If caching was used, "zero size buf in output" alerts might appear in logs if a client prematurely closed connection. Alerts appeared in the following situation: - writing to client returned an error, so event pipe drained all busy buffers leaving body output filters in an invalid state; - when upstream response was fully received, ngx_http_upstream_finalize_request() tried to flush all pending data. Fix is to avoid flushing body if p->downstream_error is set.
2016-03-03Copy filter: fixed sendfile aio handlers to set ctx->aio.Maxim Dounin1-4/+12
Sendfile handlers (aio preload and thread handler) are called within ctx->output_filter() in ngx_output_chain(), and hence ctx->aio cannot be set directly in ngx_output_chain(). Meanwhile, it must be set to make sure loop within ngx_output_chain() will be properly terminated. There are no known cases that trigger the problem, though in theory something like aio + sub filter (something that needs body in memory, and can also free some memory buffers) + sendfile can result in "task already active" and "second aio post" alerts. The fix is to set ctx->aio in ngx_http_copy_aio_sendfile_preload() and ngx_http_copy_thread_handler(). For consistency, ctx->aio is no longer set explicitly in ngx_output_chain_copy_buf(), as it's now done in ngx_http_copy_thread_handler().
2016-03-01Request body: moved handling of the last part in the save filter.Valentin Bartenev1-69/+40
No functional changes.
2016-02-24HTTP/2: implemented per request timeouts (closes #626).Valentin Bartenev3-63/+147
Previously, there were only three timeouts used globally for the whole HTTP/2 connection: 1. Idle timeout for inactivity when there are no streams in processing (the "http2_idle_timeout" directive); 2. Receive timeout for incomplete frames when there are no streams in processing (the "http2_recv_timeout" directive); 3. Send timeout when there are frames waiting in the output queue (the "send_timeout" directive on a server level). Reaching one of these timeouts leads to HTTP/2 connection close. This left a number of scenarios when a connection can get stuck without any processing and timeouts: 1. A client has sent the headers block partially so nginx starts processing a new stream but cannot continue without the rest of HEADERS and/or CONTINUATION frames; 2. When nginx waits for the request body; 3. All streams are stuck on exhausted connection or stream windows. The first idea that was rejected was to detect when the whole connection gets stuck because of these situations and set the global receive timeout. The disadvantage of such approach would be inconsistent behaviour in some typical use cases. For example, if a user never replies to the browser's question about where to save the downloaded file, the stream will be eventually closed by a timeout. On the other hand, this will not happen if there's some activity in other concurrent streams. Now almost all the request timeouts work like in HTTP/1.x connections, so the "client_header_timeout", "client_body_timeout", and "send_timeout" are respected. These timeouts close the request. The global timeouts work as before. Previously, the c->write->delayed flag was abused to avoid setting timeouts on stream events. Now, the "active" and "ready" flags are manipulated instead to control the processing of individual streams.
2016-02-24HTTP/2: always use temporary pool for processing headers.Valentin Bartenev2-25/+37
This is required for implementing per request timeouts. Previously, the temporary pool was used only during skipping of headers and the request pool was used otherwise. That required switching of pools if the request was closed while parsing. It wasn't a problem since the request could be closed only after the validation of the fully parsed header. With the per request timeouts, the request can be closed at any moment, and switching of pools in the middle of parsing header name or value becomes a problem. To overcome this, the temporary pool is now always created and used. Special checks are added to keep it when either the stream is being processed or until header block is fully parsed.
2016-02-24HTTP/2: cleaned up state while closing stream.Valentin Bartenev1-0/+4
Without this the state might keep pointing to already closed stream.
2016-02-24Fixed buffer over-read while logging invalid request headers.Valentin Bartenev1-4/+3
Since 667aaf61a778 (1.1.17) the ngx_http_parse_header_line() function can return NGX_HTTP_PARSE_INVALID_HEADER when a header contains NUL character. In this case the r->header_end pointer isn't properly initialized, but the log message in ngx_http_process_request_headers() hasn't been adjusted. It used the pointer in size calculation, which might result in up to 2k buffer over-read. Found with afl-fuzz.
2016-02-18Headers filter: fixed "add_header ... '' always".Ruslan Ermilov1-8/+8
The "always" parameter was ignored if the header value was empty.
2016-02-16HTTP/2: added debug logging of response headers.Valentin Bartenev1-0/+41
Because of HPACK compression it's hard to see what headers are actually sent by the server.
2016-02-16HTTP/2: use local pointer instead of r->connection.Valentin Bartenev1-2/+2
No functional changes.
2016-02-12HTTP/2: fixed undefined behavior in ngx_http_v2_huff_encode().Valentin Bartenev1-2/+6
When the "pending" value is zero, the "buf" will be right shifted by the width of its type, which results in undefined behavior. Found by Coverity (CID 1352150).
2016-02-11HTTP/2: implemented HPACK Huffman encoding for response headers.Valentin Bartenev3-56/+343
This reduces the size of headers by over 30% on average. Based on the patch by Vlad Krasnov: http://mailman.nginx.org/pipermail/nginx-devel/2015-December/007682.html
2016-02-04Dynamic modules: changed ngx_modules to cycle->modules.Maxim Dounin4-37/+37
2016-02-04Dynamic modules: moved module-related stuff to separate files.Maxim Dounin1-8/+1
2016-02-04HTTP/2: fixed possible buffer overrun (ticket #893).Valentin Bartenev1-2/+2
Due to greater priority of the unary plus operator over the ternary operator the expression didn't work as expected. That might result in one byte less allocation than needed for the HEADERS frame buffer.
2016-02-02HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.Valentin Bartenev1-1/+11
2016-02-02HTTP/2: fixed request length accounting.Valentin Bartenev1-1/+10
Now it includes not only the received body size, but the size of headers block as well.
2016-02-02HTTP/2: fixed excessive memory allocation for pool cleanup.Valentin Bartenev1-1/+1
2016-02-02HTTP/2: removed unused field from ngx_http_v2_stream_t.Valentin Bartenev1-1/+0
2016-01-12Request body: removed surplus assigment, no functional changes.Valentin Bartenev1-6/+0
Setting rb->bufs to NULL is surplus after ngx_http_write_request_body() has returned NGX_OK.
2016-01-11Upstream: fixed changing method on X-Accel-Redirect.Maxim Dounin1-0/+1
Previously, only r->method was changed, resulting in handling of a request as GET within nginx itself, but not in requests to proxied servers. See http://mailman.nginx.org/pipermail/nginx/2015-December/049518.html.
2015-12-17Upstream: don't keep connections on early responses (ticket #669).Maxim Dounin3-0/+8
2015-12-17Fixed PROXY protocol on IPv6 sockets (ticket #858).Maxim Dounin1-0/+1
2015-12-09Fixed fastcgi_pass with UNIX socket and variables (ticket #855).Ruslan Ermilov1-1/+3
This was broken in a93345ee8f52 (1.9.8).
2015-12-08Slice filter: terminate first slice with last_in_chain flag.Roman Arutyunyan1-0/+1
This flag makes sub filter flush buffered data and optimizes allocation in copy filter.
2015-12-08Slice filter: never run subrequests when main request is buffered.Roman Arutyunyan1-0/+4
With main request buffered, it's possible, that a slice subrequest will send output before it. For example, while main request is waiting for aio read to complete, a slice subrequest can start an aio operation as well. The order in which aio callbacks are called is undetermined.
2015-12-08SSL: fixed possible segfault on renegotiation (ticket #845).Sergey Kandaurov1-0/+4
Skip SSL_CTX_set_tlsext_servername_callback in case of renegotiation. Do nothing in SNI callback as in this case it will be supplied with request in c->data which isn't expected and doesn't work this way. This was broken by b40af2fd1c16 (1.9.6) with OpenSSL master branch and LibreSSL.
2015-12-07Slice filter.Roman Arutyunyan3-5/+546
Splits a request into subrequests, each providing a specific range of response. The variable "$slice_range" must be used to set subrequest range and proper cache key. The directive "slice" sets slice size. The following example splits requests into 1-megabyte cacheable subrequests. server { listen 8000; location / { slice 1m; proxy_cache cache; proxy_cache_key $uri$is_args$args$slice_range; proxy_set_header Range $slice_range; proxy_cache_valid 200 206 1h; proxy_pass http://127.0.0.1:9000; } }
2015-12-07Upstream: fill r->headers_out.content_range from upstream response.Roman Arutyunyan1-0/+5
2015-12-03Style: NGX_PTR_SIZE replaced with sizeof(void *).Maxim Dounin1-1/+1
The NGX_PTR_SIZE macro is only needed in preprocessor directives where it's not possible to use sizeof().
2015-12-02Style.Maxim Dounin1-1/+1
2015-11-30Stop emulating a space character after r->method_name.Ruslan Ermilov2-4/+1
This is an API change. The proxy module was modified to not depend on this in 44122bddd9a1. No known third-party modules seem to depend on this.
2015-11-06Proxy: improved code readability.Ruslan Ermilov1-12/+5
Do not assume that space character follows the method name, just pass it explicitly. The fuss around it has already proved to be unsafe, see bbdb172f0927 and http://mailman.nginx.org/pipermail/nginx-ru/2013-January/049692.html for details.