summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)AuthorFilesLines
2020-02-27Disabled connection reuse while in SSL handshake.Sergey Kandaurov1-2/+2
During SSL handshake, the connection could be reused in the OCSP stapling callback, if configured, which subsequently leads to a segmentation fault.
2020-02-20Disabled duplicate "Host" headers (ticket #1724).Maxim Dounin1-2/+10
Duplicate "Host" headers were allowed in nginx 0.7.0 (revision b9de93d804ea) as a workaround for some broken Motorola phones which used to generate requests with two "Host" headers[1]. It is believed that this workaround is no longer relevant. [1] http://mailman.nginx.org/pipermail/nginx-ru/2008-May/017845.html
2020-02-20Removed "Transfer-Encoding: identity" support.Maxim Dounin1-4/+1
The "identity" transfer coding has been removed in RFC 7230. It is believed that it is not used in real life, and at the same time it provides a potential attack vector.
2020-02-20Disabled multiple Transfer-Encoding headers.Maxim Dounin1-1/+1
We anyway do not support more than one transfer encoding, so accepting requests with multiple Transfer-Encoding headers doesn't make sense. Further, we do not handle multiple headers, and ignore anything but the first header. Reported by Filippo Valsorda.
2020-02-11Made ngx_http_get_forwarded_addr_internal() non-recursive.Vladimir Homutov1-27/+25
2020-02-05HTTP/2: fixed socket leak with an incomplete HEADERS frame.Sergey Kandaurov1-2/+7
A connection could get stuck without timers if a client has partially sent the HEADERS frame such that it was split on the individual header boundary. In this case, it cannot be processed without the rest of the HEADERS frame. The fix is to call ngx_http_v2_state_headers_save() in this case. Normally, it would be called from the ngx_http_v2_state_header_block() handler on the next iteration, when there is not enough data to continue processing. This isn't the case if recv_buffer became empty and there's no more data to read.
2020-02-05Version bump.Sergey Kandaurov1-2/+2
2020-01-21release-1.17.8 tagMaxim Dounin1-0/+1
2020-01-21nginx-1.17.8-RELEASErelease-1.17.8Maxim Dounin1-0/+36
2020-01-17gRPC: variables support in the "grpc_pass" directive.Vladimir Homutov1-38/+190
2020-01-14HTTP/2: removed ngx_debug_point() call.Daniil Bondarev1-4/+0
     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.
2019-12-27SSL: reworked posted next events again.Maxim Dounin4-14/+16
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.
2019-12-27Trailing space removed.Maxim Dounin1-1/+1
2019-12-27Version bump.Maxim Dounin1-2/+2
2019-12-24release-1.17.7 tagMaxim Dounin1-0/+1
2019-12-24nginx-1.17.7-RELEASErelease-1.17.7Maxim Dounin1-0/+84
2019-12-24SSL: reworked posted next events.Maxim Dounin5-34/+28
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.
2019-12-23HTTP/2: introduced separate handler to retry stream close.Maxim Dounin1-2/+19
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.
2019-12-23HTTP/2: fixed socket leak with queued frames (ticket #1689).Maxim Dounin1-1/+2
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.
2019-12-23Dav: added checks for chunked to body presence conditions.Maxim Dounin1-3/+5
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).
2019-12-23Update manpage, sort command line options.Sergey A. Osokin1-7/+8
2019-12-23Discard request body when redirecting to a URL via error_page.Ruslan Ermilov1-0/+6
Reported by Bert JW Regeer and Francisco Oca Gonzalez.
2019-12-16Rewrite: disallow empty replacements.Ruslan Ermilov1-0/+5
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.
2019-12-16Tolerate '\0' in URI when mapping URI to path.Ruslan Ermilov1-1/+2
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.
2019-12-16Rewrite: fixed segfault with rewritten URI and "alias".Ruslan Ermilov1-1/+8
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.
2019-12-16Fixed request finalization in ngx_http_index_handler().Ruslan Ermilov1-1/+1
Returning 500 instead of NGX_ERROR is preferable here because header has not yet been sent to the client.
2019-12-16Saved some memory allocations.Ruslan Ermilov2-28/+7
In configurations when "root" has variables, some modules unnecessarily allocated memory for the "Location" header value.
2019-12-16Dav: fixed Location in successful MKCOL response.Ruslan Ermilov1-1/+2
Instead of reducing URI length to not include the terminating '\0' character in 6ddaac3e0bf7, restore the terminating '/' character.
2019-12-05Upstream keepalive: clearing of c->data in cached connections.Maxim Dounin1-0/+1
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.
2019-12-05Version bump.Maxim Dounin1-2/+2
2019-11-19release-1.17.6 tagMaxim Dounin1-0/+1
2019-11-19nginx-1.17.6-RELEASErelease-1.17.6Maxim Dounin1-0/+32
2019-11-18Limit conn: added shared context.Roman Arutyunyan2-93/+86
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.
2019-11-18Limit conn: $limit_conn_status variable.Roman Arutyunyan4-5/+149
The variable takes one of the values: PASSED, REJECTED or REJECTED_DRY_RUN.
2019-11-19Limit conn: limit_conn_dry_run directive.Roman Arutyunyan2-2/+46
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.
2019-11-18Updated comment after 776d1bebdca2.Roman Arutyunyan1-1/+1
2019-11-06Limit req: $limit_req_status variable.Roman Arutyunyan2-5/+76
The variable takes one of the values: PASSED, DELAYED, REJECTED, DELAYED_DRY_RUN or REJECTED_DRY_RUN.
2019-10-21Parsing server PROXY protocol address and port (ticket #1206).Roman Arutyunyan4-72/+164
New variables $proxy_protocol_server_addr and $proxy_protocol_server_port are added both to HTTP and Stream.
2019-10-21Core: moved PROXY protocol fields out of ngx_connection_t.Roman Arutyunyan8-37/+87
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.
2019-10-24Version bump.Roman Arutyunyan1-2/+2
2019-10-22release-1.17.5 tagMaxim Dounin1-0/+1
2019-10-22nginx-1.17.5-RELEASErelease-1.17.5Maxim Dounin1-0/+63
2019-10-21Win32: silenced -Wcast-function-type GCC warning (ticket #1865).Maxim Dounin1-1/+1
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.
2019-10-21Win32: improved fallback on FormatMessage() errors.Maxim Dounin1-1/+1
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.
2019-10-17SSL: available bytes handling (ticket #1431).Maxim Dounin5-0/+78
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.
2019-10-17Events: available bytes calculation via ioctl(FIONREAD).Maxim Dounin17-12/+193
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.
2019-10-17SSL: improved ngx_ssl_recv_chain() to stop if c->read->ready is 0.Maxim Dounin1-0/+4
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.
2019-10-17Event pipe: disabled c->read->available checking for SSL.Maxim Dounin1-1/+5
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.
2019-10-15Fixed header parsing with ignore_invalid_headers switched off.Ruslan Ermilov1-0/+4
The parsing was broken when the first character of the header name was invalid. Based on a patch by Alan Kemp.
2019-10-08Fixed URI normalization with merge_slashes switched off.Maxim Dounin1-2/+2
Previously, "/foo///../bar" was normalized into "/foo/bar" instead of "/foo//bar".