aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
...
* Version bump.Sergey Kandaurov2020-02-05
|
* gRPC: variables support in the "grpc_pass" directive.Vladimir Homutov2020-01-17
|
* HTTP/2: removed ngx_debug_point() call.Daniil Bondarev2020-01-14
| | | | | | | |      With the recent change to prevent frames flood in d4448892a294, nginx will finalize the connection with NGX_HTTP_V2_INTERNAL_ERROR whenever flood is detected, causing nginx aborting or stopping if the debug_points directive is used in nginx config.
* SSL: reworked posted next events again.Maxim Dounin2019-12-27
| | | | | | | | | | | | | | Previous change 1ce3f01a4355 incorrectly introduced processing of the ngx_posted_next_events queue at the end of operation, effectively making posted next events a nop, since at the end of an event loop iteration the queue is always empty. Correct approach is to move events to the ngx_posted_events queue at an iteration start, as it was done previously. Further, in some cases the c->read event might be already in the ngx_posted_events queue, and calling ngx_post_event() with the ngx_posted_next_events queue won't do anything. To make sure the event will be correctly placed into the ngx_posted_next_events queue we now check if it is already posted.
* Version bump.Maxim Dounin2019-12-27
|
* SSL: reworked posted next events.Maxim Dounin2019-12-24
| | | | | | | | | | | | | | Introduced in 9d2ad2fb4423 available bytes handling in SSL relied on connection read handler being overwritten to set the ready flag and the amount of available bytes. This approach is, however, does not work properly when connection read handler is changed, for example, when switching to a next pipelined request, and can result in unexpected connection timeouts, see here: http://mailman.nginx.org/pipermail/nginx-devel/2019-December/012825.html Fix is to introduce ngx_event_process_posted_next() instead, which will set ready and available regardless of how event handler is set.
* HTTP/2: introduced separate handler to retry stream close.Maxim Dounin2019-12-23
| | | | | | | | When ngx_http_v2_close_stream_handler() is used to retry stream close after queued frames are sent, client timeouts on the stream can be logged multiple times and/or in addition to already happened errors. To resolve this, separate ngx_http_v2_retry_close_stream_handler() was introduced, which does not try to log timeouts.
* HTTP/2: fixed socket leak with queued frames (ticket #1689).Maxim Dounin2019-12-23
| | | | | | | | | | | | | If a stream is closed with queued frames, it is possible that no further write events will occur on the stream, leading to the socket leak. To fix this, the stream's fake connection read handler is set to ngx_http_v2_close_stream_handler(), to make sure that finalizing the connection with ngx_http_v2_finalize_connection() will be able to close the stream regardless of the current number of queued frames. Additionally, the stream's fake connection fc->error flag is explicitly set, so ngx_http_v2_handle_stream() will post a write event when queued frames are finally sent even if stream flow control window is exhausted.
* Dav: added checks for chunked to body presence conditions.Maxim Dounin2019-12-23
| | | | | | These checks were missed when chunked support was introduced. And also added an explicit error message to ngx_http_dav_copy_move_handler() (it was missed for some reason, in contrast to DELETE and MKCOL handlers).
* Discard request body when redirecting to a URL via error_page.Ruslan Ermilov2019-12-23
| | | | Reported by Bert JW Regeer and Francisco Oca Gonzalez.
* Rewrite: disallow empty replacements.Ruslan Ermilov2019-12-16
| | | | | | While empty replacements were caught at run-time, parsing code of the "rewrite" directive expects that a minimum length of the "replacement" argument is 1.
* Tolerate '\0' in URI when mapping URI to path.Ruslan Ermilov2019-12-16
| | | | | | | If a rewritten URI has the null character, only a part of URI was copied to a memory buffer allocated for path. In some setups this could be exploited to expose uninitialized memory via the Location header.
* Rewrite: fixed segfault with rewritten URI and "alias".Ruslan Ermilov2019-12-16
| | | | | | | | | | | | | | | | | | | The "alias" directive cannot be used in the same location where URI was rewritten. This has been detected in the "rewrite ... break" case, but not when the standalone "break" directive was used. This change also fixes proxy_pass with URI component in a similar case: location /aaa/ { rewrite ^ /xxx/yyy; break; proxy_pass http://localhost:8080/bbb/; } Previously, the "/bbb/yyy" would be sent to a backend instead of "/xxx/yyy". And if location's prefix was longer than the rewritten URI, a segmentation fault might occur.
* Fixed request finalization in ngx_http_index_handler().Ruslan Ermilov2019-12-16
| | | | | Returning 500 instead of NGX_ERROR is preferable here because header has not yet been sent to the client.
* Saved some memory allocations.Ruslan Ermilov2019-12-16
| | | | | In configurations when "root" has variables, some modules unnecessarily allocated memory for the "Location" header value.
* Dav: fixed Location in successful MKCOL response.Ruslan Ermilov2019-12-16
| | | | | Instead of reducing URI length to not include the terminating '\0' character in 6ddaac3e0bf7, restore the terminating '/' character.
* Upstream keepalive: clearing of c->data in cached connections.Maxim Dounin2019-12-05
| | | | | | | Previously, connections returned from keepalive cache had c->data pointing to the keepalive cache item. While this shouldn't be a problem for correct code, as c->data is not expected to be used before it is set, explicitly clearing it might help to avoid confusion.
* Version bump.Maxim Dounin2019-12-05
|
* Limit conn: added shared context.Roman Arutyunyan2019-11-18
| | | | | | | Previously only an rbtree was associated with a limit_conn. To make it possible to associate more data with a limit_conn, shared context is introduced similar to limit_req. Also, shared pool pointer is kept in a way similar to limit_req.
* Limit conn: $limit_conn_status variable.Roman Arutyunyan2019-11-18
| | | | The variable takes one of the values: PASSED, REJECTED or REJECTED_DRY_RUN.
* Limit conn: limit_conn_dry_run directive.Roman Arutyunyan2019-11-19
| | | | | A new directive limit_conn_dry_run allows enabling the dry run mode. In this mode connections are not rejected, but reject status is logged as usual.
* Updated comment after 776d1bebdca2.Roman Arutyunyan2019-11-18
|
* Limit req: $limit_req_status variable.Roman Arutyunyan2019-11-06
| | | | | The variable takes one of the values: PASSED, DELAYED, REJECTED, DELAYED_DRY_RUN or REJECTED_DRY_RUN.
* Parsing server PROXY protocol address and port (ticket #1206).Roman Arutyunyan2019-10-21
| | | | | New variables $proxy_protocol_server_addr and $proxy_protocol_server_port are added both to HTTP and Stream.
* Core: moved PROXY protocol fields out of ngx_connection_t.Roman Arutyunyan2019-10-21
| | | | | | Now a new structure ngx_proxy_protocol_t holds these fields. This allows to add more PROXY protocol fields in the future without modifying the connection structure.
* Version bump.Roman Arutyunyan2019-10-24
|
* Win32: silenced -Wcast-function-type GCC warning (ticket #1865).Maxim Dounin2019-10-21
| | | | | | | With MinGW-w64, building 64-bit nginx binary with GCC 8 and above results in warning due to cast of GetProcAddress() result to ngx_wsapoll_pt, which GCC thinks is incorrect. Added intermediate cast to "void *" to silence the warning.
* Win32: improved fallback on FormatMessage() errors.Maxim Dounin2019-10-21
| | | | | | | | | | | | FormatMessage() seems to return many errors which essentially indicate that the language in question is not available. At least the following were observed in the wild and during testing: ERROR_MUI_FILE_NOT_FOUND (15100) (ticket #1868), ERROR_RESOURCE_TYPE_NOT_FOUND (1813). While documentation says it should be ERROR_RESOURCE_LANG_NOT_FOUND (1815), this doesn't seem to be the case. As such, checking error code was removed, and as long as FormatMessage() returns an error, we now always try the default language.
* SSL: available bytes handling (ticket #1431).Maxim Dounin2019-10-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Added code to track number of bytes available in the socket. This makes it possible to avoid looping for a long time while working with fast enough peer when data are added to the socket buffer faster than we are able to read and process data. When kernel does not provide number of bytes available, it is retrieved using ioctl(FIONREAD) as long as a buffer is filled by SSL_read(). It is assumed that number of bytes returned by SSL_read() is close to the number of bytes read from the socket, as we do not use SSL compression. But even if it is not true for some reason, this is not important, as we post an additional reading event anyway. Note that data can be buffered at SSL layer, and it is not possible to simply stop reading at some point and wait till the event will be reported by the kernel again. This can be only done when there are no data in SSL buffers, and there is no good way to find out if it's the case. Instead of trying to figure out if SSL buffers are empty, this patch introduces events posted for the next event loop iteration - such events will be processed only on the next event loop iteration, after going into the kernel and retrieving additional events. This seems to be simple and reliable approach.
* Events: available bytes calculation via ioctl(FIONREAD).Maxim Dounin2019-10-17
| | | | | | | | | | | | | | | | | | | | | This makes it possible to avoid looping for a long time while working with a fast enough peer when data are added to the socket buffer faster than we are able to read and process them (ticket #1431). This is basically what we already do on FreeBSD with kqueue, where information about the number of bytes in the socket buffer is returned by the kevent() call. With other event methods rev->available is now set to -1 when the socket is ready for reading. Later in ngx_recv() and ngx_recv_chain(), if full buffer is received, real number of bytes in the socket buffer is retrieved using ioctl(FIONREAD). Reading more than this number of bytes ensures that even with edge-triggered event methods the event will be triggered again, so it is safe to stop processing of the socket and switch to other connections. Using ioctl(FIONREAD) only after reading a full buffer is an optimization. With this approach we only call ioctl(FIONREAD) when there are at least two recv()/readv() calls.
* SSL: improved ngx_ssl_recv_chain() to stop if c->read->ready is 0.Maxim Dounin2019-10-17
| | | | | | | | As long as there are data to read in the socket, yet the amount of data is less than total size of the buffers in the chain, this saves one unneeded read() syscall. Before this change, reading only stopped if ngx_ssl_recv() returned no data, that is, two read() syscalls in a row returned EAGAIN.
* Event pipe: disabled c->read->available checking for SSL.Maxim Dounin2019-10-17
| | | | | | | | | | In SSL connections, data can be buffered by the SSL layer, and it is wrong to avoid doing c->recv_chain() if c->read->available is 0 and c->read->pending_eof is set. And tests show that the optimization in question indeed can result in incorrect detection of premature connection close if upstream closes the connection without sending a close notify alert at the same time. Fix is to disable c->read->available optimization for SSL connections.
* Fixed header parsing with ignore_invalid_headers switched off.Ruslan Ermilov2019-10-15
| | | | | | The parsing was broken when the first character of the header name was invalid. Based on a patch by Alan Kemp.
* Fixed URI normalization with merge_slashes switched off.Maxim Dounin2019-10-08
| | | | | Previously, "/foo///../bar" was normalized into "/foo/bar" instead of "/foo//bar".
* The "/." and "/.." at the end of URI should be normalized.Ruslan Ermilov2019-10-08
|
* Improved detection of broken percent encoding in URI.Ruslan Ermilov2019-10-08
|
* Core: removed dead code in ngx_rbtree_delete().Vladimir Homutov2019-09-30
| | | | | The result of ngx_rbtree_min() is always a node with the left child equal to sentinel, thus the check is unnecessary.
* Version bump.Vladimir Homutov2019-09-30
|
* HTTP/2: fixed worker_shutdown_timeout.Ruslan Ermilov2019-09-23
|
* HTTP/2: fixed possible alert about left open socket on shutdown.Ruslan Ermilov2019-09-23
| | | | | | | | | | | | | | This could happen when graceful shutdown configured by worker_shutdown_timeout times out and is then followed by another timeout such as proxy_read_timeout. In this case, the HEADERS frame is added to the output queue, but attempt to send it fails (due to c->error forcibly set during graceful shutdown timeout). This triggers request finalization which attempts to close the stream. But the stream cannot be closed because there is a frame in the output queue, and the connection cannot be finalized. This leaves the connection open without any timer events leading to alert. The fix is to post write event when sending output queue fails on c->error. That will finalize the connection.
* HTTP/2: traffic-based flood detection.Maxim Dounin2019-09-18
| | | | | | | With this patch, all traffic over an HTTP/2 connection is counted in the h2c->total_bytes field, and payload traffic is counted in the h2c->payload_bytes field. As long as total traffic is many times larger than payload traffic, we consider this to be a flood.
* HTTP/2: switched back to RST_STREAM with NO_ERROR.Maxim Dounin2019-09-18
| | | | | | | | | In 8df664ebe037, we've switched to maximizing stream window instead of sending RST_STREAM. Since then handling of RST_STREAM with NO_ERROR was fixed at least in Chrome, hence we switch back to using RST_STREAM. This allows more effective rejecting of large bodies, and also minimizes non-payload traffic to be accounted in the next patch.
* SSL: fixed ssl_verify_client error message.Sergey Kandaurov2019-09-16
|
* Resolver: fixed possible use-after-free while resolving PTR.Sergey Kandaurov2019-09-10
| | | | | | | | | | Previously, if a response to the PTR request was cached, and ngx_resolver_dup() failed to allocate memory for the resulting name, then the original node was freed but left in expire_queue. A subsequent address resolving would end up in a use-after-free memory access of the node either in ngx_resolver_expire() or ngx_resolver_process_ptr(), when accessing it through expire_queue. The fix is to leave the resolver node intact.
* HTTP/2: close connection on zero WINDOW_UPDATE.Ruslan Ermilov2019-09-10
| | | | | | Don't waste server resources by sending RST_STREAM frames. Instead, reject WINDOW_UPDATE frames with invalid zero increment by closing connection with PROTOCOL_ERROR.
* HTTP/2: close connection on frames with self-dependency.Ruslan Ermilov2019-09-10
| | | | | | Don't waste server resources by sending RST_STREAM frames. Instead, reject HEADERS and PRIORITY frames with self-dependency by closing connection with PROTOCOL_ERROR.
* Fixed "return" with discarding invalid chunked body.Sergey Kandaurov2019-09-04
| | | | | | | | | When ngx_http_discard_request_body() call was added to ngx_http_send_response(), there were no return codes other than NGX_OK and NGX_HTTP_INTERNAL_SERVER_ERROR. Now it can also return NGX_HTTP_BAD_REQUEST, but ngx_http_send_response() still incorrectly transforms it to NGX_HTTP_INTERNAL_SERVER_ERROR. The fix is to propagate ngx_http_discard_request_body() errors.
* Detect runaway chunks in ngx_http_parse_chunked().Sergey Kandaurov2019-09-03
| | | | | | | | | | | | | | | | | As defined in HTTP/1.1, body chunks have the following ABNF: chunk = chunk-size [ chunk-ext ] CRLF chunk-data CRLF where chunk-data is a sequence of chunk-size octets. With this change, chunk-data that doesn't end up with CRLF at chunk-size offset will be treated as invalid, such as in the example provided below: 4 SEE-THIS-AND- 4 THAT 0
* HTTP/2: discard remaining request body after redirect.Sergey Kandaurov2019-08-19
| | | | | | | | | | | | | | | | | | | | | Previously, if unbuffered request body reading wasn't finished before the request was redirected to a different location using error_page or X-Accel-Redirect, and the request body is read again, this could lead to disastrous effects, such as a duplicate post_handler call or "http request count is zero" alert followed by a segmentation fault. This happened in the following configuration (ticket #1819): location / { proxy_request_buffering off; proxy_pass http://bad; proxy_intercept_errors on; error_page 502 = /error; } location /error { proxy_pass http://backend; }
* SSL: lowered log level for WSAECONNABORTED errors on Windows.Maxim Dounin2019-08-16
| | | | | | | | Winsock uses ECONNABORTED instead of ECONNRESET in some cases. For non-SSL connections this is already handled since baad3036086e. Reported at http://mailman.nginx.org/pipermail/nginx-ru/2019-August/062363.html.