summaryrefslogtreecommitdiffhomepage
path: root/src/http (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2016-05-24HTTP/2: unbreak build on MSVC.Valentin Bartenev1-1/+1
2016-05-24HTTP/2: implemented preread buffer for request body (closes #959).Valentin Bartenev4-43/+146
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-23Realip: detect duplicate real_ip_header directive.Ruslan Ermilov1-0/+4
2016-05-23Realip: port support in X-Real-IP and X-Forwarded-For.Dmitry Volyntsev1-1/+3
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-23Realip: take client port from PROXY protocol header.Dmitry Volyntsev1-0/+22
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-23Added the $realip_remote_port variable.Dmitry Volyntsev1-4/+71
2016-05-23Added the $proxy_protocol_port variable.Dmitry Volyntsev1-0/+31
2016-05-23Renamed "u" to "sockaddr" in listen options types.Maxim Dounin3-15/+17
2016-05-23Introduced the ngx_sockaddr_t type.Ruslan Ermilov3-13/+3
It's properly aligned and can hold any supported sockaddr.
2016-05-20Use ngx_cmp_sockaddr() where appropriate.Ruslan Ermilov2-34/+4
2016-05-20HTTP/2: the "421 Misdirected Request" response (closes #848).Valentin Bartenev4-9/+23
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-19SSL: support for multiple curves (ticket #885).Maxim Dounin1-1/+1
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-19SSL: support for multiple certificates (ticket #814).Maxim Dounin2-17/+34
2016-05-18Added overflow checks for version numbers (ticket #762).Maxim Dounin1-0/+16
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-16Cache: fixed updating bypassed cached errors (ticket #827).Maxim Dounin1-0/+1
2016-05-16Dav: return 501 on PUT with ranges (ticket #948).Maxim Dounin3-0/+11
2016-05-13Improved EPOLLRDHUP handling.Valentin Bartenev2-2/+10
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-12Map: support of complex values in resulting strings.Dmitry Volyntsev1-59/+67
2016-04-28Removed unused flag unexpected_eof from ngx_connection_t.Ruslan Ermilov1-2/+0
2016-04-26Variable $request_id.Vladimir Homutov1-0/+47
The variable contains text representation based on random data, usable as a unique request identifier.
2015-12-18Upstream: the "transparent" parameter of proxy_bind and friends.Roman Arutyunyan7-6/+29
This parameter lets binding the proxy connection to a non-local address. Upstream will see the connection as coming from that address. When used with $remote_addr, upstream will accept the connection from real client address. Example: proxy_bind $remote_addr transparent;
2016-04-13Upstream: prepared proxy_bind to accept parameters.Roman Arutyunyan1-38/+44
In addition, errors occurred while setting bind address are no longer ignored.
2016-04-19HTTP/2: send the output queue after emitting WINDOW_UPDATE.Valentin Bartenev1-0/+10
The WINDOW_UPDATE frame could be left in the output queue for an indefinite period of time resulting in the request timeout. This might happen if reading of the body was triggered by an event unrelated to client connection, e.g. by the limit_req timer.
2016-04-19HTTP/2: skip data frames in case of internal errors.Valentin Bartenev1-0/+2
This prevents possible processing of such frames and triggering rb->post_handler if an error occurred during r->request_body initialization.
2016-04-19HTTP/2: don't send WINDOW_UPDATE for an empty request body.Valentin Bartenev1-12/+13
Particularly this prevents sending WINDOW_UPDATE with zero delta which can result in PROTOCOL_ERROR. Also removed surplus setting of no_flow_control to 0.
2016-04-18HTTP/2: write logs when refusing streams with data.Maxim Dounin1-0/+4
Refusing streams is known to be incorrectly handled at least by IE, Edge and Safari. Make sure to provide appropriate logging to simplify fixing this in the affected browsers.
2016-04-14HTTP/2: send WINDOW_UPDATE instead of RST_STREAM with NO_ERROR.Valentin Bartenev1-0/+22
After the 92464ebace8e change, it has been discovered that not all clients follow the RFC and handle RST_STREAM with NO_ERROR properly. Notably, Chrome currently interprets it as INTERNAL_ERROR and discards the response. As a workaround, instead of RST_STREAM the maximum stream window update will be sent, which will let client to send up to 2 GB of a request body data before getting stuck on flow control. All the received data will be silently discarded. See for details: http://mailman.nginx.org/pipermail/nginx-devel/2016-April/008143.html https://bugs.chromium.org/p/chromium/issues/detail?id=603182
2016-04-14HTTP/2: refuse streams with data until SETTINGS is acknowledged.Valentin Bartenev2-1/+8
A client is allowed to send requests before receiving and acknowledging the SETTINGS frame. Such a client having a wrong idea about the stream's could send the request body that nginx isn't ready to process. The previous behavior was to send RST_STREAM with FLOW_CONTROL_ERROR in such case, but it didn't allow retrying requests that have been rejected.
2016-04-14HTTP/2: deduplicated some code in ngx_http_v2_state_headers().Valentin Bartenev1-18/+13
No functional changes.
2016-04-11FastCGI: skip special bufs in buffered request body chain.Valentin Bartenev1-0/+5
This prevents forming empty records out of such buffers. Particularly it fixes double end-of-stream records with chunked transfer encoding, or when HTTP/2 is used and the END_STREAM flag has been sent without data. In both cases there is an empty buffer at the end of the request body chain with the "last_buf" flag set. The canonical libfcgi, as well as php implementation, tolerates such records, while the HHVM parser is more strict and drops the connection (ticket #950).
2016-04-11Fixed typos.Alessandro Ghedini1-2/+2
2016-04-07Fixed spelling.Josh Soref2-5/+5
2016-04-01HTTP/2: support for unbuffered upload of request body.Valentin Bartenev3-3/+138
2016-04-01HTTP/2: rewritten handling of request body.Valentin Bartenev4-258/+238
There are two improvements: 1. Support for request body filters; 2. Receiving of request body is started only after the ngx_http_read_client_request_body() call. The last one fixes the problem when the client_max_body_size value might not be respected from the right location if the location was changed either during the process of receiving body or after the whole body had been received.
2016-04-01HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.Valentin Bartenev2-14/+25
RFC 7540 states that "A server can send a complete response prior to the client sending an entire request if the response does not depend on any portion of the request that has not been sent and received. When this is true, a server MAY request that the client abort transmission of a request without error by sending a RST_STREAM with an error code of NO_ERROR after sending a complete response (i.e., a frame with the END_STREAM flag)." This should prevent a client from blocking on the stream window, since it isn't maintained for closed streams. Currently, quite big initial stream windows are used, so such blocking is very unlikly, but that will be changed in the further patches.
2016-03-31SSL: RSA_generate_key() is deprecated in OpenSSL 1.1.0.Maxim Dounin1-1/+1
OpenSSL removed support for all 40 and 56 bit ciphers.
2016-03-31Fixed logging.Sergey Kandaurov18-34/+34
2016-03-31Fixed logging with variable field width.Sergey Kandaurov5-9/+10
2016-03-31Fixed logging in close error handling.Sergey Kandaurov1-1/+1
2016-03-30Style.Ruslan Ermilov17-66/+66
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