Compare commits

...

6827 Commits

Author SHA1 Message Date
Sergey Kandaurov cf616abc3b Merged with the default branch. 2023-03-29 11:14:25 +04:00
Maxim Dounin 424c870970 release-1.23.4 tag 2023-03-28 18:01:54 +03:00
Maxim Dounin 18d32b3f2a nginx-1.23.4-RELEASE 2023-03-28 18:01:53 +03:00
Maxim Dounin 31ff1aa55e Updated OpenSSL used for win32 builds. 2023-03-28 02:25:55 +03:00
Maxim Dounin dd7ebb19ba Gzip: compatibility with recent zlib-ng versions.
It now uses custom alloc_aligned() wrapper for all allocations,
therefore all allocations are larger than expected by (64 + sizeof(void*)).
Further, they are seen as allocations of 1 element.  Relevant calculations
were adjusted to reflect this, and state allocation is now protected
with a flag to avoid misinterpreting other allocations as the zlib
deflate_state allocation.

Further, it no longer forces window bits to 13 on compression level 1,
so the comment was adjusted to reflect this.
2023-03-27 21:25:05 +03:00
Maxim Dounin c4f8e285b7 SSL: enabled TLSv1.3 by default. 2023-03-24 02:57:43 +03:00
Maxim Dounin 23958e4a5c Mail: fixed handling of blocked client read events in proxy.
When establishing a connection to the backend, nginx blocks reading
from the client with ngx_mail_proxy_block_read().  Previously, such
events were lost, and in some cases this resulted in connection hangs.

Notably, this affected mail_imap_ssl.t on Windows, since the test
closes connections after requesting authentication, but without
waiting for any responses (so the connection close events might be
lost).

Fix is to post an event to read from the client after connecting to
the backend if there were blocked events.
2023-03-24 02:53:21 +03:00
Roman Arutyunyan b1a0c01112 QUIC: style. 2023-03-15 19:57:15 +04:00
Sergey Kandaurov 71e9770303 HTTP/3: fixed OpenSSL compatibility layer initialization.
SSL context is not present if the default server has neither certificates nor
ssl_reject_handshake enabled.  Previously, this led to null pointer dereference
before it would be caught with configuration checks.

Additionally, non-default servers with distinct SSL contexts need to initialize
compatibility layer in order to complete a QUIC handshake.
2023-03-24 19:49:50 +04:00
Maxim Dounin 4d05ba0272 Syslog: introduced error log handler.
This ensures that errors which happen during logging to syslog are logged
with proper context, such as "while logging to syslog" and the server name.

Prodded by Safar Safarly.
2023-03-10 07:43:50 +03:00
Maxim Dounin 7ea9823a62 Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
During initial startup the ngx_cycle->hostname is not available, and
previously this resulted in incorrect logging.  Instead, hostname from the
configuration being parsed is now preserved in the syslog peer structure
and then used during logging.

Similarly, ngx_cycle->log might not match the configuration where the
syslog peer is defined if the configuration is not yet fully applied,
and previously this resulted in unexpected logging of syslog errors
and debug information.  Instead, cf->cycle->new_log is now referenced
in the syslog peer structure and used for logging, similarly to how it
is done in other modules.
2023-03-10 07:43:40 +03:00
Maxim Dounin ff333ad01c HTTP/2: finalize request as bad if header validation fails.
Similarly to 7192:d5a535774861, this avoids spurious zero statuses
in access.log, and in line with other header-related errors.
2023-03-10 06:47:53 +03:00
Maxim Dounin d1fe9cedbc HTTP/2: socket leak with "return 444" in error_page (ticket #2455).
Similarly to ticket #274 (7354:1812f1d79d84), early request finalization
without calling ngx_http_run_posted_requests() resulted in a connection
hang (a socket leak) if the 400 (Bad Request) error was generated in
ngx_http_v2_state_process_header() due to invalid request headers and
"return 444" was used in error_page 400.
2023-03-10 06:47:48 +03:00
Maxim Dounin 1ecea359f7 SSL: logging levels of errors observed with BoringSSL.
As tested with tlsfuzzer with BoringSSL, the following errors are
certainly client-related:

SSL_do_handshake() failed (SSL: error:10000066:SSL routines:OPENSSL_internal:BAD_ALERT)
SSL_do_handshake() failed (SSL: error:10000089:SSL routines:OPENSSL_internal:DECODE_ERROR)
SSL_do_handshake() failed (SSL: error:100000dc:SSL routines:OPENSSL_internal:TOO_MANY_WARNING_ALERTS)
SSL_do_handshake() failed (SSL: error:10000100:SSL routines:OPENSSL_internal:INVALID_COMPRESSION_LIST)
SSL_do_handshake() failed (SSL: error:10000102:SSL routines:OPENSSL_internal:MISSING_KEY_SHARE)
SSL_do_handshake() failed (SSL: error:1000010e:SSL routines:OPENSSL_internal:TOO_MUCH_SKIPPED_EARLY_DATA)
SSL_read() failed (SSL: error:100000b6:SSL routines:OPENSSL_internal:NO_RENEGOTIATION)

Accordingly, the SSL_R_BAD_ALERT, SSL_R_DECODE_ERROR,
SSL_R_TOO_MANY_WARNING_ALERTS, SSL_R_INVALID_COMPRESSION_LIST,
SSL_R_MISSING_KEY_SHARE, SSL_R_TOO_MUCH_SKIPPED_EARLY_DATA,
and SSL_R_NO_RENEGOTIATION errors are now logged at the "info" level.
2023-03-08 22:22:47 +03:00
Maxim Dounin 984ea8ae69 SSL: logging levels of errors observed with tlsfuzzer and LibreSSL.
As tested with tlsfuzzer with LibreSSL 3.7.0, the following errors are
certainly client-related:

SSL_do_handshake() failed (SSL: error:14026073:SSL routines:ACCEPT_SR_CLNT_HELLO:bad packet length)
SSL_do_handshake() failed (SSL: error:1402612C:SSL routines:ACCEPT_SR_CLNT_HELLO:ssl3 session id too long)
SSL_do_handshake() failed (SSL: error:140380EA:SSL routines:ACCEPT_SR_KEY_EXCH:tls rsa encrypted value length is wrong)

Accordingly, the SSL_R_BAD_PACKET_LENGTH ("bad packet length"),
SSL_R_SSL3_SESSION_ID_TOO_LONG ("ssl3 session id too long"),
SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG ("tls rsa encrypted value
length is wrong") errors are now logged at the "info" level.
2023-03-08 22:22:34 +03:00
Maxim Dounin 59f479952d SSL: logging levels of various errors reported with tlsfuzzer.
To further differentiate client-related errors and adjust logging levels
of various SSL errors, nginx was tested with tlsfuzzer with multiple
OpenSSL versions (3.1.0-beta1, 3.0.8, 1.1.1t, 1.1.0l, 1.0.2u, 1.0.1u,
1.0.0s, 0.9.8zh).

The following errors were observed during tlsfuzzer runs with OpenSSL 3.0.8,
and are clearly client-related:

SSL_do_handshake() failed (SSL: error:0A000092:SSL routines::data length too long)
SSL_do_handshake() failed (SSL: error:0A0000A0:SSL routines::length too short)
SSL_do_handshake() failed (SSL: error:0A000124:SSL routines::bad legacy version)
SSL_do_handshake() failed (SSL: error:0A000178:SSL routines::no shared signature algorithms)

Accordingly, the SSL_R_DATA_LENGTH_TOO_LONG ("data length too long"),
SSL_R_LENGTH_TOO_SHORT ("length too short"), SSL_R_BAD_LEGACY_VERSION
("bad legacy version"), and SSL_R_NO_SHARED_SIGNATURE_ALGORITHMS
("no shared signature algorithms", misspelled as "sigature" in OpenSSL 1.0.2)
errors are now logged at the "info" level.

Additionally, the following errors were observed with OpenSSL 3.0.8 and
with TLSv1.3 enabled:

SSL_do_handshake() failed (SSL: error:0A00006F:SSL routines::bad digest length)
SSL_do_handshake() failed (SSL: error:0A000070:SSL routines::missing sigalgs extension)
SSL_do_handshake() failed (SSL: error:0A000096:SSL routines::encrypted length too long)
SSL_do_handshake() failed (SSL: error:0A00010F:SSL routines::bad length)
SSL_read() failed (SSL: error:0A00007A:SSL routines::bad key update)
SSL_read() failed (SSL: error:0A000125:SSL routines::mixed handshake and non handshake data)

Accordingly, the SSL_R_BAD_DIGEST_LENGTH ("bad digest length"),
SSL_R_MISSING_SIGALGS_EXTENSION ("missing sigalgs extension"),
SSL_R_ENCRYPTED_LENGTH_TOO_LONG ("encrypted length too long"),
SSL_R_BAD_LENGTH ("bad length"), SSL_R_BAD_KEY_UPDATE ("bad key update"),
and SSL_R_MIXED_HANDSHAKE_AND_NON_HANDSHAKE_DATA ("mixed handshake and non
handshake data") errors are now logged at the "info" level.

Additionally, the following errors were observed with OpenSSL 1.1.1t:

SSL_do_handshake() failed (SSL: error:14094091:SSL routines:ssl3_read_bytes:data between ccs and finished)
SSL_do_handshake() failed (SSL: error:14094199:SSL routines:ssl3_read_bytes:too many warn alerts)
SSL_read() failed (SSL: error:1408F0C6:SSL routines:ssl3_get_record:packet length too long)
SSL_read() failed (SSL: error:14094085:SSL routines:ssl3_read_bytes:ccs received early)

Accordingly, the SSL_R_CCS_RECEIVED_EARLY ("ccs received early"),
SSL_R_DATA_BETWEEN_CCS_AND_FINISHED ("data between ccs and finished"),
SSL_R_PACKET_LENGTH_TOO_LONG ("packet length too long"), and
SSL_R_TOO_MANY_WARN_ALERTS ("too many warn alerts") errors are now logged
at the "info" level.

Additionally, the following errors were observed with OpenSSL 1.0.2u:

SSL_do_handshake() failed (SSL: error:1407612A:SSL routines:SSL23_GET_CLIENT_HELLO:record too small)
SSL_do_handshake() failed (SSL: error:1408C09A:SSL routines:ssl3_get_finished:got a fin before a ccs)

Accordingly, the SSL_R_RECORD_TOO_SMALL ("record too small") and
SSL_R_GOT_A_FIN_BEFORE_A_CCS ("got a fin before a ccs") errors are now
logged at the "info" level.

No additional client-related errors were observed while testing with
OpenSSL 3.1.0-beta1, OpenSSL 1.1.0l, OpenSSL 1.0.1u, OpenSSL 1.0.0s,
and OpenSSL 0.9.8zh.
2023-03-08 22:21:59 +03:00
Maxim Dounin 3c47d22dfa SSL: switched to detect log level based on the last error.
In some cases there might be multiple errors in the OpenSSL error queue,
notably when a libcrypto call fails, and then the SSL layer generates
an error itself.  For example, the following errors were observed
with OpenSSL 3.0.8 with TLSv1.3 enabled:

SSL_do_handshake() failed (SSL: error:02800066:Diffie-Hellman routines::invalid public key error:0A000132:SSL routines::bad ecpoint)
SSL_do_handshake() failed (SSL: error:08000066:elliptic curve routines::invalid encoding error:0A000132:SSL routines::bad ecpoint)
SSL_do_handshake() failed (SSL: error:0800006B:elliptic curve routines::point is not on curve error:0A000132:SSL routines::bad ecpoint)

In such cases it seems to be better to determine logging level based on
the last error in the error queue (the one added by the SSL layer,
SSL_R_BAD_ECPOINT in all of the above example example errors).  To do so,
the ngx_ssl_connection_error() function was changed to use
ERR_peek_last_error().
2023-03-08 22:21:53 +03:00
Yugo Horie ada02a13b5 Core: stricter UTF-8 handling in ngx_utf8_decode().
An UTF-8 octet sequence cannot start with a 11111xxx byte (above 0xf8),
see https://datatracker.ietf.org/doc/html/rfc3629#section-3.  Previously,
such bytes were accepted by ngx_utf8_decode() and misinterpreted as 11110xxx
bytes (as in a 4-byte sequence).  While unlikely, this can potentially cause
issues.

Fix is to explicitly reject such bytes in ngx_utf8_decode().
2023-02-23 08:09:50 +09:00
Maxim Dounin f4c0711c86 Win32: non-ASCII names in ngx_fs_bsize(), ngx_fs_available().
This fixes potentially incorrect cache size calculations and non-working
"min_free" when using cache in directories with non-ASCII names.
2023-02-23 20:50:03 +03:00
Maxim Dounin acf3f86572 Win32: removed attempt to use a drive letter in ngx_fs_bsize().
Just a drive letter might not correctly represent file system being used,
notably when using symlinks (as created by "mklink /d").  As such, instead
of trying to call GetDiskFreeSpace() with just a drive letter, we now always
use GetDiskFreeSpace() with full path.

Further, it looks like the code to use just a drive letter never worked,
since it tried to test name[2] instead of name[1] to be ':'.
2023-02-23 20:50:00 +03:00
Maxim Dounin 5a81048cd8 Win32: non-ASCII names support in ngx_open_tempfile().
This makes it possible to use temporary directories with non-ASCII characters,
either explicitly or via a prefix with non-ASCII characters in it.
2023-02-23 20:49:57 +03:00
Maxim Dounin 16b638ef7c Win32: non-ASCII names support in ngx_rename_file().
This makes it possible to upload files with non-ASCII characters
when using the dav module (ticket #1433).
2023-02-23 20:49:55 +03:00
Maxim Dounin fb264ca0d2 Win32: non-ASCII names support in ngx_delete_file().
This makes it possible to delete files with non-ASCII characters
when using the dav module (ticket #1433).
2023-02-23 20:49:54 +03:00
Maxim Dounin 06bef880d1 Win32: reworked ngx_win32_rename_file() to use nginx wrappers.
This ensures that ngx_win32_rename_file() will support non-ASCII names
when supported by the wrappers.

Notably, this is used by PUT requests in the dav module when overwriting
existing files with non-ASCII names (ticket #1433).
2023-02-23 20:49:52 +03:00
Maxim Dounin b45693f680 Win32: reworked ngx_win32_rename_file() to check errors.
Previously, ngx_win32_rename_file() retried on all errors returned by
MoveFile() to a temporary name.  It only make sense, however, to retry
when the destination file already exists, similarly to the condition
when ngx_win32_rename_file() is called.  Retrying on other errors is
meaningless and might result in an infinite loop.
2023-02-23 20:49:50 +03:00
Maxim Dounin 82fba427a0 Win32: non-ASCII directory names support in ngx_delete_dir().
This makes it possible to delete directories with non-ASCII characters
when using the dav module (ticket #1433).
2023-02-23 20:49:47 +03:00
Maxim Dounin c77dd27fb0 Win32: non-ASCII directory names support in ngx_create_dir().
This makes it possible to create directories under prefix with non-ASCII
characters, as well as makes it possible to create directories with non-ASCII
characters when using the dav module (ticket #1433).

To ensure that the dav module operations are restricted similarly to
other file operations (in particular, short names are not allowed), the
ngx_win32_check_filename() function is used.  It improved to support
checking of just dirname, and now can be used to check paths when creating
files or directories.
2023-02-23 20:49:45 +03:00
Maxim Dounin 4408a67ee7 Win32: non-ASCII directory names support in ngx_getcwd().
This makes it possible to start nginx without a prefix explicitly set
in a directory with non-ASCII characters in it.
2023-02-23 20:49:44 +03:00
Maxim Dounin 3861363449 Win32: non-ASCII names support in "include" with wildcards.
Notably, ngx_open_glob() now supports opening directories with non-ASCII
characters, and pathnames returned by ngx_read_glob() are converted to UTF-8.
2023-02-23 20:49:41 +03:00
Maxim Dounin cc06a160ad Win32: non-ASCII names support in autoindex (ticket #458).
Notably, ngx_open_dir() now supports opening directories with non-ASCII
characters, and directory entries returned by ngx_read_dir() are properly
converted to UTF-8.
2023-02-23 20:49:39 +03:00
Maxim Dounin 9612c3c394 Win32: OpenSSL compilation for x64 targets with MSVC.
To ensure proper target selection the NGX_MACHINE variable is now set
based on the MSVC compiler output, and the OpenSSL target is set based
on it.

This is not important as long as "no-asm" is used (as in misc/GNUmakefile
and win32 build instructions), but might be beneficial if someone is trying
to build OpenSSL with assembler code.
2023-02-23 18:16:08 +03:00
Maxim Dounin d47af0bb0c Win32: i386 now assumed when crossbuilding (ticket #2416).
Previously, NGX_MACHINE was not set when crossbuilding, resulting in
NGX_ALIGNMENT=16 being used in 32-bit builds (if not explicitly set to a
correct value).  This in turn might result in memory corruption in
ngx_palloc() (as there are no usable aligned allocator on Windows, and
normal malloc() is used instead, which provides 8 byte alignment on
32-bit platforms).

To fix this, now i386 machine is set when crossbuilding, so nginx won't
assume strict alignment requirements.
2023-02-23 18:15:59 +03:00
Maxim Dounin 54bd67eb92 Win32: handling of localized MSVC cl output.
Output examples in English, Russian, and Spanish:

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Оптимизирующий 32-разрядный компилятор Microsoft (R) C/C++ версии 16.00.30319.01 для 80x86
Compilador de optimización de C/C++ de Microsoft (R) versión 16.00.30319.01 para x64

Since most of the words are translated, instead of looking for the words
"Compiler Version" we now search for "C/C++" and the version number.
2023-02-23 18:15:57 +03:00
Maxim Dounin f8ea58861b Win32: removed unneeded wildcard in NGX_CC_NAME test for msvc.
Wildcards for msvc in NGX_CC_NAME tests are not needed since 78f8ac479735.
2023-02-23 18:15:53 +03:00
Maxim Dounin 29acc9594d Lingering close for connections with pipelined requests.
This is expected to help with clients using pipelining with some constant
depth, such as apt[1][2].

When downloading many resources, apt uses pipelining with some constant
depth, a number of requests in flight.  This essentially means that after
receiving a response it sends an additional request to the server, and
this can result in requests arriving to the server at any time.  Further,
additional requests are sent one-by-one, and can be easily seen as such
(neither as pipelined, nor followed by pipelined requests).

The only safe approach to close such connections (for example, when
keepalive_requests is reached) is with lingering.  To do so, now nginx
monitors if pipelining was used on the connection, and if it was, closes
the connection with lingering.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=973861#10
[2] https://mailman.nginx.org/pipermail/nginx-devel/2023-January/ZA2SP5SJU55LHEBCJMFDB2AZVELRLTHI.html
2023-02-02 23:38:48 +03:00
Maxim Dounin 2c3719b676 Fixed "zero size buf" alerts with subrequests.
Since 4611:2b6cb7528409 responses from the gzip static, flv, and mp4 modules
can be used with subrequests, though empty files were not properly handled.
Empty gzipped, flv, and mp4 files thus resulted in "zero size buf in output"
alerts.  While valid corresponding files are not expected to be empty, such
files shouldn't result in alerts.

Fix is to set b->sync on such empty subrequest responses, similarly to what
ngx_http_send_special() does.

Additionally, the static module, the ngx_http_send_response() function, and
file cache are modified to do the same instead of not sending the response
body at all in such cases, since not sending the response body at all is
believed to be at least questionable, and might break various filters
which do not expect such behaviour.
2023-01-28 05:23:33 +03:00
Maxim Dounin 3f83236d3e Style. 2023-01-28 05:20:23 +03:00
Maxim Dounin b130077028 Added warning about redefinition of listen socket protocol options.
The "listen" directive in the http module can be used multiple times
in different server blocks.  Originally, it was supposed to be specified
once with various socket options, and without any parameters in virtual
server blocks.  For example:

    server { listen 80 backlog=1024; server_name foo; ... }
    server { listen 80; server_name bar; ... }
    server { listen 80; server_name bazz; ... }

The address part of the syntax ("address[:port]" / "port" / "unix:path")
uniquely identifies the listening socket, and therefore is enough for
name-based virtual servers (to let nginx know that the virtual server
accepts requests on the listening socket in question).

To ensure that listening options do not conflict between virtual servers,
they were allowed only once.  For example, the following configuration
will be rejected ("duplicate listen options for 0.0.0.0:80 in ..."):

    server { listen 80 backlog=1024; server_name foo; ... }
    server { listen 80 backlog=512; server_name bar; ... }

At some point it was, however, noticed, that it is sometimes convenient
to repeat some options for clarity.  In nginx 0.8.51 the "ssl" parameter
was allowed to be specified multiple times, e.g.:

    server { listen 443 ssl backlog=1024; server_name foo; ... }
    server { listen 443 ssl; server_name bar; ... }
    server { listen 443 ssl; server_name bazz; ... }

This approach makes configuration more readable, since SSL sockets are
immediately visible in the configuration.  If this is not needed, just the
address can still be used.

Later, additional protocol-specific options similar to "ssl" were
introduced, notably "http2" and "proxy_protocol".  With these options,
one can write:

    server { listen 443 ssl backlog=1024; server_name foo; ... }
    server { listen 443 http2; server_name bar; ... }
    server { listen 443 proxy_protocol; server_name bazz; ... }

The resulting socket will use ssl, http2, and proxy_protocol, but this
is not really obvious from the configuration.

To emphasize such misleading configurations are discouraged, nginx now
warns as long as the "listen" directive is used with options different
from the options previously used if this is potentially confusing.

In particular, the following configurations are allowed:

    server { listen 8401 ssl backlog=1024; server_name foo; }
    server { listen 8401 ssl; server_name bar; }
    server { listen 8401 ssl; server_name bazz; }

    server { listen 8402 ssl http2 backlog=1024; server_name foo; }
    server { listen 8402 ssl; server_name bar; }
    server { listen 8402 ssl; server_name bazz; }

    server { listen 8403 ssl; server_name bar; }
    server { listen 8403 ssl; server_name bazz; }
    server { listen 8403 ssl http2; server_name foo; }

    server { listen 8404 ssl http2 backlog=1024; server_name foo; }
    server { listen 8404 http2; server_name bar; }
    server { listen 8404 http2; server_name bazz; }

    server { listen 8405 ssl http2 backlog=1024; server_name foo; }
    server { listen 8405 ssl http2; server_name bar; }
    server { listen 8405 ssl http2; server_name bazz; }

    server { listen 8406 ssl; server_name foo; }
    server { listen 8406; server_name bar; }
    server { listen 8406; server_name bazz; }

And the following configurations will generate warnings:

    server { listen 8501 ssl http2 backlog=1024; server_name foo; }
    server { listen 8501 http2; server_name bar; }
    server { listen 8501 ssl; server_name bazz; }

    server { listen 8502 backlog=1024; server_name foo; }
    server { listen 8502 ssl; server_name bar; }

    server { listen 8503 ssl; server_name foo; }
    server { listen 8503 http2; server_name bar; }

    server { listen 8504 ssl; server_name foo; }
    server { listen 8504 http2; server_name bar; }
    server { listen 8504 proxy_protocol; server_name bazz; }

    server { listen 8505 ssl http2 proxy_protocol; server_name foo; }
    server { listen 8505 ssl http2; server_name bar; }
    server { listen 8505 ssl; server_name bazz; }

    server { listen 8506 ssl http2; server_name foo; }
    server { listen 8506 ssl; server_name bar; }
    server { listen 8506; server_name bazz; }

    server { listen 8507 ssl; server_name bar; }
    server { listen 8507; server_name bazz; }
    server { listen 8507 ssl http2; server_name foo; }

    server { listen 8508 ssl; server_name bar; }
    server { listen 8508; server_name bazz; }
    server { listen 8508 ssl backlog=1024; server_name foo; }

    server { listen 8509; server_name bazz; }
    server { listen 8509 ssl; server_name bar; }
    server { listen 8509 ssl backlog=1024; server_name foo; }

The basic idea is that at most two sets of protocol options are allowed:
the main one (with socket options, if any), and a shorter one, with options
being a subset of the main options, repeated for clarity.  As long as the
shorter set of protocol options is used, all listen directives except the
main one should use it.
2023-01-28 01:29:45 +03:00
Roman Arutyunyan 4a41efe418 HTTP/3: trigger more compatibility errors for "listen quic".
Now "ssl", "proxy_protocol" and "http2" are not allowed with "quic" in "listen"
directive.  Previously, only "ssl" was not allowed.
2023-01-26 15:25:33 +04:00
Roman Arutyunyan eea23ac250 HTTP/3: "quic" parameter of "listen" directive.
Now "listen" directve has a new "quic" parameter which enables QUIC protocol
for the address.  Further, to enable HTTP/3, a new directive "http3" is
introduced.  The hq-interop protocol is enabled by "http3_hq" as before.
Now application protocol is chosen by ALPN.

Previously used "http3" parameter of "listen" is deprecated.
2023-02-27 14:00:56 +04:00
Roman Arutyunyan fe0c3d7310 QUIC: OpenSSL compatibility layer.
The change allows to compile QUIC with OpenSSL which lacks BoringSSL QUIC API.

This implementation does not support 0-RTT.
2023-02-22 19:16:53 +04:00
Sergey Kandaurov 8db8943ec3 QUIC: improved ssl_reject_handshake error logging.
The check follows the ngx_ssl_handshake() change in 59e1c73fe02b.
2023-02-23 16:26:38 +04:00
Sergey Kandaurov ab4347c710 QUIC: using ngx_ssl_handshake_log(). 2023-02-23 16:17:29 +04:00
Sergey Kandaurov 367b5b9230 QUIC: moved "handshake failed" reason to send_alert.
A QUIC handshake failure breaks down into several cases:
- a handshake error which leads to a send_alert call
- an error triggered by the add_handshake_data callback
- internal errors (allocation etc)

Previously, in the first case, only error code was set in the send_alert
callback.  Now the "handshake failed" reason phrase is set there as well.
In the second case, both code and reason are set by add_handshake_data.
In the last case, setting reason phrase is removed: returning NGX_ERROR
now leads to closing the connection with just INTERNAL_ERROR.

Reported by Jiuzhou Cui.
2023-02-23 16:16:56 +04:00
Sergey Kandaurov 20d9744ba3 QUIC: using NGX_QUIC_ERR_CRYPTO macro in ALPN checks.
Patch by Jiuzhou Cui.
2023-02-23 15:49:59 +04:00
Sergey Kandaurov 23257650b1 QUIC: fixed indentation. 2023-02-13 14:01:50 +04:00
Sergey Kandaurov ea97f3a0e3 README: fixed toc.
While here, updated link to mailman.
2023-02-13 13:41:35 +04:00
Sergey Kandaurov a0bcb2042e README: updated building from sources, added directives reference. 2023-02-08 12:47:35 +04:00
Roman Arutyunyan b9ce6d5074 QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Previously, since 3550b00d9dc8, the token was allocated on stack, to get
rid of pool usage.  Now the token is allocated by ngx_quic_copy_buffer()
in QUIC buffers, also used for STREAM, CRYPTO and ACK frames.
2023-01-31 15:26:33 +04:00
Roman Arutyunyan 204f0f10cd QUIC: ngx_quic_copy_buffer() function.
The function copies passed data to QUIC buffer chain and returns it.
The chain can be used in ngx_quic_frame_t data field.
2023-01-31 14:12:18 +04:00
Maxim Dounin b0ff65f27f Fixed handling of very long locations (ticket #2435).
Previously, location prefix length in ngx_http_location_tree_node_t was
stored as "u_char", and therefore location prefixes longer than 255 bytes
were handled incorrectly.

Fix is to use "u_short" instead.  With "u_short", prefixes up to 65535 bytes
can be safely used, and this isn't reachable due to NGX_CONF_BUFFER, which
is 4096 bytes.
2023-01-26 03:34:44 +03:00
Maxim Dounin 2a56f86948 Gzip static: ranges support (ticket #2349).
In contrast to on-the-fly gzipping with gzip filter, static gzipped
representation as returned by gzip_static is persistent, and therefore
the same binary representation is available for future requests, making
it possible to use range requests.

Further, if a gzipped representation is re-generated with different
compression settings, it is expected to result in different ETag and
different size reported in the Content-Range header, making it possible
to safely use range requests anyway.

As such, ranges are now allowed for files returned by gzip_static.
2023-01-24 03:01:51 +03:00
Maxim Dounin c95da93677 QUIC: improved SO_COOKIE configure test.
In nginx source code the inttypes.h include, if available, is used to define
standard integer types.  Changed the SO_COOKIE configure test to follow this.
2023-01-24 02:57:42 +03:00
Maxim Dounin 0940a055c9 Configure: removed unneeded header from UDP_SEGMENT test. 2023-01-23 05:01:01 +03:00
Sergey Kandaurov bdc9726c1b QUIC: defer setting the active flag for client stream events.
Specifically, now it is kept unset until streams are initialized.
Notably, this unbreaks OCSP with client certificates after 35e27117b593.
Previously, the read event could be posted prematurely via ngx_quic_set_event()
e.g., as part of handling a STREAM frame.
2023-01-18 19:20:18 +04:00
Roman Arutyunyan 994f4ef06c QUIC: relocated ngx_quic_init_streams() for 0-RTT.
Previously, streams were initialized in early keys handler.  However, client
transport parameters may not be available by then.  This happens, for example,
when using QuicTLS.  Now streams are initialized in ngx_quic_crypto_input()
after calling SSL_do_handshake() for both 0-RTT and 1-RTT.
2023-01-10 17:24:10 +04:00
Roman Arutyunyan 1565a79f8a HTTP/3: insert count block timeout.
Previously, there was no timeout for a request stream blocked on insert count,
which could result in infinite wait.  Now client_header_timeout is set when
stream is first blocked.
2023-01-05 19:03:22 +04:00
Roman Arutyunyan 42e1233601 HTTP/3: trigger 400 (Bad Request) on stream error while blocked.
Previously, stream was closed with NGX_HTTP_CLOSE.  However, in a similar case
when recv() returns eof or error, status 400 is triggered.
2023-01-05 18:15:46 +04:00
Roman Arutyunyan abd52b27e1 QUIC: set stream error flag on reset.
Now, when RESET_STREAM is sent or received, or when streams are closed,
stream connection error flag is set.  Previously, only stream state was
changed, which resulted in setting the error flag only after calling
recv()/send()/send_chain().  However, there are cases when none of these
functions is called, but it's still important to know if the stream is being
closed.  For example, when an HTTP/3 request stream is blocked on insert count,
receiving RESET_STREAM should trigger stream closure, which was not the case.

The change also fixes ngx_http_upstream_check_broken_connection() and
ngx_http_test_reading() with QUIC streams.
2023-01-10 17:42:40 +04:00
Roman Arutyunyan 1253ac84df QUIC: automatically add and never delete stream events.
Previously, stream events were added and deleted by ngx_handle_read_event() and
ngx_handle_write_event() in a way similar to level-triggered events.  However,
QUIC stream events are effectively edge-triggered and can stay active all time.
Moreover, the events are now active since the moment a stream is created.
2023-01-10 14:05:18 +04:00
Sergey Kandaurov 5f8fa53775 HTTP/3: fixed $connection_time.
Previously, start_time wasn't set for a new stream.
The fix is to derive it from the parent connection.
Also it's used to simplify tracking keepalive_time.
2023-01-10 17:59:16 +04:00
Roman Arutyunyan bc654726e1 HTTP/3: handled insertion reference to a going to be evicted entry.
As per RFC 9204, section 3.2.2, a new entry can reference an entry in the
dynamic table that will be evicted when adding this new entry into the dynamic
table.

Previously, such inserts resulted in use-after-free since the old entry was
evicted before the insertion (ticket #2431).  Now it's evicted after the
insertion.

This change fixes Insert with Name Reference and Duplicate encoder instructions.
2023-01-03 16:24:45 +04:00
Sergey Kandaurov 8d5850da1f Merged with the default branch. 2023-01-02 17:10:22 +04:00
Maxim Dounin 707d223378 Updated link to OpenVZ suspend/resume bug. 2022-12-21 14:53:27 +03:00
Valentin Bartenev 3f617b7149 Fixed port ranges support in the listen directive.
Ports difference must be respected when checking addresses for duplicates,
otherwise configurations like this are broken:

  listen 127.0.0.1:6000-6005

It was broken by 4cc2bfeff46c (nginx 1.23.3).
2022-12-18 21:29:02 +03:00
BullerDu 83edadac23 Style. 2022-12-16 01:15:15 +04:00
Sergey Kandaurov 08a1c0a1d9 Version bump. 2022-12-16 01:15:13 +04:00
Sergey Kandaurov 68afb2f973 Merged with the default branch. 2022-12-15 19:40:44 +04:00
Maxim Dounin 699ae8a01c release-1.23.3 tag 2022-12-13 18:53:53 +03:00
Maxim Dounin 52917ef083 nginx-1.23.3-RELEASE 2022-12-13 18:53:53 +03:00
Maxim Dounin aa63ed2790 Updated OpenSSL and zlib used for win32 builds. 2022-12-13 03:32:57 +03:00
Maxim Dounin 7fd888bb22 Win32: event flags handling edge cases in ngx_wsarecv().
Fixed event flags handling edge cases in ngx_wsarecv() and ngx_wsarecv_chain(),
notably to always reset rev->ready in case of errors (which wasn't the case
after ngx_socket_nread() errors), and after EOF (rev->ready was not cleared
if due to a misconfiguration a zero-sized buffer was used for reading).
2022-12-01 04:22:36 +03:00
Maxim Dounin 5cd89e4788 SSL: fixed ngx_ssl_recv() to reset c->read->ready after errors.
With this change, behaviour of ngx_ssl_recv() now matches ngx_unix_recv(),
which used to always reset c->read->ready to 0 when returning errors.

This fixes an infinite loop in unbuffered SSL proxying if writing to the
client is blocked and an SSL error happens (ticket #2418).

With this change, the fix for a similar issue in the stream module
(6868:ee3645078759), which used a different approach of explicitly
testing c->read->error instead, is no longer needed and was reverted.
2022-12-01 04:22:31 +03:00
Maxim Dounin 4d077c3a47 Removed casts from ngx_memcmp() macro.
Casts are believed to be not needed, since memcmp() has "const void *"
arguments since introduction of the "void" type in C89.  And on pre-C89
platforms nginx is unlikely to compile without warnings anyway, as there
are no casts in memcpy() and memmove() calls.

These casts were added in 1648:89a47f19b9ec without any details on why they
were added, and Igor does not remember details either.  The most plausible
explanation is that they were copied from ngx_strcmp() and were not really
needed even at that time.

Prodded by Alejandro Colomar.
2022-11-30 18:01:53 +03:00
Maxim Dounin 8bb0ea63bf Fixed alignment of ngx_memmove()/ngx_movemem() macro definitions. 2022-11-30 18:01:43 +03:00
Sergey Kandaurov 6ba33e6090 SSL: fixed debug logging of SSL_sendfile() return value. 2022-11-24 23:08:30 +04:00
Maxim Dounin 73c99585a5 Fixed segfault when switching off master process during upgrade.
Binary upgrades are not supported without master process, but it is,
however, possible, that nginx running with master process is asked
to upgrade binary, and the configuration file as available on disk
at this time includes "master_process off;".

If this happens, listening sockets inherited from the previous binary
will have ls[i].previous set.  But the old cycle on initial process
startup, including startup after binary upgrade, is destroyed by
ngx_init_cycle() once configuration parsing is complete.  As a result,
an attempt to dereference ls[i].previous in ngx_event_process_init()
accesses already freed memory.

Fix is to avoid looking into ls[i].previous if the old cycle is already
freed.

With this change it is also no longer needed to clear ls[i].previous in
worker processes, so the relevant code was removed.
2022-11-23 23:48:53 +03:00
Maxim Dounin 0ef1d93199 Disabled cloning of sockets without master process (ticket #2403).
Cloning of listening sockets for each worker process does not make sense
when working without master process, and causes some of the connections
not to be accepted if worker_processes is set to more than one and there
are listening sockets configured with the reuseport flag.  Fix is to
disable cloning when master process is disabled.
2022-11-23 23:12:04 +03:00
Maxim Dounin 6fb2777ad2 Filtering duplicate addresses in listen (ticket #2400).
Due to the glibc bug[1], getaddrinfo("localhost") with AI_ADDRCONFIG
on a typical host with glibc and without IPv6 returns two 127.0.0.1
addresses, and therefore "listen localhost:80;" used to result in
"duplicate ... address and port pair" after 4f9b72a229c1.

Fix is to explicitly filter out duplicate addresses returned during
resolution of a name.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=14969
2022-11-23 17:30:08 +03:00
Roman Arutyunyan 5d65721f65 Process events posted by ngx_close_idle_connections() immediately.
Previously, if an event was posted by a read event handler, called by
ngx_close_idle_connections(), that event was not processed until the next
event loop iteration, which could happen after a timeout.
2022-11-18 19:31:38 +04:00
Ciel Zhao aa49ba2cd2 SSI: handling of subrequests from other modules (ticket #1263).
As the SSI parser always uses the context from the main request for storing
variables and blocks, that context should always exist for subrequests using
SSI, even though the main request does not necessarily have SSI enabled.

However, `ngx_http_get_module_ctx(r->main, ...)` is getting NULL in such cases,
resulting in the worker crashing SIGSEGV when accessing its attributes.

This patch links the first initialized context to the main request, and
upgrades it only when main context is initialized.
2022-11-21 17:01:34 +03:00
Maxim Dounin 2658aef1da Fixed PROXY protocol to use ngx_memcpy()/ngx_memcmp(). 2022-11-08 12:48:21 +03:00
Maxim Dounin ff6c0947b8 Added logging to PROXY protocol write buffer check.
The check is not expected to fail unless there is a bug in the calling
code.  But given the check is here, it should log an alert if it fails
instead of silently closing the connection.
2022-11-08 12:48:19 +03:00
Roman Arutyunyan 1d87a364e9 Increased maximum read PROXY protocol header size.
Maximum size for reading the PROXY protocol header is increased to 4096 to
accommodate a bigger number of TLVs, which are supported since cca4c8a715de.

Maximum size for writing the PROXY protocol header is not changed since only
version 1 is currently supported.
2022-11-02 13:46:16 +04:00
Roman Arutyunyan f457bc62dd Version bump. 2022-11-03 15:52:55 +04:00
Roman Arutyunyan 62700a2ed2 HTTP/3: implement keepalive for hq.
Previously, keepalive timer was deleted in ngx_http_v3_wait_request_handler()
and set in request cleanup handler.  This worked for HTTP/3 connections, but not
for hq connections.  Now keepalive timer is deleted in
ngx_http_v3_init_request_stream() and set in connection cleanup handler,
which works both for HTTP/3 and hq.
2022-10-25 12:52:09 +04:00
Roman Arutyunyan aa58c6457a QUIC: application init() callback.
It's called after handshake completion or prior to the first early data stream
creation.  The callback should initialize application-level data before
creating streams.

HTTP/3 callback implementation sets keepalive timer and sends SETTINGS.

Also, this allows to limit max handshake time in ngx_http_v3_init_stream().
2022-11-30 12:51:15 +04:00
Maxim Dounin f0f0c9a867 release-1.23.2 tag 2022-10-19 10:56:21 +03:00
Maxim Dounin e9910b7063 nginx-1.23.2-RELEASE 2022-10-19 10:56:20 +03:00
Roman Arutyunyan 8a78de6d6a Mp4: disabled duplicate atoms.
Most atoms should not appear more than once in a container.  Previously,
this was not enforced by the module, which could result in worker process
crash, memory corruption and disclosure.
2022-10-19 10:53:17 +03:00
Sergey Kandaurov a86de64900 SSL: improved validation of ssl_session_cache and ssl_ocsp_cache.
Now it properly detects invalid shared zone configuration with omitted size.
Previously it used to read outside of the buffer boundary.

Found with AddressSanitizer.
2022-10-17 16:24:53 +04:00
Sergey Kandaurov be9d072dce SSL: removed cast not needed after 5ffd76a9ccf3. 2022-10-13 16:18:56 +04:00
Maxim Dounin 1b916f5c20 SSL: workaround for session timeout handling with TLSv1.3.
OpenSSL with TLSv1.3 updates the session creation time on session
resumption and keeps the session timeout unmodified, making it possible
to maintain the session forever, bypassing client certificate expiration
and revocation.  To make sure session timeouts are actually used, we
now update the session creation time and reduce the session timeout
accordingly.

BoringSSL with TLSv1.3 ignores configured session timeouts and uses a
hardcoded timeout instead, 7 days.  So we update session timeout to
the configured value as soon as a session is created.
2022-10-12 20:14:57 +03:00
Maxim Dounin 9d7861c041 SSL: optimized rotation of session ticket keys.
Instead of syncing keys with shared memory on each ticket operation,
the code now does this only when the worker is going to change expiration
of the current key, or going to switch to a new key: that is, usually
at most once per second.

To do so without races, the code maintains 3 keys: current, previous,
and next.  If a worker will switch to the next key earlier, other workers
will still be able to decrypt new tickets, since they will be encrypted
with the next key.
2022-10-12 20:14:55 +03:00
Maxim Dounin 792f04dad0 SSL: automatic rotation of session ticket keys.
As long as ssl_session_cache in shared memory is configured, session ticket
keys are now automatically generated in shared memory, and rotated
periodically.  This can be beneficial from forward secrecy point of view,
and also avoids increased CPU usage after configuration reloads.

This also helps BoringSSL to properly resume sessions in configurations
with multiple worker processes and no ssl_session_ticket_key directives,
as BoringSSL tries to automatically rotate session ticket keys and does
this independently in different worker processes, thus breaking session
resumption between worker processes.
2022-10-12 20:14:53 +03:00
Maxim Dounin 2e2c146aa5 SSL: shorter debug messages about session tickets. 2022-10-12 20:14:51 +03:00
Maxim Dounin 0c18bd861d SSL: renamed session ticket key functions and data index.
Previously used names are way too long, renamed to simplify writing code.
2022-10-12 20:14:49 +03:00
Maxim Dounin 48fb597c4b SSL: renamed session ticket key type.
The ngx_ssl_session_ticket_key_t is way too long, renamed to
ngx_ssl_ticket_key_t to simplify writing code.
2022-10-12 20:14:47 +03:00
Maxim Dounin 96d88871dc SSL: style.
Runtime OCSP functions separated from configuration ones.
2022-10-12 20:14:45 +03:00
Maxim Dounin 4540a1a2f6 SSL: explicit clearing of expired sessions.
This reduces lifetime of session keying material in server's memory, and
therefore can be beneficial from forward secrecy point of view.
2022-10-12 20:14:43 +03:00
Maxim Dounin 099e089879 SSL: single allocation in session cache on 32-bit platforms.
Given the present typical SSL session sizes, on 32-bit platforms it is
now beneficial to store all data in a single allocation, since rbtree
node + session id + ASN1 representation of a session takes 256 bytes of
shared memory (36 + 32 + 150 = about 218 bytes plus SNI server name).

Storing all data in a single allocation is beneficial for SNI names up to
about 40 characters long and makes it possible to store about 4000 sessions
in one megabyte (instead of about 3000 sessions now).  This also slightly
simplifies the code.
2022-10-12 20:14:40 +03:00
Maxim Dounin 5595d35a2c SSL: explicit session id length checking.
Session ids are not expected to be longer than 32 bytes, but this is
theoretically possible with TLSv1.3, where session ids are essentially
arbitrary and sent as session tickets.  Since on 64-bit platforms we
use fixed 32-byte buffer for session ids, added an explicit length check
to make sure the buffer is large enough.
2022-10-12 20:14:39 +03:00
Maxim Dounin b1366da936 SSL: updated comment about session sizes.
Previous numbers are somewhat outdated, typical ASN1 representations of
sessions are slightly bigger now.
2022-10-12 20:14:37 +03:00
Maxim Dounin 569325fc41 SSL: reduced logging of session cache failures (ticket #621).
Session cache allocations might fail as long as the new session is different
in size from the one least recently used (and freed when the first allocation
fails).  In particular, it might not be possible to allocate space for
sessions with client certificates, since they are noticeably bigger than
normal sessions.

To ensure such allocation failures won't clutter logs, logging level changed
to "warn", and logging is now limited to at most one warning per second.
2022-10-12 20:14:36 +03:00
Maxim Dounin 833473a03a SSL: disabled saving tickets to session cache.
OpenSSL tries to save TLSv1.3 sessions into session cache even when using
tickets for stateless session resumption, "because some applications just
want to know about the creation of a session".  To avoid trashing session
cache with useless data, we do not save such sessions now.
2022-10-12 20:14:34 +03:00
Roman Arutyunyan da83d4d495 Added type cast to ngx_proxy_protocol_parse_uint16().
The cast is added to make ngx_proxy_protocol_parse_uint16() similar to
ngx_proxy_protocol_parse_uint32().
2022-09-27 11:31:16 +04:00
Roman Arutyunyan 67ab4fc894 PROXY protocol v2 TLV variables.
The variables have prefix $proxy_protocol_tlv_ and are accessible by name
and by type.  Examples are: $proxy_protocol_tlv_0x01, $proxy_protocol_tlv_alpn.
2022-10-12 16:58:16 +04:00
Roman Arutyunyan a35afc196f Log only the first line of user input on PROXY protocol v1 error.
Previously, all received user input was logged.  If a multi-line text was
received from client and logged, it could reduce log readability and also make
it harder to parse nginx log by scripts.  The change brings to PROXY protocol
the same behavior that exists for HTTP request line in
ngx_http_log_error_handler().
2022-10-10 13:57:31 +04:00
Sergey Kandaurov 7bbb03f263 SSL: silenced GCC warnings when building with BoringSSL.
BoringSSL uses macro stub for SSL_CTX_set_ecdh_auto that expands to 1,
which triggers -Wunused-value "statement with no effect" warnings.
2022-09-08 13:53:49 +04:00
Maxim Dounin 401702af41 Win32: disabled threads support in OpenSSL builds.
Threads are disabled during UNIX builds (see b329c0ab1a48), and also not
needed for Windows builds.

This used to be the default before OpenSSL 1.1.0.
2022-09-07 00:47:31 +03:00
Maxim Dounin 6efacf745c Win32: fixed build on Windows with OpenSSL 3.0.x (ticket #2379).
SSL_sendfile() expects integer file descriptor as an argument, but nginx
uses OS file handles (HANDLE) to work with files on Windows, and passing
HANDLE instead of an integer correctly results in build failure.  Since
SSL_sendfile() is not expected to work on Windows anyway, the code is now
disabled on Windows with appropriate compile-time checks.
2022-09-07 00:47:17 +03:00
Maxim Dounin fdc331ac71 Win32: disabled C4306 warnings with MSVC.
Multiple C4306 warnings (conversion from 'type1' to 'type2' of greater size)
appear during 64-bit compilation with MSVC 2010 (and older) due to extensively
used constructs like "(void *) -1", so they were disabled.

In newer MSVC versions C4306 warnings were replaced with C4312 ones, and
these are not generated for such trivial type casts.
2022-09-07 00:47:07 +03:00
Maxim Dounin 4417892a13 Win32: removed misleading comment about warnings being disabled.
Warnings being disabled are not only from the "-W4" level since e4590dfd97ff.
2022-09-07 00:47:02 +03:00
Maxim Dounin 02b135834c SSL: fixed incorrect usage of #if instead of #ifdef.
In 2014ed60f17f, "#if SSL_CTRL_SET_ECDH_AUTO" test was incorrectly used
instead of "#ifdef SSL_CTRL_SET_ECDH_AUTO".  There is no practical
difference, since SSL_CTRL_SET_ECDH_AUTO evaluates to a non-zero numeric
value when defined, but anyway it's better to correctly test if the value
is defined.
2022-09-07 00:44:10 +03:00
Maxim Dounin 984bddc6c0 Events: fixed style and wrong error handling in the iocp module. 2022-09-07 00:43:51 +03:00
Roman Arutyunyan 2fb971a6b9 HTTP/3: renamed functions.
ngx_http_v3_init() is renamed ngx_http_v3_init_stream().
ngx_http_v3_reset_connection() is renamed to ngx_http_v3_reset_stream().
2022-08-22 14:09:03 +04:00
Roman Arutyunyan 1ff821f800 QUIC: removed cancelable flag from QUIC and HTTP/3 events.
All these events are created in context of a client connection and are deleted
when the connection is closed.  Setting ev->cancelable could trigger premature
connection closure and a socket leak alert.
2022-11-30 14:09:08 +04:00
Roman Arutyunyan 595a642018 QUIC: idle mode for main connection.
Now main QUIC connection for HTTP/3 always has c->idle flag set.  This allows
the connection to receive worker shutdown notification.  It is passed to
application level via a new conf->shutdown() callback.

The HTTP/3 shutdown callback sends GOAWAY to client and gracefully shuts down
the QUIC connection.
2022-10-19 17:45:18 +04:00
Roman Arutyunyan 7cccd64670 HTTP/3: unified hq code with regular HTTP/3 code.
The change removes hq-specific request handler.  Now hq requests are handled
by the HTTP/3 request handler.
2022-10-19 17:45:30 +04:00
Roman Arutyunyan f24d60c54d QUIC: do not send MAX_STREAMS in shutdown state.
No more streams are expected from client.
2022-09-07 13:12:56 +04:00
Roman Arutyunyan 75f37d3fc6 QUIC: defer stream removal until all its data is acked.
Previously, stream was kept alive until all its data is sent.  This resulted
in disabling retransmission of final part of stream when QUIC connection
was closed right after closing stream connection.
2022-08-22 15:33:23 +04:00
Roman Arutyunyan 6949b4b4c2 QUIC: reusable mode for main connection.
The connection is automatically switched to this mode by transport layer when
there are no non-cancelable streams.  Currently, cancelable streams are
HTTP/3 encoder/decoder/control streams.
2022-11-29 17:46:46 +04:00
Roman Arutyunyan fbd48371fe QUIC: post close event for connection close.
Previously, close event was used only for close timeout, while read event was
used for posting connection close.
2022-09-07 19:25:13 +04:00
Roman Arutyunyan 5ae19ab1a5 QUIC: made ngx_quic_finalize_connecion() more graceful.
Previously, ngx_quic_finalize_connection() closed the connection with NGX_ERROR
code, which resulted in immediate connection closure.  Now the code is NGX_OK,
which provides a more graceful shutdown with a timeout.
2022-08-22 15:28:51 +04:00
Roman Arutyunyan be17320c91 QUIC: treat qc->error == -1 as a missing error.
Previously, zero was used for this purpose.  However, NGX_QUIC_ERR_NO_ERROR is
zero too.  As a result, NGX_QUIC_ERR_NO_ERROR was changed to
NGX_QUIC_ERR_INTERNAL_ERROR when closing a QUIC connection.
2022-09-07 12:37:15 +04:00
Sergey Kandaurov 6c843d19f2 QUIC: fixed computation of nonce with packet numbers beyond 2^32.
Prodded by Yu Zhu.
2022-11-25 15:56:33 +04:00
Jiuzhou Cui a7bda07bda HTTP/3: fixed build without NGX_PCRE (broken by 0f5fc7a320db). 2022-11-25 15:07:23 +08:00
Roman Arutyunyan 7702f830dd QUIC: fixed triggering stream read event (ticket #2409).
If a client packet carrying a stream data frame is not acked due to packet loss,
the stream data is retransmitted later by client.  It's also possible that the
retransmitted range is bigger than before due to more stream data being
available by then.  If the original data was read out by the application,
there would be no read event triggered by the retransmitted frame, even though
it contains new data.
2022-11-23 18:50:26 +04:00
Sergey Kandaurov a53a72f079 QUIC: fixed C4334 MSVC warning about 32 to 64 bits conversion. 2022-11-22 18:05:37 +04:00
Sergey Kandaurov 3cf42a4a1d QUIC: plug MSVC warning about potentially uninitialized variable. 2022-11-22 18:05:37 +04:00
Sergey Kandaurov c71b6810be Added shutdown macros for win32 required for QUIC. 2022-11-22 18:05:36 +04:00
Sergey Kandaurov 690e72d8b6 QUIC: fixed C4389 MSVC warning about signed/unsigned mismatch. 2022-11-22 18:05:36 +04:00
Sergey Kandaurov 41a5fad87b QUIC: avoid using C99 designated initializers.
They are not supported by MSVC till 2012.

SSL_QUIC_METHOD initialization is moved to run-time to preserve portability
among SSL library implementations, which allows to reduce its visibility.
Note using of a static storage to keep SSL_set_quic_method() reference valid.
2022-11-22 18:05:35 +04:00
Sergey Kandaurov 8e422fd5e8 QUIC: moved variable declaration to fix build with MSVC 2010.
Previously, ngx_quic_hkdf_t variables used declaration with assignment
in the middle of a function, which is not supported by MSVC 2010.
Fixing this also required to rewrite the ngx_quic_hkdf_set macro
and to switch to an explicit array size.
2022-11-22 18:05:35 +04:00
Sergey Kandaurov 5a00ab5877 QUIC: fixed C4706 warnings with MSVC 2010.
The fix is to avoid assignments within conditional expression.
2022-11-22 18:05:34 +04:00
Sergey Kandaurov 4d1689d053 HTTP/3: fixed server_name regex captures (ticket #2407).
Previously, HTTP/3 stream connection didn't inherit the servername regex
from the main QUIC connection saved when processing SNI and using regular
expressions in server names.  As a result, it didn't execute to set regex
captures when choosing the virtual server while parsing HTTP/3 headers.
2022-11-22 14:10:04 +04:00
Roman Arutyunyan 0854b8073f Set default listen socket type in http.
The type field was added in 7999d3fbb765 at early stages of QUIC implementation
and was not initialized for default listen.  Missing initialization resulted in
default listen socket creation error.
2022-11-01 17:00:35 +04:00
Sergey Kandaurov de23dc786b Merged with the default branch. 2022-10-20 16:41:36 +04:00
Sergey Kandaurov 628d0113ae README: converted to passive voice, LibreSSL support. 2022-10-20 16:30:43 +04:00
Sergey Kandaurov 993631dea7 QUIC: removed compatibility with older BoringSSL API.
SSL_CIPHER_get_protocol_id() appeared in BoringSSL somewhere between
BORINGSSL_API_VERSION 12 and 13 for compatibility with OpenSSL 1.1.1.
It was adopted without a proper macro test, which remained unnoticed.
This justifies that such old BoringSSL API isn't widely used and its
support can be dropped.

While here, removed SSL_set_quic_use_legacy_codepoint() that became
useless after the default was flipped in BoringSSL over a year ago.
2022-10-20 16:21:07 +04:00
Sergey Kandaurov d0bd68de53 QUIC: support for setting QUIC methods with LibreSSL.
Setting QUIC methods is converted to use C99 designated initializers
for simplicity, as LibreSSL 3.6.0 has different SSL_QUIC_METHOD layout.

Additionally, only set_read_secret/set_write_secret callbacks are set.
Although they are preferred in LibreSSL over set_encryption_secrets,
better be on a safe side as LibreSSL has unexpectedly incompatible
set_encryption_secrets calling convention expressed in passing read
and write secrets split in separate calls, unlike this is documented
in old BoringSSL sources.  To avoid introducing further changes for
the old API, it is simply disabled.
2022-10-20 16:21:06 +04:00
Sergey Kandaurov e5ebf25fcc QUIC: using SSL_set_quic_early_data_enabled() only with QuicTLS.
This function is present in QuicTLS only.  After SSL_READ_EARLY_DATA_SUCCESS
became visible in LibreSSL together with experimental QUIC API, this required
to revise the conditional compilation test to use more narrow macros.
2022-10-20 16:21:06 +04:00
Sergey Kandaurov 6b7d3d64c3 QUIC: using native TLSv1.3 cipher suite constants.
After BoringSSL aligned[1] with OpenSSL on TLS1_3_CK_* macros, and
LibreSSL uses OpenSSL naming, our own variants can be dropped now.
Compatibility is preserved with libraries that lack these macros.

Additionally, transition to SSL_CIPHER_get_id() fixes build error
with LibreSSL that doesn't implement SSL_CIPHER_get_protocol_id().

[1] https://boringssl.googlesource.com/boringssl/+/dfddbc4ded
2022-10-20 16:21:05 +04:00
Sergey Kandaurov 03a1a94d18 QUIC: "info" logging level on insufficient client connection ids.
Apparently, this error is reported on NAT rebinding if client didn't
previously send NEW_CONNECTION_ID to supply additional connection ids.
2022-09-30 17:24:47 +04:00
Sergey Kandaurov 26c9efed33 README: updated the current status. 2022-09-12 18:37:36 +04:00
Murilo Andrade 9e68d2296f SSL: logging level of "bad record type" errors.
The SSL_R_BAD_RECORD_TYPE ("bad record type") errors are reported by
OpenSSL 1.1.1 or newer when using TLSv1.3 if the client sends a record
with unknown or unexpected type.  These errors are now logged at the
"info" level.
2022-08-09 17:13:46 -03:00
Maxim Dounin 4dfce3ca3c Version bump. 2022-08-30 01:52:51 +03:00
Roman Arutyunyan 2d72193dc0 HTTP/3: skip empty request body buffers (ticket #2374).
When client DATA frame header and its content come in different QUIC packets,
it may happen that only the header is processed by the first
ngx_http_v3_request_body_filter() call.  In this case an empty request body
buffer is added to r->request_body->bufs, which is later reused in a
subsequent ngx_http_v3_request_body_filter() call without being removed from
the body chain.  As a result, rb->request_body->bufs ends up with two copies of
the same buffer.

The fix is to avoid adding empty request body buffers to r->request_body->bufs.
2022-08-03 16:59:51 +04:00
Maxim Dounin 15d70dbd7d release-1.23.1 tag 2022-07-19 17:05:27 +03:00
Maxim Dounin 5b4af5c1e1 nginx-1.23.1-RELEASE 2022-07-19 17:05:27 +03:00
Maxim Dounin 9fcbfb1255 Updated OpenSSL used for win32 builds. 2022-07-19 17:03:30 +03:00
Maxim Dounin b585c3b74e Events: fixed EPOLLRDHUP with FIONREAD (ticket #2367).
When reading exactly rev->available bytes, rev->available might become 0
after FIONREAD usage introduction in efd71d49bde0.  On the next call of
ngx_readv_chain() on systems with EPOLLRDHUP this resulted in return without
any actions, that is, with rev->ready set, and this in turn resulted in no
timers set in event pipe, leading to socket leaks.

Fix is to reset rev->ready in ngx_readv_chain() when returning due to
rev->available being 0 with EPOLLRDHUP, much like it is already done in
ngx_unix_recv().  This ensures that if rev->available will become 0, on
systems with EPOLLRDHUP support appropriate EPOLLRDHUP-specific handling
will happen on the next ngx_readv_chain() call.

While here, also synced ngx_readv_chain() to match ngx_unix_recv() and
reset rev->ready when returning due to rev->available being 0 with kqueue.
This is mostly cosmetic change, as rev->ready is anyway reset when
rev->available is set to 0.
2022-07-15 15:19:32 +03:00
Maxim Dounin ce67cac0ba Range filter: clearing of pre-existing Content-Range headers.
Some servers might emit Content-Range header on 200 responses, and this
does not seem to contradict RFC 9110: as per RFC 9110, the Content-Range
header has no meaning for status codes other than 206 and 416.  Previously
this resulted in duplicate Content-Range headers in nginx responses handled
by the range filter.  Fix is to clear pre-existing headers.
2022-07-15 07:01:44 +03:00
Sergey Kandaurov ec2ecdd62b Resolver: fixed memory leak for the "ipv4=off" case.
This change partially reverts 2a77754cd9fe to properly free rn->query.

Found by Coverity (CID 1507244).
2022-07-14 21:26:54 +04:00
Ruslan Ermilov bcf1402445 The "ipv4=" parameter of the "resolver" directive.
When set to "off", only IPv6 addresses will be resolved, and no
A queries are ever sent (ticket #2196).
2022-07-12 21:44:02 +04:00
Maxim Dounin f94e5b01a7 SSL: logging levels of various errors added in OpenSSL 1.1.1.
Starting with OpenSSL 1.1.1, various additional errors can be reported
by OpenSSL in case of client-related issues, most notably during TLSv1.3
handshakes.  In particular, SSL_R_BAD_KEY_SHARE ("bad key share"),
SSL_R_BAD_EXTENSION ("bad extension"), SSL_R_BAD_CIPHER ("bad cipher"),
SSL_R_BAD_ECPOINT ("bad ecpoint").  These are now logged at the "info"
level.
2022-07-12 15:55:22 +03:00
Maxim Dounin 86fa8882c8 Upstream: optimized use of SSL contexts (ticket #1234).
To ensure optimal use of memory, SSL contexts for proxying are now
inherited from previous levels as long as relevant proxy_ssl_* directives
are not redefined.

Further, when no proxy_ssl_* directives are redefined in a server block,
we now preserve plcf->upstream.ssl in the "http" section configuration
to inherit it to all servers.

Similar changes made in uwsgi, grpc, and stream proxy.
2022-06-29 02:47:45 +03:00
Maxim Dounin ef4919f875 Version bump. 2022-06-29 02:47:38 +03:00
Maxim Dounin e5accc5b36 release-1.23.0 tag 2022-06-21 17:25:37 +03:00
Maxim Dounin 266ad70b19 nginx-1.23.0-RELEASE 2022-06-21 17:25:36 +03:00
Maxim Dounin bfe9ab90ba Updated OpenSSL used for win32 builds. 2022-06-21 17:09:34 +03:00
Maxim Dounin cd4f57ef8d Misc: win32 sources now preserved in release tarballs.
This makes it possible to build nginx under Windows from release tarballs
instead of using source code repository.
2022-06-20 19:30:50 +03:00
Gena Makhomed 4a4d67a03d Contrib: vim syntax, update core and 3rd party module directives.
List of 3rd party modules github repositories are obtained from
https://github.com/freebsd/freebsd-ports/blob/main/www/nginx-devel/Makefile.extmod
2022-06-18 15:54:40 +03:00
Sergey Kandaurov 9912eb8939 Perl: removed unused variables, forgotten in ef6a3a99a81a. 2022-06-14 10:39:58 +04:00
Aleksei Bavshin b29e4652bb Resolver: make TCP write timer event cancelable.
Similar to 70e65bf8dfd7, the change is made to ensure that the ability to
cancel resolver tasks is fully controlled by the caller.  As mentioned in the
referenced commit, it is safe to make this timer cancelable because resolve
tasks can have their own timeouts that are not cancelable.

The scenario where this may become a problem is a periodic background resolve
task (not tied to a specific request or a client connection), which receives a
response with short TTL, large enough to warrant fallback to a TCP query.
With each event loop wakeup, we either have a previously set write timer
instance or schedule a new one.  The non-cancelable write timer can delay or
block graceful shutdown of a worker even if the ngx_resolver_ctx_t->cancelable
flag is set by the API user, and there are no other tasks or connections.

We use the resolver API in this way to maintain the list of upstream server
addresses specified with the 'resolve' parameter, and there could be third-party
modules implementing similar logic.
2022-06-01 20:17:23 -07:00
Vladimir Homutov d3d5a9b8a4 QUIC: avoided pool usage in token calculation. 2022-05-31 11:05:22 +04:00
Vladimir Homutov fe6cac822c QUIC: removed ngx_quic_keys_new().
The ngx_quic_keys_t structure is now exposed.
2022-07-27 17:31:16 +04:00
Vladimir Homutov da18efff87 QUIC: avoided pool usage in ngx_quic_protection.c. 2022-07-27 17:16:40 +04:00
Vladimir Homutov 17c9506b58 QUIC: fixed-length buffers for secrets. 2022-07-27 17:15:33 +04:00
Sergey Kandaurov 03b740ba06 Merged with the default branch. 2022-07-26 19:54:11 +04:00
Sergey Kandaurov f2bc2e05d0 Merged with the default branch. 2022-06-22 18:34:58 +04:00
Sergey Kandaurov 658e350aae HTTP/3: updated SETTINGS_MAX_FIELD_SECTION_SIZE name. 2022-06-08 16:19:01 +04:00
Sergey Kandaurov 62e6a35da7 README: updated after HTTP/3 RFC publication, minor refinements. 2022-06-08 15:30:08 +04:00
Roman Arutyunyan b752b1ec26 HTTP/3: require that field section base index is not negative.
RFC 9204 explicitly requires that.
2022-05-26 16:17:56 +04:00
Aleksei Bavshin 663445ba7a Stream: don't flush empty buffers created for read errors.
When we generate the last_buf buffer for an UDP upstream recv error, it does
not contain any data from the wire. ngx_stream_write_filter attempts to forward
it anyways, which is incorrect (e.g., UDP upstream ECONNREFUSED will be
translated to an empty packet).

This happens because we mark the buffer as both 'flush' and 'last_buf', and
ngx_stream_write_filter has special handling for flush with certain types of
connections (see d127837c714f, 32b0ba4855a6).  The flags are meant to be
mutually exclusive, so the fix is to ensure that flush and last_buf are not set
at the same time.

Reproduction:

stream {
    upstream unreachable {
        server     127.0.0.1:8880;
    }
    server {
        listen     127.0.0.1:8998 udp;
        proxy_pass unreachable;
    }
}

1 0.000000000    127.0.0.1 → 127.0.0.1    UDP 47 45588 → 8998 Len=5
2 0.000166300    127.0.0.1 → 127.0.0.1    UDP 47 51149 → 8880 Len=5
3 0.000172600    127.0.0.1 → 127.0.0.1    ICMP 75 Destination unreachable (Port
unreachable)
4 0.000202400    127.0.0.1 → 127.0.0.1    UDP 42 8998 → 45588 Len=0

Fixes d127837c714f.
2022-05-23 11:29:44 -07:00
Maxim Dounin 8d3f47c131 Mp4: fixed potential overflow in ngx_http_mp4_crop_stts_data().
Both "count" and "duration" variables are 32-bit, so their product might
potentially overflow.  It is used to reduce 64-bit start_time variable,
and with very large start_time this can result in incorrect seeking.

Found by Coverity (CID 1499904).
2022-06-07 21:58:52 +03:00
Sergey Kandaurov 82ff3c2d8c Upstream: handling of certificates specified as an empty string.
Now, if the directive is given an empty string, such configuration cancels
loading of certificates, in particular, if they would be otherwise inherited
from the previous level.  This restores previous behaviour, before variables
support in certificates was introduced (3ab8e1e2f0f7).
2022-06-07 20:08:57 +04:00
Maxim Dounin bb4d3b091d Upstream: fixed X-Accel-Expires/Cache-Control/Expires handling.
Previously, if caching was disabled due to Expires in the past, nginx
failed to cache the response even if it was cacheable as per subsequently
parsed Cache-Control header (ticket #964).

Similarly, if caching was disabled due to Expires in the past,
"Cache-Control: no-cache" or "Cache-Control: max-age=0", caching was not
used if it was cacheable as per subsequently parsed X-Accel-Expires header.

Fix is to avoid disabling caching immediately after parsing Expires in
the past or Cache-Control, but rather set flags which are later checked by
ngx_http_upstream_process_headers() (and cleared by "Cache-Control: max-age"
and X-Accel-Expires).

Additionally, now X-Accel-Expires does not prevent parsing of cache control
extensions, notably stale-while-revalidate and stale-if-error.  This
ensures that order of the X-Accel-Expires and Cache-Control headers is not
important.

Prodded by Vadim Fedorenko and Yugo Horie.
2022-06-07 00:07:12 +03:00
Maxim Dounin e571a75ba4 Upstream: fixed build without http cache (broken by cd73509f21e2). 2022-05-31 00:14:11 +03:00
Maxim Dounin 7ec70432d4 Headers filter: improved memory allocation error handling. 2022-05-30 21:25:57 +03:00
Maxim Dounin c43e768c74 Multiple WWW-Authenticate headers with "satisfy any;".
If a module adds multiple WWW-Authenticate headers (ticket #485) to the
response, linked in r->headers_out.www_authenticate, all headers are now
cleared if another module later allows access.

This change is a nop for standard modules, since the only access module which
can add multiple WWW-Authenticate headers is the auth request module, and
it is checked after other standard access modules.  Though this might
affect some third party access modules.

Note that if a 3rd party module adds a single WWW-Authenticate header
and not yet modified to set the header's next pointer to NULL, attempt to
clear such a header with this change will result in a segmentation fault.
2022-05-30 21:25:56 +03:00
Maxim Dounin ac4d19865a Auth request: multiple WWW-Authenticate headers (ticket #485).
When using auth_request with an upstream server which returns 401
(Unauthorized), multiple WWW-Authenticate headers from the upstream server
response are now properly copied to the response.
2022-05-30 21:25:54 +03:00
Maxim Dounin 3d731d9748 Upstream: multiple WWW-Authenticate headers (ticket #485).
When using proxy_intercept_errors and an error page for error 401
(Unauthorized), multiple WWW-Authenticate headers from the upstream server
response are now properly copied to the response.
2022-05-30 21:25:53 +03:00
Maxim Dounin 12bd0b0884 Upstream: handling of multiple Vary headers (ticket #1423).
Previously, only the last header value was used when caching.
2022-05-30 21:25:51 +03:00
Maxim Dounin 027b46b7ea Upstream: duplicate headers ignored or properly linked.
Most of the known duplicate upstream response headers are now ignored
with a warning.

If syntax permits multiple headers, these are now properly linked to
the lists, notably Vary and WWW-Authenticate.  This makes it possible
to further handle such lists where it makes sense.
2022-05-30 21:25:49 +03:00
Maxim Dounin 47e9ce390d Upstream: header handlers can now return parsing errors.
With this change, duplicate Content-Length and Transfer-Encoding headers
are now rejected.  Further, responses with invalid Content-Length or
Transfer-Encoding headers are now rejected, as well as responses with both
Content-Length and Transfer-Encoding.
2022-05-30 21:25:48 +03:00
Maxim Dounin 4e5ce1fa2e Upstream: all known headers in u->headers_in are linked lists now. 2022-05-30 21:25:46 +03:00
Maxim Dounin dd06c6b586 All known output headers can be linked lists now.
The h->next pointer properly provided as NULL in all cases where known
output headers are added.

Note that there are 3rd party modules which might not do this, and it
might be risky to rely on this for arbitrary headers.
2022-05-30 21:25:45 +03:00
Maxim Dounin 95ec5e3d95 Upstream: simplified Accept-Ranges handling.
The u->headers_in.accept_ranges field is not used anywhere and hence removed.
2022-05-30 21:25:43 +03:00
Maxim Dounin f77cf83837 Upstream: simplified Content-Encoding handling.
Since introduction of offset handling in ngx_http_upstream_copy_header_line()
in revision 573:58475592100c, the ngx_http_upstream_copy_content_encoding()
function is no longer needed, as its behaviour is exactly equivalent to
ngx_http_upstream_copy_header_line() with appropriate offset.  As such,
the ngx_http_upstream_copy_content_encoding() function was removed.

Further, the u->headers_in.content_encoding field is not used anywhere,
so it was removed as well.

Further, Content-Encoding handling no longer depends on NGX_HTTP_GZIP,
as it can be used even without any gzip handling compiled in (for example,
in the charset filter).
2022-05-30 21:25:42 +03:00
Maxim Dounin e1778b75f3 Upstream: style. 2022-05-30 21:25:40 +03:00
Maxim Dounin bf8acaa78a Perl: combining unknown headers during $r->header_in() lookup. 2022-05-30 21:25:38 +03:00
Maxim Dounin 7de2b91556 Perl: all known input headers are handled identically.
As all known input headers are now linked lists, these are now handled
identically.  In particular, this makes it possible to access properly
combined values of headers not specifically handled previously, such
as "Via" or "Connection".
2022-05-30 21:25:36 +03:00
Maxim Dounin 0c2a0ef934 All non-unique input headers are now linked lists.
The ngx_http_process_multi_header_lines() function is removed, as it is
exactly equivalent to ngx_http_process_header_line().  Similarly,
ngx_http_variable_header() is used instead of ngx_http_variable_headers().
2022-05-30 21:25:35 +03:00
Maxim Dounin 29a1e8e317 Reworked multi headers to use linked lists.
Multi headers are now using linked lists instead of arrays.  Notably,
the following fields were changed: r->headers_in.cookies (renamed
to r->headers_in.cookie), r->headers_in.x_forwarded_for,
r->headers_out.cache_control, r->headers_out.link, u->headers_in.cache_control
u->headers_in.cookies (renamed to u->headers_in.set_cookie).

The r->headers_in.cookies and u->headers_in.cookies fields were renamed
to r->headers_in.cookie and u->headers_in.set_cookie to match header names.

The ngx_http_parse_multi_header_lines() and ngx_http_parse_set_cookie_lines()
functions were changed accordingly.

With this change, multi headers are now essentially equivalent to normal
headers, and following changes will further make them equivalent.
2022-05-30 21:25:33 +03:00
Maxim Dounin ad8f9f7411 Combining unknown headers during variables lookup (ticket #1316).
Previously, $http_*, $sent_http_*, $sent_trailer_*, $upstream_http_*,
and $upstream_trailer_* variables returned only the first header (with
a few specially handled exceptions: $http_cookie, $http_x_forwarded_for,
$sent_http_cache_control, $sent_http_link).

With this change, all headers are returned, combined together.  For
example, $http_foo variable will be "a, b" if there are "Foo: a" and
"Foo: b" headers in the request.

Note that $upstream_http_set_cookie will also return all "Set-Cookie"
headers (ticket #1843), though this might not be what one want, since
the "Set-Cookie" header does not follow the list syntax (see RFC 7230,
section 3.2.2).
2022-05-30 21:25:32 +03:00
Maxim Dounin f6087d2731 Uwsgi: combining headers with identical names (ticket #1724).
The uwsgi specification states that "The uwsgi block vars represent a
dictionary/hash".  This implies that no duplicate headers are expected.

Further, provided headers are expected to follow CGI specification,
which also requires to combine headers (RFC 3875, section "4.1.18.
Protocol-Specific Meta-Variables"): "If multiple header fields with
the same field-name are received then the server MUST rewrite them
as a single value having the same semantics".
2022-05-30 21:25:30 +03:00
Maxim Dounin d86b7da869 SCGI: combining headers with identical names (ticket #1724).
SCGI specification explicitly forbids headers with duplicate names
(section "3. Request Format"): "Duplicate names are not allowed in
the headers".

Further, provided headers are expected to follow CGI specification,
which also requires to combine headers (RFC 3875, section "4.1.18.
Protocol-Specific Meta-Variables"): "If multiple header fields with
the same field-name are received then the server MUST rewrite them
as a single value having the same semantics".
2022-05-30 21:25:28 +03:00
Maxim Dounin 189568930e FastCGI: combining headers with identical names (ticket #1724).
FastCGI responder is expected to receive CGI/1.1 environment variables
in the parameters (see section "6.2 Responder" of the FastCGI specification).
Obviously enough, there cannot be multiple environment variables with
the same name.

Further, CGI specification (RFC 3875, section "4.1.18. Protocol-Specific
Meta-Variables") explicitly requires to combine headers: "If multiple
header fields with the same field-name are received then the server MUST
rewrite them as a single value having the same semantics".
2022-05-30 21:25:27 +03:00
Maxim Dounin 021a3fbc4e Perl: fixed $r->header_in("Connection").
Previously, the r->header_in->connection pointer was never set despite
being present in ngx_http_headers_in, resulting in incorrect value returned
by $r->header_in("Connection") in embedded perl.
2022-05-30 21:25:25 +03:00
Marcus Ball 01ca68ac56 Fixed runtime handling of systems without EPOLLRDHUP support.
In 7583:efd71d49bde0 (nginx 1.17.5) along with introduction of the
ioctl(FIONREAD) support proper handling of systems without EPOLLRDHUP
support in the kernel (but with EPOLLRDHUP in headers) was broken.

Before the change, rev->available was never set to 0 unless
ngx_use_epoll_rdhup was also set (that is, runtime test for EPOLLRDHUP
introduced in 6536:f7849bfb6d21 succeeded).  After the change,
rev->available might reach 0 on systems without runtime EPOLLRDHUP
support, stopping further reading in ngx_readv_chain() and ngx_unix_recv().
And, if EOF happened to be already reported along with the last event,
it is not reported again by epoll_wait(), leading to connection hangs
and timeouts on such systems.

This affects Linux kernels before 2.6.17 if nginx was compiled
with newer headers, and, more importantly, emulation layers, such as
DigitalOcean's App Platform's / gVisor's epoll emulation layer.

Fix is to explicitly check ngx_use_epoll_rdhup before the corresponding
rev->pending_eof tests in ngx_readv_chain() and ngx_unix_recv().
2022-05-30 02:38:07 +03:00
Maxim Dounin 8e2a2eca0b Version bump. 2022-05-30 02:37:59 +03:00
Maxim Dounin 698672af41 Updated OpenSSL and zlib used for win32 builds. 2022-05-24 02:51:49 +03:00
Sergey Kandaurov 4ecd24e967 Configure: recognize arm64 machine name as a synonym for aarch64.
In particular, this sets a reasonable cacheline size on FreeBSD and macOS,
which prefer to use this name and both lack _SC_LEVEL1_DCACHE_LINESIZE.
2022-04-29 17:38:01 +04:00
Roman Arutyunyan 86a3380000 QUIC: separate UDP framework for QUIC.
Previously, QUIC used the existing UDP framework, which was created for UDP in
Stream.  However the way QUIC connections are created and looked up is different
from the way UDP connections in Stream are created and looked up.  Now these
two implementations are decoupled.
2022-04-20 16:01:17 +04:00
Roman Arutyunyan c5f5a571d9 QUIC: fixed insertion at the end of buffer.
Previously, last buffer was tracked by keeping a pointer to the previous
chain link "next" field.  When the previous buffer was split and then removed,
the pointer was no longer valid.  Writing at this pointer resulted in broken
data chains.

Now last buffer is tracked by keeping a direct pointer to it.
2022-02-17 22:38:42 +03:00
Sergey Kandaurov 4ce2114724 QUIC: fixed indentation. 2022-02-16 15:45:47 +03:00
Roman Arutyunyan 418ce3b294 QUIC: optimize insertion at the end of QUIC buffer. 2022-02-14 14:54:34 +03:00
Roman Arutyunyan ab1adbbc08 QUIC: eliminated ngx_quic_copy_buf().
Its only call is substituted with QUIC buffer write/read pair.
2022-02-14 14:53:46 +03:00
Roman Arutyunyan 45c5af421b QUIC: trim input chain in ngx_quic_buffer_write().
This allows to eliminate explicit trimming when handling input STREAM frame.
As a result, ngx_quic_trim_chain() is eliminated as well.
2022-02-14 14:51:10 +03:00
Roman Arutyunyan 8363d84edd QUIC: ngx_quic_buffer_t object.
The object is used instead of ngx_chain_t pointer for buffer operations like
ngx_quic_write_chain() and ngx_quic_read_chain().  These functions are renamed
to ngx_quic_write_buffer() and ngx_quic_read_buffer().
2022-02-14 15:27:59 +03:00
Sergey Kandaurov 8c4e29e4f0 SSL: logging level of "application data after close notify".
Such fatal errors are reported by OpenSSL 1.1.1, and similarly by BoringSSL,
if application data is encountered during SSL shutdown, which started to be
observed on the second SSL_shutdown() call after SSL shutdown fixes made in
09fb2135a589 (1.19.2).  The error means that the client continues to send
application data after receiving the "close_notify" alert (ticket #2318).
Previously it was reported as SSL_shutdown() error of SSL_ERROR_SYSCALL.
2022-02-08 17:35:27 +03:00
Roman Arutyunyan 28919d3e59 QUIC: stream lingering.
Now ngx_quic_stream_t is decoupled from ngx_connection_t in a way that it
can persist after connection is closed by application.  During this period,
server is expecting stream final size from client for correct flow control.
Also, buffered output is sent to client as more flow control credit is granted.
2022-02-05 12:54:54 +03:00
Sergey Kandaurov 6e67500606 QUIC: optimized datagram expansion with half-RTT tickets.
As shown in RFC 8446, section 2.2, Figure 3, and further specified in
section 4.6.1, BoringSSL releases session tickets in Application Data
(along with Finished) early, based on a precalculated client Finished
transcript, once client signalled early data in extensions.
2022-02-15 14:12:34 +03:00
Sergey Kandaurov 45e76acd51 Merged with the default branch. 2022-02-14 10:14:07 +03:00
Vladimir Homutov d261bc2b0b QUIC: fixed in-flight bytes accounting.
Initially, frames are genereated and stored in ctx->frames.
Next, ngx_quic_output() collects frames to be sent in in ctx->sending.
On failure, ngx_quic_revert_sned() returns frames into ctx->frames.

On success, the ngx_quic_commit_send() moves ack-eliciting frames into
ctx->sent and frees non-ack-eliciting frames.
This function also updates in-flight bytes counter, so only actually sent
frames are accounted.

The counter is decremented in the following cases:
 - acknowledgment is received
 - packet was declared lost
 - we are discarding context completely

In each of this cases frame is removed from ctx->sent queue and in-flight
counter is accordingly decremented.

The patch fixes the case of discarding context - only removing frames
from ctx->sent must be followed by in-flight bytes counter decrement,
otherwise cg->in_flight could experience type underflow.

The issue appeared in b1676cd64dc9.
2022-02-09 15:51:42 +03:00
Vladimir Homutov 615dbe6b64 QUIC: fixed output context restoring.
The cd8018bc81a5 fixed unintended send of non-padded initial packets,
but failed to restore context properly: only processed contexts need
to be restored.  As a consequence, a packet number could be restored
from uninitialized value.
2022-02-09 15:53:21 +03:00
Roman Arutyunyan 6920deb708 QUIC: fixed resetting stream wev->ready flag.
Previously, the flag could be reset after send_chain() with a limit, even
though there was room for more data.  The application then started waiting for
a write event notification, which never happened.

Now the wev->ready flag is only reset when flow control is exhausted.
2022-02-09 14:49:05 +03:00
Vladimir Homutov e2b85c16d0 QUIC: fixed the "quic_stream_buffer_size" directive.
The default value is now correctly set and the configuration
is properly merged.
2022-02-08 23:00:12 +03:00
Sergey Kandaurov 70dccd6f6d Year 2022. 2022-02-04 13:29:31 +03:00
Maxim Dounin 807b009133 HTTP/2: fixed closed_nodes overflow (ticket #1708).
With large http2_max_concurrent_streams or http2_max_concurrent_pushes, more
than 255 ngx_http_v2_node_t structures might be allocated, eventually leading
to h2c->closed_nodes overflow when closing corresponding streams.  This will
in turn result in additional allocations in ngx_http_v2_get_node_by_id().

While mostly harmless, it can result in excessive memory usage by a HTTP/2
connection, notably in configurations with many keepalive_requests allowed.
Fix is to use ngx_uint_t for h2c->closed_nodes instead of unsigned:8.
2022-02-03 22:46:01 +03:00
Roman Arutyunyan 2ddbea69f1 QUIC: switch stream to DATA_RECVD state.
The switch happens when received byte counter reaches stream final size.
Previously, this state was skipped.  The stream went from SIZE_KNOWN to
DATA_READ when all bytes were read by application.

The change prevents STOP_SENDING frames from being sent when all data is
received from client, but not yet fully read by application.
2022-02-03 18:11:59 +03:00
Roman Arutyunyan 89b9a30c3c QUIC: improved size calculation in ngx_quic_write_chain().
Previously, size was calculated based on the number of input bytes processed
by the function.  Now only the copied bytes are considered.  This prevents
overlapping buffers from contributing twice to the overall written size.
2022-02-03 21:29:05 +03:00
Maxim Dounin 4cdfb1ee3c HTTP/2: made it possible to flush response headers (ticket #1743).
Response headers can be buffered in the SSL buffer.  But stream's fake
connection buffered flag did not reflect this, so any attempts to flush
the buffer without sending additional data were stopped by the write filter.

It does not seem to be possible to reflect this in fc->buffered though, as
we never known if main connection's c->buffered corresponds to the particular
stream or not.  As such, fc->buffered might prevent request finalization
due to sending data on some other stream.

Fix is to implement handling of flush buffers when the c->need_flush_buf
flag is set, similarly to the existing last buffer handling.  The same
flag is now used for UDP sockets in the stream module instead of explicit
checking of c->type.
2022-02-03 01:44:38 +03:00
Sergey Kandaurov 2e7f031ba8 QUIC: do not arm loss detection timer if nothing was sent.
Notably, this became quite practicable after the recent fix in cd8018bc81a5.

Additionally, do not arm loss detection timer on connection termination.
2022-02-02 15:57:08 +03:00
Vladimir Homutov 144c6f6aa7 QUIC: fixed padding of initial packets in case of limited path.
Previously, non-padded initial packet could be sent as a result of the
following situation:

 - initial queue is not empty (so padding to 1200 is required)
 - handshake queue is not empty (so padding is to be added after h/s packet)
 - path is limited

If serializing handshake packet would violate path limit, such packet was
omitted, and the non-padded initial packet was sent.

The fix is to avoid sending the packet at all in such case.  This follows the
original intention introduced in c5155a0cb12f.
2022-02-02 14:16:48 +03:00
Sergey Kandaurov afe8ad39f0 QUIC: do not declare SSL buffering, it's not used.
No functional changes.
2022-02-01 20:46:32 +03:00
Maxim Dounin cfd713832d Cache: fixed race in ngx_http_file_cache_forced_expire().
During configuration reload two cache managers might exist for a short
time.  If both tried to delete the same cache node, the "ignore long locked
inactive cache entry" alert appeared in logs.  Additionally,
ngx_http_file_cache_forced_expire() might be also called by worker
processes, with similar results.

Fix is to ignore cache nodes being deleted, similarly to how it is
done in ngx_http_file_cache_expire() since 3755:76e3a93821b1.  This
was somehow missed in 7002:ab199f0eb8e8, when ignoring long locked
cache entries was introduced in ngx_http_file_cache_forced_expire().
2022-02-01 16:29:28 +03:00
Vladimir Homutov e16352881a QUIC: improved debug logging.
- wording in log->action is adjusted to match function names.

 - connection close steps are made obvious and start with "quic close" prefix:
     *1 quic close initiated rc:-4
     *1 quic close silent drain:0 timedout:1
     *1 quic close resumed rc:-1
     *1 quic close resumed rc:-1
     *1 quic close resumed rc:-4
     *1 quic close completed

   this makes it easy to understand if particular "close" record is an initial
   cause or lasting process, or the final one.

 - cases of close without quic connection now logged as "packet rejected":
     *14 quic run
     *14 quic packet rx long flags:ec version:1
     *14 quic packet rx hs len:61
     *14 quic packet rx dcid len:20 00000000000002c32f60e4aa2b90a64a39dc4228
     *14 quic packet rx scid len:8 81190308612cd019
     *14 quic expected initial, got handshake
     *14 quic packet done rc:-1 level:hs decr:0 pn:0 perr:0
     *14 quic packet rejected rc:-1, cleanup connection
     *14 reusable connection: 0

   this makes it easy to spot early packet rejection and avoid confuse with
   quic connection closing (which in fact was not even created).

 - packet processing summary now uses same prefix "quic packet done rc:"

 - added debug to places where packet was rejected without any reason logged
2022-02-01 15:43:56 +03:00
Vladimir Homutov bda9e27f29 QUIC: got rid of hash symbol in backup and logging.
Now all objectes with sequence number (i.e. sockets, connection ids and
paths) are logged as "foo seq:N".
2022-01-28 14:57:33 +03:00
Vladimir Homutov 4f37d2d295 QUIC: dead code removed.
The ngx_quic_parse_packet() now returns NGX_OK, NGX_ERROR (parsing failed)
and NGX_ABORT (unsupported version).
2022-02-01 13:01:10 +03:00
Vladimir Homutov 2e249af96e QUIC: merged ngx_quic_close_quic() and ngx_quic_close_connection().
The separate ngx_quic_close_quic() doesn't make much sense.
2022-02-01 13:05:38 +03:00
Vladimir Homutov 03fa9875a6 QUIC: revised ngx_quic_handle_datagram() error codes.
The NGX_DECLINED is replaced with NGX_DONE to match closer to return code
of ngx_quic_handle_packet() and ngx_quic_close_connection() rc argument.

The ngx_quic_close_connection() rc code is used only when quic connection
exists, thus anything goes if qc == NULL.

The ngx_quic_handle_datagram() does not return NG_OK in cases when quic
connection is not yet created.
2022-02-01 14:35:31 +03:00
Vladimir Homutov 32e84e9b4a Core: added autotest for UDP segmentation offloading. 2022-01-26 20:40:00 +03:00
Roman Arutyunyan 0b7051b4f3 QUIC: stream event setting function.
The function ngx_quic_set_event() is now called instead of posting events
directly.
2022-01-26 12:01:31 +03:00
Roman Arutyunyan b97e7a75a7 QUIC: style. 2022-01-31 18:09:03 +03:00
Roman Arutyunyan c2e9c35718 HTTP/3: proper uni stream closure detection.
Previously, closure detection for server-initiated uni streams was not properly
implemented.  Instead, HTTP/3 code relied on QUIC code posting the read event
and setting rev->error when it needed to close the stream.  Then, regular
uni stream read handler called c->recv() and received error, which closed the
stream.  This was an ad-hoc solution.  If, for whatever reason, the read
handler was called earlier, c->recv() would return 0, which would also close
the stream.

Now server-initiated uni streams have a separate read event handler for
tracking stream closure.  The handler calls c->recv(), which normally returns
0, but may return error in case of closure.
2022-01-31 09:46:30 +03:00
Roman Arutyunyan 6e7c3ad42c QUIC: introduced explicit stream states.
This allows to eliminate the usage of stream connection event flags for tracking
stream state.
2022-01-31 09:46:02 +03:00
Roman Arutyunyan 6850f6e935 HTTP/3: delayed Insert Count Increment instruction.
Sending the instruction is delayed until the end of the current event cycle.
Delaying the instruction is allowed by quic-qpack-21, section 2.2.2.3.
The goal is to reduce the amount of data sent back to client by accumulating
several inserts in one instruction and sometimes not sending the instruction at
all, if Section Acknowledgement was sent just before it.
2022-01-27 12:20:47 +03:00
Roman Arutyunyan d503544196 QUIC: allowed main QUIC connection for some operations.
Operations like ngx_quic_open_stream(), ngx_http_quic_get_connection(),
ngx_http_v3_finalize_connection(), ngx_http_v3_shutdown_connection() used to
receive a QUIC stream connection.  Now they can receive the main QUIC
connection as well.  This is useful when calling them from a stream context.
2022-01-31 09:16:47 +03:00
Sergey Kandaurov 1d39bb83db QUIC: limited SSL_set_quic_use_legacy_codepoint() API usage.
As advertised in BoringSSL a1d3bfb64fd7ef2cb178b5b515522ffd75d7b8c5,
it may be dropped once callers implementing the draft versions cycle out.
2022-01-27 13:14:01 +03:00
Roman Arutyunyan 1e056aced9 QUIC: style. 2022-01-26 18:03:45 +03:00
Vladimir Homutov b3fd447923 QUIC: fixed handling of initial source connection id.
This was broken in 1e2f4e9c8195.

While there, adjusted formatting of debug message with socket seqnum.
2022-01-26 15:48:12 +03:00
Sergey Kandaurov af0552eb37 README: updated link to nginx-devel mailman. 2022-01-26 14:15:40 +03:00
Sergey Kandaurov 1c65bfc630 README: updated info about incomplete features. 2022-01-26 14:15:40 +03:00
Sergey Kandaurov abcf055579 README: updated to QUICv1.
While here, removed old browsers tips.
2022-01-26 14:15:40 +03:00
Sergey Kandaurov fcf955fdf8 QUIC: set to standard TLS codepoint after draft versions removal.
This is to ease transition with oldish BoringSSL versions,
the default for SSL_set_quic_use_legacy_codepoint() has been
flipped in BoringSSL a1d3bfb64fd7ef2cb178b5b515522ffd75d7b8c5.
2022-01-26 14:15:40 +03:00
Sergey Kandaurov d1b929cc71 QUIC: removed draft versions support. 2022-01-26 14:15:40 +03:00
Sergey Kandaurov 6c4bd8acd6 HTTP/3: removed draft versions support in ALPN. 2022-01-26 14:15:40 +03:00
Vladimir Homutov bb42e87e67 Core: added function for local source address cmsg. 2022-01-25 15:48:58 +03:00
Vladimir Homutov 906d7f354f Core: made the ngx_sendmsg() function non-static.
The NGX_HAVE_ADDRINFO_CMSG macro is defined when at least one of methods
to deal with corresponding control message is available.
2022-01-25 15:48:56 +03:00
Vladimir Homutov 4c658c3465 Core: the ngx_event_udp.h header file. 2022-01-25 15:41:48 +03:00
Vladimir Homutov b1e646b1bf Version bump. 2022-01-27 13:44:09 +03:00
Maxim Dounin f49615da3b release-1.21.6 tag 2022-01-25 18:03:52 +03:00
Maxim Dounin 5ad62114ff nginx-1.21.6-RELEASE 2022-01-25 18:03:51 +03:00
Maxim Dounin 6155ea68a3 SSL: always renewing tickets with TLSv1.3 (ticket #1892).
Chrome only uses TLS session tickets once with TLS 1.3, likely following
RFC 8446 Appendix C.4 recommendation.  With OpenSSL, this works fine with
built-in session tickets, since these are explicitly renewed in case of
TLS 1.3 on each session reuse, but results in only two connections being
reused after an initial handshake when using ssl_session_ticket_key.

Fix is to always renew TLS session tickets in case of TLS 1.3 when using
ssl_session_ticket_key, similarly to how it is done by OpenSSL internally.
2022-01-24 17:18:50 +03:00
Maxim Dounin aea77c50d0 Contrib: vim syntax adjusted to save cpoptions (ticket #2276).
Line continuation as used in the syntax file might be broken if "compatible"
is set or "C" is added to cpoptions.  Fix is to set the "cpoptions" option
to vim default value at script start and restore it later, see
":help use-cpo-save".
2022-01-22 00:28:51 +03:00
Roman Arutyunyan 930ff068d4 QUIC: changed debug message. 2022-01-21 11:20:18 +03:00
Sergey Kandaurov 99d696f0da Merged with the default branch. 2022-01-25 23:42:48 +03:00
Vladimir Homutov d54a5b5884 QUIC: fixed macro style. 2022-01-25 15:48:05 +03:00
Roman Arutyunyan 14a87fa1fa QUIC: fixed chain returned from ngx_quic_write_chain().
Previously, when input ended on a QUIC buffer boundary, input chain was not
advanced to the next buffer.  As a result, ngx_quic_write_chain() returned
a chain with an empty buffer instead of NULL.  This broke HTTP write filter,
preventing it from closing the HTTP request and eventually timing out.

Now input chain is always advanced to a buffer that has data, before checking
QUIC buffer boundary condition.
2022-01-25 09:45:50 +03:00
Vladimir Homutov 4e07aec877 QUIC: removed stale declaration.
The ngx_quic_get_unconnected_socket() was removed in 1e2f4e9c8195.
2022-01-21 11:41:39 +03:00
Vladimir Homutov 31d0317338 QUIC: avoid logging error in case of version negotiation.
Previously, "early error" message was logged in this case.
2022-01-23 21:29:36 +03:00
Vladimir Homutov 9ff3d71a97 QUIC: additional limit for probing packets.
RFC 9000, 9.3.  Responding to Connection Migration:
    An endpoint only changes the address to which it sends packets in
    response to the highest-numbered non-probing packet.

The patch extends this requirement to probing packets.  Although it may
seem excessive, it helps with mitigation of reply attacks (when an off-path
attacker has copied packet with PATH_CHALLENGE and uses different
addresses to exhaust available connection ids).
2022-01-20 22:00:25 +03:00
Pavel Pautov 33b193d870 Core: simplify reader lock release. 2022-01-19 17:37:34 -08:00
Vladimir Homutov 006a271f72 QUIC: reworked migration handling.
The quic connection now holds active, backup and probe paths instead
of sockets.  The number of migration paths is now limited and cannot
be inflated by a bad client or an attacker.

The client id is now associated with path rather than socket. This allows
to simplify processing of output and connection ids handling.

New migration abandons any previously started migrations.  This allows to
free consumed client ids and request new for use in future migrations and
make progress in case when connection id limit is hit during migration.

A path now can be revalidated without losing its state.

The patch also fixes various issues with NAT rebinding case handling:
    - paths are now validated (previously, there was no validation
      and paths were left in limited state)
    - attempt to reuse id on different path is now again verified
      (this was broken in 40445fc7c403)
    - former path is now validated in case of apparent migration
2022-01-19 22:39:24 +03:00
Vladimir Homutov 339eb9ad8b QUIC: the "quic_active_connection_id_limit" directive.
The directive sets corresponding transport parameter and limits number of
created client ids.
2022-01-18 12:49:55 +03:00
Sergey Kandaurov bf0bcce6b4 SSL: free pkey on SSL_CTX_set0_tmp_dh_pkey() failure.
The behaviour was changed in OpenSSL 3.0.1:
https://git.openssl.org/?p=openssl.git;a=commitdiff;h=bf17b7b
2022-01-17 17:05:12 +03:00
Roman Arutyunyan bad85f3f8d QUIC: introduced function ngx_quic_split_chain().
The function splits a buffer at given offset.  The function is now
called from ngx_quic_read_chain() and ngx_quic_write_chain(), which
simplifies both functions.
2022-01-17 14:39:04 +03:00
Roman Arutyunyan bb98e475b6 QUIC: fixed format specifier after 3789f4a56d65. 2022-01-16 00:28:13 +03:00
Roman Arutyunyan 7e2e280495 QUIC: return written size from ngx_quic_write_chain().
This allows to escape calculating it before calling the function.
2022-01-13 11:34:42 +03:00
Sergey Kandaurov f6048da13b README: documented QuicTLS support. 2022-01-13 16:56:07 +03:00
Sergey Kandaurov 5a825889b6 QUIC: removed ngx_send_lowat() check for QUIC connections.
After 9ae239d2547d, ngx_quic_handle_write_event() no longer runs into
ngx_send_lowat() for QUIC connections, so the check became excessive.
It is assumed that external modules operating with SO_SNDLOWAT
(I'm not aware of any) should do this check on their own.
2022-01-13 15:57:21 +03:00
Sergey Kandaurov ee55da0516 HTTP/3: removed useless warning regarding OpenSSL library.
After 0e6528551f26, it became impossible to run into this path.
2022-01-13 15:57:15 +03:00
Roman Arutyunyan 63a5f45fe4 QUIC: fixed handling stream input buffers.
Previously, ngx_quic_write_chain() treated each input buffer as a memory
buffer, which is not always the case.  Special buffers were not skipped, which
is especially important when hitting the input byte limit.

The issue manifested itself with ngx_quic_write_chain() returning a non-empty
chain consisting of a special last_buf buffer when called from QUIC stream
send_chain().  In order for this to happen, input byte limit should be equal to
the chain length, and the input chain should end with an empty last_buf buffer.
An easy way to achieve this is the following:

  location /empty {
      return 200;
  }

When this non-empty chain was returned from send_chain(), it signalled to the
caller that input was blocked, while in fact it wasn't.  This prevented HTTP
request from finalization, which prevented QUIC from sending STREAM FIN to
the client.  The QUIC stream was then reset after a timeout.

Now special buffers are skipped and send_chain() returns NULL in the case
above, which signals to the caller a successful operation.

Also, original byte limit is now passed to ngx_quic_write_chain() from
send_chain() instead of actual chain length to make sure it's never zero.
2022-01-13 11:23:53 +03:00
Roman Arutyunyan 67e147aacc QUIC: fixed handling STREAM FIN.
Previously, when a STREAM FIN frame with no data bytes was received after all
prior stream data were already read by the application layer, the frame was
ignored and eof was not reported to the application.
2022-01-11 18:57:02 +03:00
Roman Arutyunyan f3327857af HTTP/3: set c->error on read error in ngx_http_test_reading().
Similar to other error/eof cases.
2022-01-12 11:57:46 +03:00
Roman Arutyunyan 8b88be5ed0 HTTP/3: simplified code. 2022-01-12 11:57:06 +03:00
Roman Arutyunyan 668f43ca38 QUIC: modified HTTP version test.
The new condition produces smaller diff to the default branch and is similar to
HTTP/2 case.
2022-01-12 11:54:39 +03:00
Maxim Dounin f59d1b6b12 Avoid sending "Connection: keep-alive" when shutting down.
When a worker process is shutting down, keepalive is not used: this is checked
before the ngx_http_set_keepalive() call in ngx_http_finalize_connection().
Yet the "Connection: keep-alive" header was still sent, even if we know that
the worker process is shutting down, potentially resulting in additional
requests being sent to the connection which is going to be closed anyway.
While clients are expected to be able to handle asynchronous close events
(see ticket #1022), it is certainly possible to send the "Connection: close"
header instead, informing the client that the connection is going to be closed
and potentially saving some unneeded work.

With this change, we additionally check for worker process shutdown just
before sending response headers, and disable keepalive accordingly.
2022-01-11 02:23:49 +03:00
Sergey Kandaurov d98314233f HTTP/3: improved processing of multiple Cookie field lines.
As per draft-ietf-quic-http, 4.1.1.2, and similar to HTTP/2 specification,
they ought to be concatenated.  This closely follows ngx_http_v2_module.
2021-12-30 12:59:32 +03:00
Maxim Dounin d29c0a2728 Events: fixed balancing between workers with EPOLLEXCLUSIVE.
Linux with EPOLLEXCLUSIVE usually notifies only the process which was first
to add the listening socket to the epoll instance.  As a result most of the
connections are handled by the first worker process (ticket #2285).  To fix
this, we re-add the socket periodically, so other workers will get a chance
to accept connections.
2021-12-30 01:08:46 +03:00
Maxim Dounin 7d591be08f Version bump. 2021-12-29 22:59:53 +03:00
Roman Arutyunyan 22eb20ae31 Style. 2021-12-29 15:33:51 +03:00
Sergey Kandaurov 217bec97be Merged with the default branch. 2021-12-29 15:17:26 +03:00
Maxim Dounin 74bc340e28 release-1.21.5 tag 2021-12-28 18:28:38 +03:00
Maxim Dounin 7db0cfd3e0 nginx-1.21.5-RELEASE 2021-12-28 18:28:37 +03:00
Maxim Dounin 92fb81046b Updated OpenSSL and PCRE used for win32 builds. 2021-12-28 17:56:16 +03:00
Maxim Dounin ba9d2fd6cb Support for sendfile(SF_NOCACHE).
The SF_NOCACHE flag, introduced in FreeBSD 11 along with the new non-blocking
sendfile() implementation by glebius@, makes it possible to use sendfile()
along with the "directio" directive.
2021-12-27 19:49:26 +03:00
Maxim Dounin 6b569722a3 SSL: SSL_sendfile(SF_NODISKIO) support. 2021-12-27 19:48:42 +03:00
Maxim Dounin 2d022c44e5 Simplified sendfile(SF_NODISKIO) usage.
Starting with FreeBSD 11, there is no need to use AIO operations to preload
data into cache for sendfile(SF_NODISKIO) to work.  Instead, sendfile()
handles non-blocking loading data from disk by itself.  It still can, however,
return EBUSY if a page is already being loaded (for example, by a different
process).  If this happens, we now post an event for the next event loop
iteration, so sendfile() is retried "after a short period", as manpage
recommends.

The limit of the number of EBUSY tolerated without any progress is preserved,
but now it does not result in an alert, since on an idle system event loop
iteration might be very short and EBUSY can happen many times in a row.
Instead, SF_NODISKIO is simply disabled for one call once the limit is
reached.

With this change, sendfile(SF_NODISKIO) is now used automatically as long as
sendfile() is enabled, and no longer requires "aio on;".
2021-12-27 19:48:33 +03:00
Maxim Dounin 68a85b7abf Removed "aio sendfile", deprecated since 1.7.11. 2021-12-27 19:47:05 +03:00
Vladimir Homutov e13ef94157 QUIC: got rid of ngx_quic_create_temp_socket().
It was mostly copy of the ngx_quic_listen().  Now ngx_quic_listen() no
longer generates server id and increments seqnum.  Instead, the server
id is generated when the socket is created.

The ngx_quic_alloc_socket() function is renamed to ngx_quic_create_socket().
2021-12-27 13:49:56 +03:00
Ruslan Ermilov 38b5a6065f Fixed a mismerge in 5c86189a1c1b. 2021-12-28 15:01:02 +03:00
Roman Arutyunyan 7ceefcdb91 QUIC: renamed input handling functions.
Now these functions have names ngx_quic_handle_XXX():

  - ngx_quic_process_stateless_reset() -> ngx_quic_handle_stateless_reset()
  - ngx_quic_input() -> ngx_quic_handle_datagram()
  - ngx_quic_process_packet() -> ngx_quic_handle_packet()
  - ngx_quic_process_payload() -> ngx_quic_handle_payload()
2021-12-27 16:15:28 +03:00
Roman Arutyunyan 95824195ef QUIC: fixed format specifier after 6ccf3867959a. 2021-12-28 13:50:01 +03:00
Vladimir Homutov 04cb5fa243 QUIC: fixed config test with bpf (ticket #2292).
The SO_REUSEPORT socket option is not set during configuration testing,
thus making the further module initialization impossible and meaningless.
2021-12-28 13:24:58 +03:00
Maxim Dounin 358936940d Core: added NGX_REGEX_MULTILINE for 3rd party modules.
Notably, NAXSI is known to misuse ngx_regex_compile() with rc.options set
to PCRE_CASELESS | PCRE_MULTILINE.  With PCRE2 support, and notably binary
compatibility changes, it is no longer possible to set PCRE[2]_MULTILINE
option without using proper interface.  To facilitate correct usage,
this change adds the NGX_REGEX_MULTILINE option.
2021-12-25 01:07:18 +03:00
Maxim Dounin 5d40152946 PCRE2 and PCRE binary compatibility.
With this change, dynamic modules using nginx regex interface can be used
regardless of the variant of the PCRE library nginx was compiled with.

If a module is compiled with different PCRE library variant, in case of
ngx_regex_exec() errors it will report wrong function name in error
messages.  This is believed to be tolerable, given that fixing this will
require interface changes.
2021-12-25 01:07:16 +03:00
Maxim Dounin cf313fe3de PCRE2 library support.
The PCRE2 library is now used by default if found, instead of the
original PCRE library.  If needed for some reason, this can be disabled
with the --without-pcre2 configure option.

To make it possible to specify paths to the library and include files
via --with-cc-opt / --with-ld-opt, the library is first tested without
any additional paths and options.  If this fails, the pcre2-config script
is used.

Similarly to the original PCRE library, it is now possible to build PCRE2
from sources with nginx configure, by using the --with-pcre= option.
It automatically detects if PCRE or PCRE2 sources are provided.

Note that compiling PCRE2 10.33 and later requires inttypes.h.  When
compiling on Windows with MSVC, inttypes.h is only available starting
with MSVC 2013.  In older versions some replacement needs to be provided
("echo '#include <stdint.h>' > pcre2-10.xx/src/inttypes.h" is good enough
for MSVC 2010).

The interface on nginx side remains unchanged.
2021-12-25 01:07:15 +03:00
Maxim Dounin c023111215 Configure: simplified PCRE compilation.
Removed ICC-specific PCRE optimizations which tried to link with PCRE
object files instead of the library.  Made compiler-specific code
minimal.
2021-12-25 01:07:14 +03:00
Maxim Dounin 8ee6d17622 Core: ngx_regex.c style cleanup.
Notably, ngx_pcre_pool and ngx_pcre_studies are renamed to ngx_regex_pool
and ngx_regex_studies, respectively.
2021-12-25 01:07:12 +03:00
Maxim Dounin 1af9939c8d Core: fixed ngx_pcre_studies cleanup.
If a configuration parsing fails for some reason, ngx_regex_module_init()
is not called, and ngx_pcre_studies remained set despite the fact that
the pool it was allocated from is already freed.  This might result in
a segmentation fault during runtime regular expression compilation, such
as in SSI, for example, in the single process mode, or if a worker process
died and was respawned from a master process in such an inconsistent state.

Fix is to clear ngx_pcre_studies from the pool cleanup handler (which is
anyway used to free JIT-compiled patterns).
2021-12-25 01:07:10 +03:00
Roman Arutyunyan 4a60b40678 QUIC: refactored buffer allocation, spliting and freeing.
Previously, buffer lists was used to track used buffers.  Now reference
counter is used instead.  The new implementation is simpler and faster with
many buffer clones.
2021-12-24 18:39:22 +03:00
Ruslan Ermilov 9cfe1fb704 Moved Huffman coding out of HTTP/2.
ngx_http_v2_huff_decode.c and ngx_http_v2_huff_encode.c are renamed
to ngx_http_huff_decode.c and ngx_http_huff_encode.c.
2021-12-21 07:54:16 +03:00
Gena Makhomed 281431875f Contrib: vim syntax, update core and 3rd party module directives. 2021-12-20 20:02:48 +02:00
Roman Arutyunyan 83d57cbffa QUIC: removed ngx_quic_copy_chain().
The function is unused.
2021-12-16 17:07:11 +03:00
Roman Arutyunyan fa3c56e16a QUIC: renamed buffer-related functions.
ngx_quic_alloc_buf() -> ngx_quic_alloc_chain(),
ngx_quic_free_bufs() -> ngx_quic_free_chain(),
ngx_quic_trim_bufs() -> ngx_quic_trim_chain()
2021-12-16 17:06:35 +03:00
Roman Arutyunyan 6ad7e2eb04 QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
They are replaced with ngx_quic_write_chain() and ngx_quic_read_chain().
These functions represent the API to data buffering.

The first function adds data of given size at given offset to the buffer.
Now it returns the unwritten part of the chain similar to c->send_chain().

The second function returns data of given size from the beginning of the buffer.
Its second argument and return value are swapped compared to
ngx_quic_split_bufs() to better match ngx_quic_write_chain().

Added, returned and stored data are regular ngx_chain_t/ngx_buf_t chains.
Missing data is marked with b->sync flag.

The functions are now used in both send and recv data chains in QUIC streams.
2021-12-24 18:17:23 +03:00
Roman Arutyunyan 8ba0591205 QUIC: avoid excessive buffer allocations in stream output.
Previously, when a few bytes were send to a QUIC stream by the application, a
4K buffer was allocated for these bytes.  Then a STREAM frame was created and
that entire buffer was used as data for that frame.  The frame with the buffer
were in use up until the frame was acked by client.  Meanwhile, when more
bytes were send to the stream, more buffers were allocated and assigned as
data to newer STREAM frames.  In this scenario most buffer memory is unused.

Now the unused part of the stream output buffer is available for further
stream output while earlier parts of the buffer are waiting to be acked.
This is achieved by splitting the output buffer.
2021-12-24 18:13:51 +03:00
Vladimir Homutov c09c4c058b QUIC: got rid of excessive "qsock" argument in ngx_quic_output.c.
The output is always sent to the active path, which is stored in the
quic connection.  There is no need to pass it in arguments.

When output has to be send to to a specific path (in rare cases, such as
path probing), a separate method exists (ngx_quic_frame_sendto()).
2021-12-27 13:52:57 +03:00
Vladimir Homutov 15a3e8cd6e QUIC: refactored ngx_quic_validate_path().
The function now accepts path argument, as suggested by the name. Socket is
not really needed inside.
2021-12-16 11:49:08 +03:00
Vladimir Homutov 09e77a9751 QUIC: added missing check for backup path existence. 2021-12-16 11:42:28 +03:00
Ruslan Ermilov da7d48ca9f Merged with the default branch. 2021-12-24 15:53:59 +03:00
Roman Arutyunyan e6b7f80fb5 QUIC: added path limiting function ngx_quic_path_limit(). 2021-12-14 16:24:20 +03:00
Vladimir Homutov 6f57aada90 QUIC: decoupled path state and limitation status.
The path validation status and anti-amplification limit status is actually
two different variables.  It is possible that validating path should not
be limited (for example, when re-validating former path).
2021-12-13 09:48:33 +03:00
Vladimir Homutov 36f796fd76 QUIC: improved path validation.
Previously, path was considered valid during arbitrary selected 10m timeout
since validation.  This is quite not what RFC 9000 says; the relevant
part is:

    An endpoint MAY skip validation of a peer address if that
    address has been seen recently.

The patch considers a path to be 'recently seen' if packets were received
during idle timeout.  If a packet is received from the path that was seen
not so recently, such path is considered new, and anti-amplification
restrictions apply.
2021-12-13 17:27:29 +03:00
Roman Arutyunyan fb6c936dad QUIC: write and full stream shutdown support.
Full stream shutdown is now called from stream cleanup handler instead of
explicitly sending frames.
2021-12-13 14:49:42 +03:00
Roman Arutyunyan dca7a44179 QUIC: simplified stream initialization.
After creation, a client stream is added to qc->streams.uninitialized queue.
After initialization it's removed from the queue.  If a stream is never
initialized, it is freed in ngx_quic_close_streams().  Stream initializer
is now set as read event handler in stream connection.

Previously qc->streams.uninitialized was used only for delayed stream
initialization.

The change makes it possible not to handle separately the case of a new stream
in stream-related frame handlers.  It makes these handlers simpler since new
streams and existing streams are now handled by the same code.
2021-12-10 19:43:50 +03:00
Maxim Dounin c7aee5eac3 HTTP/2: fixed sendfile() aio handling.
With sendfile() in threads ("aio threads; sendfile on;"), client connection
can block on writing, waiting for sendfile() to complete.  In HTTP/2 this
might result in the request hang, since an attempt to continue processing
in thread event handler will call request's write event handler, which
is usually stopped by ngx_http_v2_send_chain(): it does nothing if there
are no additional data and stream->queued is set.  Further, HTTP/2 resets
stream's c->write->ready to 0 if writing blocks, so just fixing
ngx_http_v2_send_chain() is not enough.

Can be reproduced with test suite on Linux with:

TEST_NGINX_GLOBALS_HTTP="aio threads; sendfile on;" prove h2*.t

The following tests currently fail: h2_keepalive.t, h2_priority.t,
h2_proxy_max_temp_file_size.t, h2.t, h2_trailers.t.

Similarly, sendfile() with AIO preloading on FreeBSD can block as well,
with similar results.  This is, however, harder to reproduce, especially
on modern FreeBSD systems, since sendfile() usually does not return EBUSY.

Fix is to modify ngx_http_v2_send_chain() so it actually tries to send
data to the main connection when called, and to make sure that
c->write->ready is set by the relevant event handlers.
2021-11-25 22:02:10 +03:00
Maxim Dounin cb3ca0ba5d HTTP/2: fixed "task already active" with sendfile in threads.
With sendfile in threads, "task already active" alerts might appear in logs
if a write event happens on the main HTTP/2 connection, triggering a sendfile
in threads while another thread operation is already running.  Observed
with "aio threads; aio_write on; sendfile on;" and with thread event handlers
modified to post a write event to the main HTTP/2 connection (though can
happen without any modifications).

Similarly, sendfile() with AIO preloading on FreeBSD can trigger duplicate
aio operation, resulting in "second aio post" alerts.  This is, however,
harder to reproduce, especially on modern FreeBSD systems, since sendfile()
usually does not return EBUSY.

Fix is to avoid starting a sendfile operation if other thread operation
is active by checking r->aio in the thread handler (and, similarly, in
aio preload handler).  The added check also makes duplicate calls protection
redundant, so it is removed.
2021-11-25 22:02:05 +03:00
Roman Arutyunyan 2e04ad69ca QUIC: post stream events instead of calling their handlers.
This potentially reduces the number of handler calls.
2021-11-23 21:39:51 +03:00
Ruslan Ermilov 926e3d1fa2 QUIC: removed configure time test for BPF sockhash.
The test verifies kernel version on a build machine,
but actually used kernel may be different.
2021-12-09 15:30:50 +03:00
Ruslan Ermilov 8802f709d7 QUIC: configure cleanup.
Renamed and removed some macros.
2021-12-09 15:30:01 +03:00
Vladimir Homutov 6c742f75bc QUIC: added missing frame initialization.
Currently, all used fields are initialized, but usage may change in future.
2021-12-06 11:04:55 +03:00
Vladimir Homutov 5d7fa710ca QUIC: refactored ngx_quic_frame_sendto() function.
The function now takes path as an argument to deal with associated
restrictions and update sent counter.
2021-12-09 12:40:14 +03:00
Sergey Kandaurov 5917a86f5b QUIC: fixed e06283038ec8 mis-merge.
The NGX_HTTP_QUIC macro was removed in 33226ac61076.
2021-12-09 11:15:25 +03:00
Sergey Kandaurov 83a7622d32 HTTP/3: cleanup after "listen .. quic" removal in be08b858086a. 2021-12-08 17:04:56 +03:00
Vladimir Homutov 7519cf88b7 QUIC: updated README.
The ngx_http_quic_module is merged to ngx_http_v3_module.
The $quic variable no longer exists, it is replaced with $http3 variable.
2021-12-07 16:07:47 +03:00
Sergey Kandaurov d0b788c0bd QUIC: clear SSL_OP_ENABLE_MIDDLEBOX_COMPAT on SSL context switch.
The SSL_OP_ENABLE_MIDDLEBOX_COMPAT option is provided by QuicTLS and enabled
by default in the newly created SSL contexts.  SSL_set_quic_method() is used
to clear it, which is required for SSL handshake to work on QUIC connections.
Switching context in the ngx_http_ssl_servername() SNI callback overrides SSL
options from the new SSL context.  This results in the option set again.
Fix is to explicitly clear it when switching to another SSL context.

Initially reported here (in Russian):
http://mailman.nginx.org/pipermail/nginx-ru/2021-November/063989.html
2021-12-07 15:49:51 +03:00
Sergey Kandaurov 41b87485eb HTTP/3: avoid sending stream cancellation for pushed streams. 2021-12-07 15:49:30 +03:00
Sergey Kandaurov 8a0a6a85f4 QUIC: converted ngx_quic_keys_set_encryption_secret() to NGX codes.
While here, removed check for encryption level zero, redundant by its nature.
2021-12-07 15:42:10 +03:00
Roman Arutyunyan bd8e49cbc6 HTTP/3: renamed files.
ngx_http_v3_tables.h and ngx_http_v3_tables.c are renamed to
ngx_http_v3_table.h and ngx_http_v3_table.c to better match HTTP/2 code.

ngx_http_v3_streams.h and ngx_http_v3_streams.c are renamed to
ngx_http_v3_uni.h and ngx_http_v3_uni.c to better match their content.
2021-12-07 13:01:28 +03:00
Vladimir Homutov c1d88961cb QUIC: simplified configuration.
Directives that set transport parameters are removed from the configuration.
Corresponding values are derived from the quic configuration or initialized
to default.  Whenever possible, quic configuration parameters are taken from
higher-level protocol settings, i.e. HTTP/3.
2021-12-06 15:19:54 +03:00
Roman Arutyunyan 52b891d39c HTTP/3: $http3 variable.
A new variable $http3 is added.  The variable equals to "h3" for HTTP/3
connections, "hq" for hq connections and is an empty string otherwise.

The variable $quic is eliminated.

The new variable is similar to $http2 variable.
2021-12-01 11:02:17 +03:00
Roman Arutyunyan 88d2f21fc9 HTTP/3: http3_hq directive and NGX_HTTP_V3_HQ macro.
Listen quic parameter is no longer supported.
2021-12-04 10:52:55 +03:00
Roman Arutyunyan 6dc747f5ff HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module. 2021-12-06 13:02:36 +03:00
Vladimir Homutov 56feb8f3ca QUIC: fixed using of retired connection id (ticket #2289).
RFC 9000 19.16
 The sequence number specified in a RETIRE_CONNECTION_ID frame MUST NOT
 refer to the Destination Connection ID field of the packet in which the
 frame is contained.

Before the patch, the RETIRE_CONNECTION_ID frame was sent before switching
to the new client id.  If retired client id was currently in use, this lead
to violation of the spec.
2021-12-02 14:09:52 +03:00
Sergey Kandaurov bde585656a QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES. 2021-12-02 13:59:56 +03:00
Sergey Kandaurov 1cf5df0781 HTTP/3: adjusted ALPN macro names to align with 61abb35bb8cf. 2021-12-02 13:59:09 +03:00
Vladimir Homutov 9b92d9600f QUIC: removed excessive check.
The c->udp->dgram may be NULL only if the quic connection was just
created: the ngx_event_udp_recvmsg() passes information about datagrams
to existing connections by providing information in c->udp.

If case of a new connection, c->udp is allocated by the QUIC code during
creation of quic connection (it uses c->sockaddr to initialize qsock->path).

Thus the check for qsock->path is excessive and can be read wrong, assuming
that other options possible, leading to warnings from clang static analyzer.
2021-12-01 18:33:29 +03:00
Sergey Kandaurov 0d8ddc57e8 QUIC: ngx_quic_send_alert() callback moved to its place. 2021-11-30 14:30:59 +03:00
Sergey Kandaurov a9546f2161 QUIC: simplified ngx_quic_send_alert() callback.
Removed sending CLOSE_CONNECTION directly to avoid duplicate frames,
since it is sent later again in SSL_do_handshake() error handling.
As such, removed redundant settings of error fields set elsewhere.
While here, improved debug message.
2021-11-30 14:30:59 +03:00
Vladimir Homutov 5ddebcaaff QUIC: removed unnecessary closing of active/backup sockets.
All open sockets are stored in a queue.  There is no need to close some
of them separately.  If it happens that active and backup point to same
socket, double close may happen (leading to possible segfault).
2021-11-18 14:33:21 +03:00
Vladimir Homutov 70907fdbe0 QUIC: fixed migration during NAT rebinding.
The RFC 9000 allows a packet from known CID arrive from unknown path:

    These requirements regarding connection ID reuse apply only to the
    sending of packets, as unintentional changes in path without a change
    in connection ID are possible.  For example, after a period of
    network inactivity, NAT rebinding might cause packets to be sent on a
    new path when the client resumes sending.

Before the patch, such packets were rejected with an error in the
ngx_quic_check_migration() function.  Removing the check makes the
separate function excessive - remaining checks are early migration
check and "disable_active_migration" check.  The latter is a transport
parameter sent to client and it should not be used by server.

The server should send "disable_active_migration" "if the endpoint does
not support active connection migration" (18.2). The support status depends
on nginx configuration: to have migration working with multiple workers,
you need bpf helper, available on recent Linux systems.  The patch does
not set "disable_active_migration" automatically and leaves it for the
administrator. By default, active migration is enabled.

RFC 900 says that it is ok to migrate if the peer violates
"disable_active_migration" flag requirements:

   If the peer violates this requirement,

   the endpoint MUST either drop the incoming packets on that path without
   generating a Stateless Reset

   OR

   proceed with path validation and allow the peer to migrate.  Generating a
   Stateless Reset or closing the connection would allow third parties in the
   network to cause connections to close by spoofing or otherwise manipulating
   observed traffic.

So, nginx adheres to the second option and proceeds to path validation.


Note:

The ngtcp2 may be used for testing both active migration and NAT rebinding:

ngtcp2/client --change-local-addr=200ms --delay-stream=500ms <ip> <port> <url>

ngtcp2/client --change-local-addr=200ms --delay-stream=500ms --nat-rebinding \
              <ip> <port> <url>
2021-11-29 11:51:14 +03:00
Vladimir Homutov 1c29db5dba QUIC: refactored multiple QUIC packets handling.
Single UDP datagram may contain multiple QUIC datagrams.  In order to
facilitate handling of such cases, 'first' flag in the ngx_quic_header_t
structure is introduced.
2021-11-29 11:49:09 +03:00
Vladimir Homutov 2730e38d8b QUIC: fixed handling of RETIRE_CONNECTION_ID frame.
Previously, the retired socket was not closed if it didn't match
active or backup.

New sockets could not be created (due to count limit), since retired socket
was not closed before calling ngx_quic_create_sockets().

When replacing retired socket, new socket is only requested after closing
old one, to avoid hitting the limit on the number of active connection ids.

Together with added restrictions, this fixes an issue when a current socket
could be closed during migration, recreated and erroneously reused leading
to null pointer dereference.
2021-11-18 14:19:36 +03:00
Vladimir Homutov 64488e4e6f QUIC: additional checks for the RETIRE_CONNECTION_ID frame. 2021-11-18 14:19:31 +03:00
Roman Arutyunyan 52021bf4a0 QUIC: handle DATA_BLOCKED frame from client.
Previously the frame was not handled and connection was closed with an error.
Now, after receiving this frame, global flow control is updated and new
flow control credit is sent to client.
2021-11-17 23:07:51 +03:00
Roman Arutyunyan 75c17858cc QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Previously, after receiving STREAM_DATA_BLOCKED, current flow control limit
was sent to client.  Now, if the limit can be updated to the full window size,
it is updated and the new value is sent to client, otherwise nothing is sent.

The change lets client update flow control credit on demand.  Also, it saves
traffic by not sending MAX_STREAM_DATA with the same value twice.
2021-11-17 23:07:38 +03:00
Roman Arutyunyan 7bd866a9a5 HTTP/3: fixed compilation with QUIC, but without HTTP/3. 2021-11-17 18:49:48 +03:00
Roman Arutyunyan 07a983f8df QUIC: reject streams which we could not create.
The reasons why a stream may not be created by server currently include hitting
worker_connections limit and memory allocation error.  Previously in these
cases the entire QUIC connection was closed and all its streams were shut down.
Now the new stream is rejected and existing streams continue working.

To reject an HTTP/3 request stream, RESET_STREAM and STOP_SENDING with
H3_REQUEST_REJECTED error code are sent to client.  HTTP/3 uni streams and
Stream streams are not rejected.
2021-11-11 19:07:00 +03:00
Sergey Kandaurov 8d62635537 QUIC: stop processing new client streams at the closing state. 2021-11-12 16:29:07 +03:00
Sergey Kandaurov b14bef9520 SSL: $ssl_curve (ticket #2135).
The variable contains a negotiated curve used for the handshake key
exchange process.  Known curves are listed by their names, unknown
ones are shown in hex.

Note that for resumed sessions in TLSv1.2 and older protocols,
$ssl_curve contains the curve used during the initial handshake,
while in TLSv1.3 it contains the curve used during the session
resumption (see the SSL_get_negotiated_group manual page for
details).

The variable is only meaningful when using OpenSSL 3.0 and above.
With older versions the variable is empty.
2021-11-01 18:09:34 +03:00
Sergey Kandaurov 3771c70da7 Version bump. 2021-11-23 12:52:43 +03:00
Maxim Dounin a1459645ce release-1.21.4 tag 2021-11-02 17:49:22 +03:00
Maxim Dounin 65d47e2d65 nginx-1.21.4-RELEASE 2021-11-02 17:49:22 +03:00
Maxim Dounin d828e18761 Changed ngx_chain_update_chains() to test tag first (ticket #2248).
Without this change, aio used with HTTP/2 can result in connection hang,
as observed with "aio threads; aio_write on;" and proxying (ticket #2248).

The problem is that HTTP/2 updates buffers outside of the output filters
(notably, marks them as sent), and then posts a write event to call
output filters.  If a filter does not call the next one for some reason
(for example, because of an AIO operation in progress), this might
result in a state when the owner of a buffer already called
ngx_chain_update_chains() and can reuse the buffer, while the same buffer
is still sitting in the busy chain of some other filter.

In the particular case a buffer was sitting in output chain's ctx->busy,
and was reused by event pipe.  Output chain's ctx->busy was permanently
blocked by it, and this resulted in connection hang.

Fix is to change ngx_chain_update_chains() to skip buffers from other
modules unconditionally, without trying to wait for these buffers to
become empty.
2021-10-30 02:39:19 +03:00
Maxim Dounin a1593eb4d6 Changed default value of sendfile_max_chunk to 2m.
The "sendfile_max_chunk" directive is important to prevent worker
monopolization by fast connections.  The 2m value implies maximum 200ms
delay with 100 Mbps links, 20ms delay with 1 Gbps links, and 2ms on
10 Gbps links.  It also seems to be a good value for disks.
2021-10-29 20:21:57 +03:00
Maxim Dounin 79ea33d679 Upstream: sendfile_max_chunk support.
Previously, connections to upstream servers used sendfile() if it was
enabled, but never honored sendfile_max_chunk.  This might result
in worker monopolization for a long time if large request bodies
are allowed.
2021-10-29 20:21:54 +03:00
Maxim Dounin f9fcb63842 Fixed sendfile() limit handling on Linux.
On Linux starting with 2.6.16, sendfile() silently limits all operations
to MAX_RW_COUNT, defined as (INT_MAX & PAGE_MASK).  This incorrectly
triggered the interrupt check, and resulted in 0-sized writev() on the
next loop iteration.

Fix is to make sure the limit is always checked, so we will return from
the loop if the limit is already reached even if number of bytes sent is
not exactly equal to the number of bytes we've tried to send.
2021-10-29 20:21:51 +03:00
Maxim Dounin 7ce5186ee0 Simplified sendfile_max_chunk handling.
Previously, it was checked that sendfile_max_chunk was enabled and
almost whole sendfile_max_chunk was sent (see e67ef50c3176), to avoid
delaying connections where sendfile_max_chunk wasn't reached (for example,
when sending responses smaller than sendfile_max_chunk).  Now we instead
check if there are unsent data, and the connection is still ready for writing.
Additionally we also check c->write->delayed to ignore connections already
delayed by limit_rate.

This approach is believed to be more robust, and correctly handles
not only sendfile_max_chunk, but also internal limits of c->send_chain(),
such as sendfile() maximum supported length (ticket #1870).
2021-10-29 20:21:48 +03:00
Maxim Dounin 417cfe8951 Switched to using posted next events after sendfile_max_chunk.
Previously, 1 millisecond delay was used instead.  In certain edge cases
this might result in noticeable performance degradation though, notably on
Linux with typical CONFIG_HZ=250 (so 1ms delay becomes 4ms),
sendfile_max_chunk 2m, and link speed above 2.5 Gbps.

Using posted next events removes the artificial delay and makes processing
fast in all cases.
2021-10-29 20:21:43 +03:00
Roman Arutyunyan 2e7c8460a8 Mp4: mp4_start_key_frame directive.
The directive enables including all frames from start time to the most recent
key frame in the result.  Those frames are removed from presentation timeline
using mp4 edit lists.

Edit lists are currently supported by popular players and browsers such as
Chrome, Safari, QuickTime and ffmpeg.  Among those not supporting them properly
is Firefox[1].

Based on a patch by Tracey Jaquith, Internet Archive.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1735300
2021-10-28 14:14:25 +03:00
Roman Arutyunyan 65dd05879e Mp4: added ngx_http_mp4_update_mdhd_atom() function.
The function updates the duration field of mdhd atom.  Previously it was
updated in ngx_http_mp4_read_mdhd_atom().  The change makes it possible to
alter track duration as a result of processing track frames.
2021-10-28 13:11:31 +03:00
Roman Arutyunyan 56bbbf72d0 HTTP/3: send Stream Cancellation instruction.
As per quic-qpack-21:

   When a stream is reset or reading is abandoned, the decoder emits a
   Stream Cancellation instruction.

Previously the instruction was not sent.  Now it's sent when closing QUIC
stream connection if dynamic table capacity is non-zero and eof was not
received from client.  The latter condition means that a trailers section
may still be on its way from client and the stream needs to be cancelled.
2021-10-18 14:48:11 +03:00
Roman Arutyunyan f72a2bb3f6 HTTP/3: allowed QUIC stream connection reuse.
A QUIC stream connection is treated as reusable until first bytes of request
arrive, which is also when the request object is now allocated.  A connection
closed as a result of draining, is reset with the error code
H3_REQUEST_REJECTED.  Such behavior is allowed by quic-http-34:

   Once a request stream has been opened, the request MAY be cancelled
   by either endpoint. Clients cancel requests if the response is no
   longer of interest; servers cancel requests if they are unable to or
   choose not to respond.

   When the server cancels a request without performing any application
   processing, the request is considered "rejected."  The server SHOULD
   abort its response stream with the error code H3_REQUEST_REJECTED.

   The client can treat requests rejected by the server as though they had
   never been sent at all, thereby allowing them to be retried later.
2021-10-18 15:47:06 +03:00
Roman Arutyunyan 261439aed2 HTTP/3: adjusted QUIC connection finalization.
When an HTTP/3 function returns an error in context of a QUIC stream, it's
this function's responsibility now to finalize the entire QUIC connection
with the right code, if required.  Previously, QUIC connection finalization
could be done both outside and inside such functions.  The new rule follows
a similar rule for logging, leads to cleaner code, and allows to provide more
details about the error.

While here, a few error cases are no longer treated as fatal and QUIC connection
is no longer finalized in these cases.  A few other cases now lead to
stream reset instead of connection finalization.
2021-10-18 15:22:33 +03:00
Vladimir Homutov a6eadf8dc0 QUIC: fixed PATH_RESPONSE frame expansion.
The PATH_RESPONSE frame must be expanded to 1200, except the case
when anti-amplification limit is in effect, i.e. on unvalidated paths.

Previously, the anti-amplification limit was always applied.
2021-11-11 15:15:07 +03:00
Vladimir Homutov f5c17cf3b7 QUIC: removed ngx_quic_error_text() declaration.
This is a leftover from cab3b7a070ef.
2021-11-10 14:36:36 +03:00
Vladimir Homutov d7aaf8eb18 QUIC: fixed GSO packets count.
Thanks to Andrey Kolyshkin <a.kolyshkin@corp.vk.com>
2021-11-09 21:17:05 +03:00
Vladimir Homutov ce10c373e8 QUIC: removed dead code.
The function is no longer used since b3d9e57d0f62.
2021-11-10 13:49:01 +03:00
Vladimir Homutov 9a035adb05 QUIC: converted client_tp_done to bitfield. 2021-11-08 15:41:12 +03:00
Vladimir Homutov f765b64594 QUIC: fixed removal of unused client IDs.
If client ID was never used, its refcount is zero.  To keep things simple,
the ngx_quic_unref_client_id() function is now aware of such IDs.

If client ID was used, the ngx_quic_replace_retired_client_id() function
is supposed to find all users and unref the ID, thus ngx_quic_unref_client_id()
should not be called after it.
2021-10-13 14:48:33 +03:00
Vladimir Homutov e945e92ece QUIC: connections with wrong ALPN protocols are now rejected.
Previously, it was not enforced in the stream module.
Now, since b9e02e9b2f1d it is possible to specify protocols.

Since ALPN is always required, the 'require_alpn' setting is now obsolete.
2021-11-03 13:36:21 +03:00
Vladimir Homutov 6c1a6d7bb3 QUIC: refactored packet creation.
The "min" and "max" arguments refer to UDP datagram size.  Generating payload
requires to account properly for header size, which is variable and depends on
payload size and packet number.
2021-10-07 13:48:29 +03:00
Vladimir Homutov 273b23d5a7 QUIC: removed unused argument in ngx_quic_create_short_header(). 2021-10-07 12:24:47 +03:00
Vladimir Homutov c13ab56118 QUIC: added function to initialize packet. 2021-09-30 12:02:29 +03:00
Vladimir Homutov 2e001d8708 QUIC: fixed processing of minimum packet size.
If packet needs to be expanded (for example Initial to 1200 bytes),
but path limit is less, such packet should not be created/sent.
2021-10-22 12:59:44 +03:00
Vladimir Homutov 9ff755cd7c QUIC: added shutdown support in stream proxy. 2021-09-23 16:25:49 +03:00
Sergey Kandaurov 965f51cde3 Merged with the default branch. 2021-11-03 11:22:07 +03:00
Sergey Kandaurov 69805192b4 QUIC: style. 2021-10-26 18:05:57 +03:00
Sergey Kandaurov 369804cacb QUIC: speeding up processing 0-RTT.
After fe919fd63b0b, processing QUIC streams was postponed until after handshake
completion, which means that 0-RTT is effectively off.  With ssl_ocsp enabled,
it could be further delayed.  This differs from how OCSP validation works with
SSL_read_early_data().  With this change, processing QUIC streams is unlocked
when obtaining 0-RTT secret.
2021-10-26 17:43:10 +03:00
Sergey Kandaurov 63aa8908c5 QUIC: refactored OCSP validation in preparation for 0-RTT support. 2021-10-26 17:43:10 +03:00
Vladimir Homutov d5e61b4c8c QUIC: switched to integer arithmetic in rtt calculations.
RFC 9002 uses constants implying effective implementation,
i.e. using bit shift operations instead of floating point.
2021-10-19 14:32:50 +03:00
Vladimir Homutov a07e6d352e QUIC: optimized ack range processing.
The sent queue is sorted by packet number.  It is possible to avoid
traversing full queue while handling ack ranges.  It makes sense to
start traversing from the queue head (i.e. check oldest packets first).
2021-10-15 12:26:42 +03:00
Roman Arutyunyan b35afd4e4a QUIC: limited the total number of frames.
Exceeding 10000 allocated frames is considered a flood.
2021-10-13 14:46:51 +03:00
Roman Arutyunyan 49b5584de3 QUIC: traffic-based flood detection.
With this patch, all traffic over a QUIC connection is compared to traffic
over QUIC streams.  As long as total traffic is many times larger than stream
traffic, we consider this to be a flood.
2021-10-13 14:41:46 +03:00
Roman Arutyunyan 6fe2069e12 HTTP/3: traffic-based flood detection.
With this patch, all traffic over HTTP/3 bidi and uni streams is counted in
the h3c->total_bytes field, and payload traffic is counted in the
h3c->payload_bytes field.  As long as total traffic is many times larger than
payload traffic, we consider this to be a flood.

Request header traffic is counted as if all fields are literal.  Response
header traffic is counted as is.
2021-10-07 13:22:42 +03:00
Roman Arutyunyan 334d204baf HTTP/3: fixed request length calculation.
Previously, when request was blocked, r->request_length was not updated.
2021-10-06 14:51:16 +03:00
Roman Arutyunyan 513f850061 HTTP/3: removed client-side encoder support.
Dynamic tables are not used when generating responses anyway.
2021-10-06 14:48:59 +03:00
Martin Duke d3f0dd0321 QUIC: attempt decrypt before checking for stateless reset.
Checking the reset after encryption avoids false positives.  More importantly,
it avoids the check entirely in the usual case where decryption succeeds.

RFC 9000, 10.3.1  Detecting a Stateless Reset

    Endpoints MAY skip this check if any packet from a datagram is
    successfully processed.
2021-10-12 11:57:50 +03:00
Martin Duke 1f523e0d47 QUIC: Check if CID has been used in stateless reset check
Section 10.3.1 of RFC9000 requires this check.
2021-10-12 11:56:49 +03:00
Roman Arutyunyan c5069b7f27 QUIC: send RESET_STREAM in response to STOP_SENDING.
As per RFC 9000:

   An endpoint that receives a STOP_SENDING frame MUST send a RESET_STREAM
   frame if the stream is in the "Ready" or "Send" state.

   An endpoint SHOULD copy the error code from the STOP_SENDING frame to
   the RESET_STREAM frame it sends, but it can use any application error code.
2021-09-21 16:24:33 +03:00
Roman Arutyunyan 59ba20b65e QUIC: reset stream only once. 2021-09-22 14:02:56 +03:00
Roman Arutyunyan a27409d50c HTTP/3: reset streams with incomplete responses or timeouts.
This prevents client from closing the QUIC connection due to response parse
error.
2021-09-27 17:08:48 +03:00
Roman Arutyunyan 599d02f027 Added r->response_sent flag.
The flag indicates that the entire response was sent to the socket up to the
last_buf flag.  The flag is only usable for protocol implementations that call
ngx_http_write_filter() from header filter, such as HTTP/1.x and HTTP/3.
2021-09-30 17:14:42 +03:00
Sergey Kandaurov 494d3fddb2 Stream: fixed segfault when using SSL certificates with variables.
Similar to the previous change, a segmentation fault occurres when evaluating
SSL certificates on a QUIC connection due to an uninitialized stream session.
The fix is to adjust initializing the QUIC part of a connection until after
it has session and variables initialized.

Similarly, this appends logging error context for QUIC connections:
- client 127.0.0.1:54749 connected to 127.0.0.1:8880 while handling frames
- quic client timed out (60: Operation timed out) while handling quic input
2021-09-29 15:06:28 +03:00
Sergey Kandaurov 63d2ab4a0d HTTP/3: fixed segfault when using SSL certificates with variables.
A QUIC connection doesn't have c->log->data and friends initialized to sensible
values.  Yet, a request can be created in the certificate callback with such an
assumption, which leads to a segmentation fault due to null pointer dereference
in ngx_http_free_request().  The fix is to adjust initializing the QUIC part of
a connection such that it has all of that in place.

Further, this appends logging error context for unsuccessful QUIC handshakes:
- cannot load certificate .. while handling frames
- SSL_do_handshake() failed .. while sending frames
2021-09-29 15:01:59 +03:00
Sergey Kandaurov e48d428d75 Stream: detect "listen .. quic" without TLSv1.3. 2021-09-29 15:01:56 +03:00
Sergey Kandaurov f210fb7953 Fixed mismerge of ssl_reject_handshake in 71b7453fb11f.
In particular, this fixes rejecting "listen .. quic|http3" configurations
without TLSv1.3 configured.
2021-09-29 15:01:53 +03:00
Sergey Kandaurov 517e44fe5b HTTP/3: fixed server push after ea9b645472b5.
Unlike in HTTP/2, both "host" and ":authority" reside in r->headers_in.server.
2021-09-27 17:42:53 +03:00
Sergey Kandaurov 7b5283b003 QUIC: moved a variable initialization near to its use.
This tends to produce slightly more optimal code with pos == NULL
when built with Clang on low optimization levels.

Spotted by Ruslan Ermilov.
2021-09-27 15:38:55 +03:00
Ruslan Ermilov 6e1487496d Configure: fixed QUIC support test.
OpenSSL library QUIC support cannot be tested at configure time when
using the --with-openssl option so assume it's present if requested.
While here, fixed the error message in case QUIC support is missing.
2021-09-27 10:10:38 +03:00
Ruslan Ermilov d116018bf7 Configure: check for QUIC 0-RTT support at compile time. 2021-09-27 10:10:37 +03:00
Sergey Kandaurov 9d1f7d142f HTTP/3: fixed null pointer dereference with server push.
See details for HTTP/2 fix in 8b0553239592 for a complete description.
2021-09-22 14:10:43 +03:00
Roman Arutyunyan 296f54ff65 HTTP/3: fixed ngx_stat_active counter.
Previously the counter was not incremented for HTTP/3 streams, but still
decremented in ngx_http_close_connection().  There are two solutions here, one
is to increment the counter for HTTP/3 streams, and the other one is not to
decrement the counter for HTTP/3 streams.  The latter solution looks
inconsistent with ngx_stat_reading/ngx_stat_writing, which are incremented on a
per-request basis.  The change adds ngx_stat_active increment for HTTP/3
request and push streams.
2021-09-22 14:08:21 +03:00
Roman Arutyunyan 60991ababd HTTP/3: fixed pushed request finalization in case of error.
Previously request could be finalized twice.  For example, this could happen
if "Host" header was invalid.
2021-09-17 15:28:31 +03:00
Sergey Kandaurov d2b5c8ad58 QUIC: set NGX_TCP_NODELAY_DISABLED for fake stream connections.
Notably, it is to avoid setting the TCP_NODELAY flag for QUIC streams
in ngx_http_upstream_send_response().  It is an invalid operation on
inherently SOCK_DGRAM sockets, which leads to QUIC connection close.

The change reduces diff to the default branch in stream content phase.
2021-09-22 14:01:18 +03:00
Roman Arutyunyan 145268fe63 QUIC: simplified stream fd initialization. 2021-09-21 18:25:26 +03:00
Ruslan Ermilov d0e0fb02ba Configure: USE_OPENSSL_QUIC=YES implies USE_OPENSSL=YES. 2021-09-21 14:46:30 +03:00
Ruslan Ermilov 69fbd46f02 Configure: ordered directories. 2021-09-21 14:46:25 +03:00
Ruslan Ermilov 63f265eaa9 Configure: simplified condition. 2021-09-21 14:46:17 +03:00
Roman Arutyunyan 5a3cca487d HTTP/3: make ngx_http_log_error() static again.
This function was only referenced from ngx_http_v3_create_push_request() to
initialize push connection log.  Now the log handler is copied from the parent
request connection.

The change reduces diff to the default branch.
2021-09-17 16:32:23 +03:00
Roman Arutyunyan d2463a2dc3 QUIC: separate event handling functions.
The functions ngx_quic_handle_read_event() and ngx_quic_handle_write_event()
are added.  Previously this code was a part of ngx_handle_read_event() and
ngx_handle_write_event().

The change simplifies ngx_handle_read_event() and ngx_handle_write_event()
by moving QUIC-related code to a QUIC source file.
2021-09-09 16:55:00 +03:00
Sergey Kandaurov 542d5f7996 HTTP/3: added CONNECT and TRACE methods rejection.
It has got lost in e1eb7f4ca9f1, let alone a subsequent update in 63c66b7cc07c.
2021-09-16 13:13:22 +03:00
Ruslan Ermilov ec9069206a Removed NGX_OPENSSL_QUIC macro, NGX_QUIC is enough. 2021-09-14 12:09:13 +03:00
Sergey Kandaurov bd9900a70f HTTP/3: added debug logging of response fields.
Because of QPACK compression it's hard to see what fields are actually
sent by the server.
2021-09-13 16:25:37 +03:00
Sergey Kandaurov 33eac933f5 HTTP/3: Huffman encoding for the Location response field. 2021-09-13 16:25:32 +03:00
Sergey Kandaurov 6437be8849 HTTP/3: Huffman encoding for the Last-Modified response field. 2021-09-13 16:25:31 +03:00
Sergey Kandaurov 65ad235948 HTTP/3: Huffman encoding for the Content-Type response field. 2021-09-13 16:25:23 +03:00
Sergey Kandaurov 5cc25926d1 HTTP/3: implemented QPACK Huffman encoding for response fields. 2021-09-13 16:25:08 +03:00
Roman Arutyunyan 5cb81675d5 HTTP/3: reading body buffering in filters.
This change follows similar changes in HTTP/1 and HTTP/2 in 9cf043a5d9ca.
2021-09-09 15:47:29 +03:00
Sergey Kandaurov 3b47302e94 QUIC: removed Firefox workaround for trailing zeroes in datagrams.
This became unnecessary after discarding invalid packets since a6784cf32c13.
2021-09-09 19:12:27 +03:00
Ruslan Ermilov ea78a549ed QUIC: macro style. 2021-09-09 15:40:08 +03:00
Ruslan Ermilov 7372cd0fae Changed the OpenSSL QUIC support detection.
As was changed in 253cf267f95a.
2021-09-09 15:34:00 +03:00
Sergey Kandaurov c530e2624e Merged with the default branch. 2021-09-08 15:53:00 +03:00
Maxim Dounin b8d5f5e340 release-1.21.3 tag 2021-09-07 18:21:03 +03:00
Maxim Dounin 27f579a7ab nginx-1.21.3-RELEASE 2021-09-07 18:21:02 +03:00
Roman Arutyunyan 77990eb5b9 QUIC: store QUIC connection fd in stream fake connection.
Previously it had -1 as fd.  This fixes proxying, which relies on downstream
connection having a real fd.  Also, this reduces diff to the default branch for
ngx_close_connection().
2021-09-06 16:59:00 +03:00
Maxim Dounin fc76464859 HTTP/2: optimized processing of small DATA frames.
The request body filter chain is no longer called after processing
a DATA frame.  Instead, we now post a read event to do this.  This
ensures that multiple small DATA frames read during the same event loop
iteration are coalesced together, resulting in much faster processing.

Since rb->buf can now contain unprocessed data, window update is no
longer sent in ngx_http_v2_state_read_data() in case of flow control
being used due to filter buffering.  Instead, window will be updated
by ngx_http_v2_read_client_request_body_handler() in the posted read
event.
2021-09-06 14:54:50 +03:00
Maxim Dounin 580b2ee445 HTTP/2: fixed timers left after request body reading.
Following rb->filter_need_buffering changes, request body reading is
only finished after the filter chain is called and rb->last_saved is set.
As such, with r->request_body_no_buffering, timer on fc->read is no
longer removed when the last part of the body is received, potentially
resulting in incorrect behaviour.

The fix is to call ngx_http_v2_process_request_body() from the
ngx_http_v2_read_unbuffered_request_body() function instead of
directly calling ngx_http_v2_filter_request_body(), so the timer
is properly removed.
2021-09-06 14:54:48 +03:00
Maxim Dounin cd91eb26f5 HTTP/2: fixed window updates when buffering in filters.
In the body read handler, the window was incorrectly calculated
based on the full buffer size instead of the amount of free space
in the buffer.  If the request body is buffered by a filter, and
the buffer is not empty after the read event is generated by the
filter to resume request body processing, this could result in
"http2 negative window update" alerts.

Further, in the body ready handler and in ngx_http_v2_state_read_data()
the buffer wasn't cleared when the data were already written to disk,
so the client might stuck without window updates.
2021-09-06 14:54:47 +03:00
Mariano Di Martino c0ab3094ae QUIC: fixed null pointer dereference in MAX_DATA handler.
If a MAX_DATA frame was received before any stream was created, then the worker
process would crash in nginx_quic_handle_max_data_frame() while traversing the
stream tree.  The issue is solved by adding a check that makes sure the tree is
not empty.
2021-09-03 14:23:50 +03:00
Roman Arutyunyan 963d191d3d Fixed debug logging. 2021-09-02 12:25:37 +03:00
Roman Arutyunyan 4aece4fef0 Version bump. 2021-09-03 17:19:33 +03:00
Sergey Kandaurov 0bdfcc0fdd README: HTTP/3 trailers are now supported. 2021-09-01 11:12:23 +03:00
Sergey Kandaurov ddf508aef8 Merged with the default branch. 2021-09-01 10:57:25 +03:00
Maxim Dounin f803495449 release-1.21.2 tag 2021-08-31 18:13:47 +03:00
Maxim Dounin 8dec02e854 nginx-1.21.2-RELEASE 2021-08-31 18:13:46 +03:00
Maxim Dounin 4f10d0da4a Updated OpenSSL used for win32 builds. 2021-08-31 17:54:54 +03:00
Maxim Dounin 7af88d829d HTTP/2: avoid memcpy() with NULL source and zero length.
Prodded by Clang Static Analyzer.
2021-08-31 16:44:13 +03:00
Sergey Kandaurov 8eb1632771 Give GCC atomics precedence over deprecated Darwin atomic(3).
This allows to build nginx on macOS with -Wdeprecated-declarations.
2021-08-30 14:45:21 +03:00
Maxim Dounin f3f51dd5b3 Request body: reading body buffering in filters.
If a filter wants to buffer the request body during reading (for
example, to check an external scanner), it can now do so.  To make
it possible, the code now checks rb->last_saved (introduced in the
previous change) along with rb->rest == 0.

Since in HTTP/2 this requires flow control to avoid overflowing the
request body buffer, so filters which need buffering have to set
the rb->filter_need_buffering flag on the first filter call.  (Note
that each filter is expected to call the next filter, so all filters
will be able set the flag if needed.)
2021-08-29 22:22:02 +03:00
Maxim Dounin a0fa88b3bf Request body: introduced rb->last_saved flag.
It indicates that the last buffer was received by the save filter,
and can be used to check this at higher levels.  To be used in the
following changes.
2021-08-29 22:21:03 +03:00
Maxim Dounin 5a012034c7 Request body: added alert to catch duplicate body saving.
If due to an error ngx_http_request_body_save_filter() is called
more than once with rb->rest == 0, this used to result in a segmentation
fault.  Added an alert to catch such errors, just in case.
2021-08-29 22:20:54 +03:00
Maxim Dounin 9dbe0c18e4 Request body: missing comments about initialization. 2021-08-29 22:20:49 +03:00
Maxim Dounin 950596248d HTTP/2: improved handling of preread unbuffered requests.
Previously, fully preread unbuffered requests larger than client body
buffer size were saved to disk, despite the fact that "unbuffered" is
expected to imply no disk buffering.
2021-08-29 22:20:44 +03:00
Maxim Dounin c971d2ad9f HTTP/2: improved handling of END_STREAM in a separate DATA frame.
The save body filter saves the request body to disk once the buffer is full.
Yet in HTTP/2 this might happen even if there is no need to save anything
to disk, notably when content length is known and the END_STREAM flag is
sent in a separate empty DATA frame.  Workaround is to provide additional
byte in the buffer, so saving the request body won't be triggered.

This fixes unexpected request body disk buffering in HTTP/2 observed after
the previous change when content length is known and the END_STREAM flag
is sent in a separate empty DATA frame.
2021-08-29 22:20:38 +03:00
Maxim Dounin 2cd576fac7 HTTP/2: reworked body reading to better match HTTP/1.x code.
In particular, now the code always uses a buffer limited by
client_body_buffer_size.  At the cost of an additional copy it
ensures that small DATA frames are not directly mapped to small
write() syscalls, but rather buffered in memory before writing.
Further, requests without Content-Length are no longer forced
to use temporary files.
2021-08-29 22:20:36 +03:00
Maxim Dounin e02f2026a8 HTTP/2: improved body reading logging. 2021-08-29 22:20:34 +03:00
Maxim Dounin 98d81a4578 Upstream: fixed timeouts with gRPC, SSL and select (ticket #2229).
With SSL it is possible that an established connection is ready for
reading after the handshake.  Further, events might be already disabled
in case of level-triggered event methods.  If this happens and
ngx_http_upstream_send_request() blocks waiting for some data from
the upstream, such as flow control in case of gRPC, the connection
will time out due to no read events on the upstream connection.

Fix is to explicitly check the c->read->ready flag if sending request
blocks and post a read event if it is set.

Note that while it is possible to modify ngx_ssl_handshake() to keep
read events active, this won't completely resolve the issue, since
there can be data already received during the SSL handshake
(see 573bd30e46b4).
2021-08-20 03:53:56 +03:00
Alexey Radkov da4d418cc3 Core: removed unnecessary restriction in hash initialization.
Hash initialization ignores elements with key.data set to NULL.
Nevertheless, the initial hash bucket size check didn't skip them,
resulting in unnecessary restrictions on, for example, variables with
long names and with the NGX_HTTP_VARIABLE_NOHASH flag.

Fix is to update the initial hash bucket size check to skip elements
with key.data set to NULL, similarly to how it is done in other parts
of the code.
2021-08-19 20:51:27 +03:00
Maxim Dounin 18a138d640 MIME: added image/avif type.
Prodded by Ryo Hirafuji, André Rømcke, Artur Juraszek.
2021-10-25 20:49:15 +03:00
Maxim Dounin ca7fe8924b SSL: SSL_sendfile() support with kernel TLS.
Requires OpenSSL 3.0 compiled with "enable-ktls" option.  Further, KTLS
needs to be enabled in kernel, and in OpenSSL, either via OpenSSL
configuration file or with "ssl_conf_command Options KTLS;" in nginx
configuration.

On FreeBSD, kernel TLS is available starting with FreeBSD 13.0, and
can be enabled with "sysctl kern.ipc.tls.enable=1" and "kldload ktls_ocf"
to load a software backend, see man ktls(4) for details.

On Linux, kernel TLS is available starting with kernel 4.13 (at least 5.2
is recommended), and needs kernel compiled with CONFIG_TLS=y (with
CONFIG_TLS=m, which is used at least on Ubuntu 21.04 by default,
the tls module needs to be loaded with "modprobe tls").
2021-10-21 18:44:07 +03:00
Maxim Dounin fb51fba9ce Style: added missing "static" specifiers.
Mostly found by gcc -Wtraditional, per "non-static declaration of ...
follows static declaration [-Wtraditional]" warnings.
2021-10-21 18:43:13 +03:00
Maxim Dounin 6c6b5ca3ab Removed CLOCK_MONOTONIC_COARSE support.
While clock_gettime(CLOCK_MONOTONIC_COARSE) is faster than
clock_gettime(CLOCK_MONOTONIC), the latter is fast enough on Linux for
practical usage, and the difference is negligible compared to other costs
at each event loop iteration.  On the other hand, CLOCK_MONOTONIC_COARSE
causes various issues with typical CONFIG_HZ=250, notably very inaccurate
limit_rate handling in some edge cases (ticket #1678) and negative difference
between $request_time and $upstream_response_time (ticket #1965).
2021-10-21 18:38:38 +03:00
Vladimir Homutov 3235758443 Mail: connections with wrong ALPN protocols are now rejected.
This is a recommended behavior by RFC 7301 and is useful
for mitigation of protocol confusion attacks [1].

For POP3 and IMAP protocols IANA-assigned ALPN IDs are used [2].
For the SMTP protocol "smtp" is used.

[1] https://alpaca-attack.com/
[2] https://www.iana.org/assignments/tls-extensiontype-values/
2021-10-20 09:45:34 +03:00
Vladimir Homutov b0ed1de8c6 HTTP: connections with wrong ALPN protocols are now rejected.
This is a recommended behavior by RFC 7301 and is useful
for mitigation of protocol confusion attacks [1].

To avoid possible negative effects, list of supported protocols
was extended to include all possible HTTP protocol ALPN IDs
registered by IANA [2], i.e. "http/1.0" and "http/0.9".

[1] https://alpaca-attack.com/
[2] https://www.iana.org/assignments/tls-extensiontype-values/
2021-10-20 09:50:02 +03:00
Vladimir Homutov 9f2dc77f4f Stream: the "ssl_alpn" directive.
The directive sets the server list of supported application protocols
and requires one of this protocols to be negotiated if client is using
ALPN.
2021-10-19 12:19:59 +03:00
Vladimir Homutov 326e670aa0 SSL: added $ssl_alpn_protocol variable.
The variable contains protocol selected by ALPN during handshake and
is empty otherwise.
2021-10-14 11:46:23 +03:00
Vladimir Homutov 27d1a8bb5d HTTP/2: removed support for NPN.
NPN was replaced with ALPN, published as RFC 7301 in July 2014.
It used to negotiate SPDY (and, in transition, HTTP/2).

NPN supported appeared in OpenSSL 1.0.1. It does not work with TLSv1.3 [1].
ALPN is supported since OpenSSL 1.0.2.

The NPN support was dropped in Firefox 53 [2] and Chrome 51 [3].

[1] https://github.com/openssl/openssl/issues/3665.
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1248198
[3] https://www.chromestatus.com/feature/5767920709795840
2021-10-15 10:02:15 +03:00
Maxim Dounin 7e799aa74c Upstream: fixed logging level of upstream invalid header errors.
In b87b7092cedb (nginx 1.21.1), logging level of "upstream sent invalid
header" errors was accidentally changed to "info".  This change restores
the "error" level, which is a proper logging level for upstream-side
errors.
2021-10-18 16:46:59 +03:00
Maxim Dounin 98b959d4f4 Synced ngx_http_subrequest() argument names (ticket #2255). 2021-10-12 23:18:18 +03:00
Awdhesh Mathpal 818e509ff1 Proxy: disabled keepalive on extra data in non-buffered mode.
The u->keepalive flag is initialized early if the response has no body
(or an empty body), and needs to be reset if there are any extra data,
similarly to how it is done in ngx_http_proxy_copy_filter().  Missed
in 83c4622053b0.
2021-10-07 19:23:11 -07:00
Maxim Dounin 198520b3ed Fixed $content_length cacheability with chunked (ticket #2252). 2021-10-06 18:01:42 +03:00
Vladimir Homutov 1444f0649f Stream: added half-close support.
The "proxy_half_close" directive enables handling of TCP half close.  If
enabled, connection to proxied server is kept open until both read ends get
EOF.  Write end shutdown is properly transmitted via proxy.
2021-09-22 10:20:00 +03:00
Roman Arutyunyan 04a9d60542 Request body: do not create temp file if there's nothing to write.
Do this only when the entire request body is empty and
r->request_body_in_file_only is set.

The issue manifested itself with missing warning "a client request body is
buffered to a temporary file" when the entire rb->buf is full and all buffers
are delayed by a filter.
2021-09-10 12:59:22 +03:00
Roman Arutyunyan af9bdb4c00 Version bump. 2021-09-14 12:12:02 +03:00
Rob Mueller 94deaa03f7 Mail: Auth-SSL-Protocol and Auth-SSL-Cipher headers (ticket #2134).
This adds new Auth-SSL-Protocol and Auth-SSL-Cipher headers to
the mail proxy auth protocol when SSL is enabled.

This can be useful for detecting users using older clients that
negotiate old ciphers when you want to upgrade to newer
TLS versions of remove suppport for old and insecure ciphers.
You can use your auth backend to notify these users before the
upgrade that they either need to upgrade their client software
or contact your support team to work out an upgrade path.
2021-08-13 03:57:47 -04:00
Maxim Dounin 9129c52b05 SSL: ciphers now set before loading certificates (ticket #2035).
To load old/weak server or client certificates it might be needed to adjust
the security level, as introduced in OpenSSL 1.1.0.  This change ensures that
ciphers are set before loading the certificates, so security level changes
via the cipher string apply to certificate loading.
2021-08-16 22:40:31 +03:00
Maxim Dounin 13f1647e50 Dark mode support in welcome and 50x error pages.
Prodded by Duncan Lock.
2021-08-16 16:36:08 +03:00
Maxim Dounin 7bbf91b130 Welcome and 50x error pages style.
Indentation of the CSS code removed to match style of the HTML code.
2021-08-16 16:36:06 +03:00
Sergey Kandaurov 3e413eb22a SSL: removed use of the SSL_OP_MSIE_SSLV2_RSA_PADDING option.
It has no effect since OpenSSL 0.9.7h and 0.9.8a.
2021-08-10 23:43:17 +03:00
Sergey Kandaurov e24c475706 SSL: removed export ciphers support.
Export ciphers are forbidden to negotiate in TLS 1.1 and later protocol modes.
They are disabled since OpenSSL 1.0.2g by default unless explicitly configured
with "enable-weak-ssl-ciphers", and completely removed in OpenSSL 1.1.0.
2021-08-10 23:43:17 +03:00
Sergey Kandaurov 19297afcc6 SSL: use of the SSL_OP_IGNORE_UNEXPECTED_EOF option.
A new behaviour was introduced in OpenSSL 1.1.1e, when a peer does not send
close_notify before closing the connection.  Previously, it was to return
SSL_ERROR_SYSCALL with errno 0, known since at least OpenSSL 0.9.7, and is
handled gracefully in nginx.  Now it returns SSL_ERROR_SSL with a distinct
reason SSL_R_UNEXPECTED_EOF_WHILE_READING ("unexpected eof while reading").
This leads to critical errors seen in nginx within various routines such as
SSL_do_handshake(), SSL_read(), SSL_shutdown().  The behaviour was restored
in OpenSSL 1.1.1f, but presents in OpenSSL 3.0 by default.

Use of the SSL_OP_IGNORE_UNEXPECTED_EOF option added in OpenSSL 3.0 allows
to set a compatible behaviour to return SSL_ERROR_ZERO_RETURN:
https://git.openssl.org/?p=openssl.git;a=commitdiff;h=09b90e0

See for additional details: https://github.com/openssl/openssl/issues/11381
2021-08-10 23:43:17 +03:00
Sergey Kandaurov a9aa03a28c SSL: silenced warnings when building with OpenSSL 3.0.
The OPENSSL_SUPPRESS_DEPRECATED macro is used to suppress deprecation warnings.
This covers Session Tickets keys, SSL Engine, DH low level API for DHE ciphers.

Unlike OPENSSL_API_COMPAT, it works well with OpenSSL built with no-deprecated.
In particular, it doesn't unhide various macros in OpenSSL includes, which are
meant to be hidden under OPENSSL_NO_DEPRECATED.
2021-08-10 23:43:16 +03:00
Sergey Kandaurov 7002d3a05c SSL: ERR_peek_error_line_data() compatibility with OpenSSL 3.0.
ERR_peek_error_line_data() was deprecated in favour of ERR_peek_error_all().
Here we use the ERR_peek_error_data() helper to pass only used arguments.
2021-08-10 23:43:16 +03:00
Sergey Kandaurov e369936f69 SSL: using SSL_CTX_set0_tmp_dh_pkey() with OpenSSL 3.0 in dhparam.
Using PEM_read_bio_DHparams() and SSL_CTX_set_tmp_dh() is deprecated
as part of deprecating the low level DH functions in favor of EVP_PKEY:
https://git.openssl.org/?p=openssl.git;a=commitdiff;h=163f6dc
2021-08-10 23:43:16 +03:00
Sergey Kandaurov 1119577cff SSL: SSL_get_peer_certificate() is deprecated in OpenSSL 3.0.
Switch to SSL_get1_peer_certificate() when building with OpenSSL 3.0
and OPENSSL_NO_DEPRECATED defined.
2021-08-10 23:43:16 +03:00
Sergey Kandaurov 6988c16717 SSL: RSA data type is deprecated in OpenSSL 3.0.
The only consumer is a callback function for SSL_CTX_set_tmp_rsa_callback()
deprecated in OpenSSL 1.1.0.  Now the function is conditionally compiled too.
2021-08-10 23:42:59 +03:00
Sergey Kandaurov 4c5efd9794 Disabled HTTP/1.0 requests with Transfer-Encoding.
The latest HTTP/1.1 draft describes Transfer-Encoding in HTTP/1.0 as having
potentially faulty message framing as that could have been forwarded without
handling of the chunked encoding, and forbids processing subsequest requests
over that connection: https://github.com/httpwg/http-core/issues/879.

While handling of such requests is permitted, the most secure approach seems
to reject them.
2021-08-09 18:12:12 +03:00
Sergey Kandaurov 3c65d1efd9 SSL: SSL_CTX_set_tmp_dh() error handling.
For example, it can fail due to weak DH parameters.
2021-08-04 21:27:51 +03:00
Maxim Dounin 715d1a2992 SSL: set events ready flags after handshake.
The c->read->ready and c->write->ready flags might be reset during
the handshake, and not set again if the handshake was finished on
the other event.  At the same time, some data might be read from
the socket during the handshake, so missing c->read->ready flag might
result in a connection hang, for example, when waiting for an SMTP
greeting (which was already received during the handshake).

Found by Sergey Kandaurov.
2021-08-03 20:50:30 +03:00
Maxim Dounin 7907f92bde Version bump. 2021-08-03 20:50:08 +03:00
Roman Arutyunyan 7c9cdcd3f9 HTTP/3: bulk parse functions.
Previously HTTP/3 streams were parsed by one character.  Now all parse functions
receive buffers.  This should optimize parsing time and CPU load.
2021-07-08 21:52:47 +03:00
Sergey Kandaurov d4fae36970 QUIC: Stateless Reset Token debug logging cleanup. 2021-08-24 14:41:31 +03:00
Sergey Kandaurov 640fd08e71 QUIC: removed duplicate logging of Stateless Reset Token. 2021-08-24 14:40:33 +03:00
Sergey Kandaurov caa3e48d23 HTTP/3: fixed dead store assignment.
Found by Clang Static Analyzer.
2021-08-24 13:03:48 +03:00
Sergey Kandaurov 675c700e7b QUIC: fixed dead store assignment.
Found by Clang Static Analyzer.
2021-08-24 13:03:46 +03:00
Sergey Kandaurov 94e092c897 QUIC: fixed format specifiers in ngx_quic_bpf module. 2021-08-17 11:41:11 +03:00
Sergey Kandaurov 34db4b5a52 HTTP/3: disabled control characters and space in header names.
This is a follow up to 41f4bd4c51f1.
2021-08-10 12:35:12 +03:00
Vladimir Homutov 9a632808a3 QUIC: better ordering in auto/modules. 2021-08-05 11:13:29 +03:00
Vladimir Homutov 9eae4cc19a HTTP/3: got rid of HTTP/2 module dependency.
The Huffman encoder/decoder now can be built separately from HTTP/2 module.
2021-08-05 11:09:13 +03:00
Roman Arutyunyan ecadcc5186 HTTP/3: replaced macros with values. 2021-08-04 17:35:11 +03:00
Roman Arutyunyan 923de21472 QUIC: asynchronous shutdown.
Previously, when cleaning up a QUIC stream in shutdown mode,
ngx_quic_shutdown_quic() was called, which could close the QUIC connection
right away.  This could be a problem if the connection was referenced up the
stack.  For example, this could happen in ngx_quic_init_streams(),
ngx_quic_close_streams(), ngx_quic_create_client_stream() etc.

With a typical HTTP/3 client the issue is unlikely because of HTTP/3 uni
streams which need a posted event to close.  In this case QUIC connection
cannot be closed right away.

Now QUIC connection read event is posted and it will shut down the connection
asynchronously.
2021-08-05 09:20:32 +03:00
Sergey Kandaurov 4d7ce86ff5 QUIC: client certificate validation with OCSP. 2021-08-04 15:49:18 +03:00
Roman Arutyunyan 671aa053d5 HTTP/3: close connection on keepalive_requests * 2.
After receiving GOAWAY, client is not supposed to create new streams.  However,
until client reads this frame, we allow it to create new streams, which are
gracefully rejected.  To prevent client from abusing this algorithm, a new
limit is introduced.  Upon reaching keepalive_requests * 2, server now closes
the entire QUIC connection claiming excessive load.
2021-07-29 16:01:37 +03:00
Roman Arutyunyan bc073e9460 QUIC: stream limits in "hq" mode.
The "hq" mode is HTTP/0.9-1.1 over QUIC.  The following limits are introduced:

- uni streams are not allowed
- keepalive_requests is enforced
- keepalive_time is enforced

In case of error, QUIC connection is finalized with 0x101 code.  This code
corresponds to HTTP/3 General Protocol Error.
2021-08-02 15:48:21 +03:00
Roman Arutyunyan a63a5cfdc0 HTTP/3: http3_max_uni_streams directive.
The directive limits the number of uni streams client is allowed to create.
2021-07-29 12:17:56 +03:00
Roman Arutyunyan 080d689d18 QUIC: limit in-flight bytes by congestion window.
Previously, in-flight byte counter and congestion window were properly
maintained, but the limit was not properly implemented.

Now a new datagram is sent only if in-flight byte counter is less than window.
The limit is datagram-based, which means that a single datagram may lead to
exceeding the limit, but the next one will not be sent.
2021-07-29 12:49:16 +03:00
Vladimir Homutov bac84680d8 QUIC: handle EAGAIN properly on UDP sockets.
Previously, the error was ignored leading to unnecessary retransmits.
Now, unsent frames are returned into output queue, state is reset, and
timer is started for the next send attempt.
2021-07-28 17:23:18 +03:00
Roman Arutyunyan 6180a7c9f7 HTTP/3: require mandatory uni streams before additional ones.
As per quic-http-34:

   Endpoints SHOULD create the HTTP control stream as well as the
   unidirectional streams required by mandatory extensions (such as the
   QPACK encoder and decoder streams) first, and then create additional
   streams as allowed by their peer.

Previously, client could create and destroy additional uni streams unlimited
number of times before creating mandatory streams.
2021-07-29 10:03:36 +03:00
Roman Arutyunyan 8b946e8575 QUIC: eliminated stream type from ngx_quic_stream_frame_t.
The information about the type is contained in off/len/fin bits.

Also, where possible, only the first stream type (0x08) is used for simplicity.
2021-07-28 13:21:47 +03:00
Vladimir Homutov 8ad7e74e1e QUIC: updated README with GSO details. 2021-07-23 11:25:16 +03:00
Roman Arutyunyan 017801b303 HTTP/3: use request pool instead of connection pool.
In several parts of ngx_http_v3_header_filter() connection pool was used for
request-related data.
2021-07-16 15:43:01 +03:00
Roman Arutyunyan 66991ee03a HTTP/3: response trailers support. 2021-07-13 22:44:03 +03:00
Sergey Kandaurov 7703098c6f QUIC: avoid processing 1-RTT with incomplete handshake in OpenSSL.
OpenSSL is known to provide read keys for an encryption level before the
level is active in TLS, following the old BoringSSL API.  In BoringSSL,
it was then fixed to defer releasing read keys until QUIC may use them.
2021-07-22 15:00:37 +03:00
Vladimir Homutov 0cde3f4f6e QUIC: the "quic_gso" directive.
The directive enables usage of UDP segmentation offloading by quic.
By default, gso is disabled since it is not always operational when
detected (depends on interface configuration).
2021-07-20 12:37:12 +03:00
Vladimir Homutov f59b487a69 Core: fixed errno clobbering in ngx_sendmsg().
This was broken by 2dfd313f22f2.
2021-07-20 12:04:58 +03:00
Sergey Kandaurov 6750340391 Merged with the default branch. 2021-07-15 16:28:21 +03:00
Vladimir Homutov 5224f4a67b Core: added separate function for local source address cmsg. 2021-07-15 14:22:54 +03:00
Vladimir Homutov b828c7f3c6 QUIC: added support for segmentation offloading.
To improve output performance, UDP segmentation offloading is used
if available.  If there is a significant amount of data in an output
queue and path is verified, QUIC packets are not sent one-by-one,
but instead are collected in a buffer, which is then passed to kernel
in a single sendmsg call, using UDP GSO.  Such method greatly decreases
number of system calls and thus system load.
2021-07-15 14:22:00 +03:00
Vladimir Homutov ab83c52df6 Core: made the ngx_sendmsg() function non-static.
Additionally, the ngx_init_srcaddr_cmsg() function is introduced which
initializes control message with connection local address.

The NGX_HAVE_ADDRINFO_CMSG macro is defined when at least one of methods
to deal with corresponding control message is available.
2021-07-15 14:21:39 +03:00
Vladimir Homutov 906023d724 Core: the ngx_event_udp.h header file. 2021-07-12 16:40:57 +03:00
Maxim Dounin f42c092eca release-1.21.1 tag 2021-07-06 17:59:17 +03:00
Maxim Dounin 23c55f959e nginx-1.21.1-RELEASE 2021-07-06 17:59:16 +03:00
Ruslan Ermilov 11a70b1f34 Win32: use only preallocated memory in send/recv chain functions.
The ngx_wsasend_chain() and ngx_wsarecv_chain() functions were
modified to use only preallocated memory, and the number of
preallocated wsabufs was increased to 64.
2021-07-05 13:26:49 +03:00
Vladimir Homutov 8f9794c09f QUIC: fixed padding calculation.
Sometimes, QUIC packets need to be of certain (or minimal) size.  This is
achieved by adding PADDING frames.  It is possible, that adding padding will
affect header size, thus forcing us to recalculate padding size once more.
2021-07-05 13:17:10 +03:00
Ruslan Ermilov 1ed44c95f5 Use only preallocated memory in ngx_readv_chain() (ticket #1408).
In d1bde5c3c5d2, the number of preallocated iovec's for ngx_readv_chain()
was increased.  Still, in some setups, the function might allocate memory
for iovec's from a connection pool, which is only freed when closing the
connection.

The ngx_readv_chain() function was modified to use only preallocated
memory, similarly to the ngx_writev_chain() change in 8e903522c17a.
2021-07-05 13:09:23 +03:00
Sergey Kandaurov 53e0bd538c HTTP/3: quic-qpack term updates.
Renamed header -> field per quic-qpack naming convention, in particular:
- Header Field -> Field Line
- Header Block -> (Encoded) Field Section
- Without Name Reference -> With Literal Name
- Header Acknowledgement -> Section Acknowledgment
2021-07-01 15:37:53 +03:00
Roman Arutyunyan 13dc9039b0 QUIC: consider max_ack_delay=16384 invalid.
As per RFC 9000:

   Values of 2^14 or greater are invalid.
2021-06-30 13:47:38 +03:00
Maxim Dounin eba1abc528 Disabled control characters in the Host header.
Control characters (0x00-0x1f, 0x7f) and space are not expected to appear
in the Host header.  Requests with such characters in the Host header are
now unconditionally rejected.
2021-06-28 18:01:24 +03:00
Maxim Dounin c3e92fb16c Improved logging of invalid headers.
In 71edd9192f24 logging of invalid headers which were rejected with the
NGX_HTTP_PARSE_INVALID_HEADER error was restricted to just the "client
sent invalid header line" message, without any attempts to log the header
itself.

This patch returns logging of the header up to the invalid character and
the character itself.  The r->header_end pointer is now properly set
in all cases to make logging possible.

The same logging is also introduced when parsing headers from upstream
servers.
2021-06-28 18:01:20 +03:00
Maxim Dounin 172878677a Disabled control characters and space in header names.
Control characters (0x00-0x1f, 0x7f), space, and colon were never allowed in
header names.  The only somewhat valid use is header continuation which nginx
never supported and which is explicitly obsolete by RFC 7230.

Previously, such headers were considered invalid and were ignored by default
(as per ignore_invalid_headers directive).  With this change, such headers
are unconditionally rejected.

It is expected to make nginx more resilient to various attacks, in particular,
with ignore_invalid_headers switched off (which is inherently unsecure, though
nevertheless sometimes used in the wild).
2021-06-28 18:01:18 +03:00
Maxim Dounin 5baf7b37e8 Disabled control characters in URIs.
Control characters (0x00-0x1f, 0x7f) were never allowed in URIs, and must
be percent-encoded by clients.  Further, these are not believed to appear
in practice.  On the other hand, passing such characters might make various
attacks possible or easier, despite the fact that currently allowed control
characters are not significant for HTTP request parsing.
2021-06-28 18:01:15 +03:00
Maxim Dounin 50b5547eec Disabled spaces in URIs (ticket #196).
From now on, requests with spaces in URIs are immediately rejected rather
than allowed.  Spaces were allowed in 31e9677b15a1 (0.8.41) to handle bad
clients.  It is believed that now this behaviour causes more harm than
good.
2021-06-28 18:01:13 +03:00
Maxim Dounin 656c2db199 Core: escaping of chars not allowed in URIs per RFC 3986.
Per RFC 3986 only the following characters are allowed in URIs unescaped:

unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
gen-delims    = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
              / "*" / "+" / "," / ";" / "="

And "%" can appear as a part of escaping itself.  The following
characters are not allowed and need to be escaped: %00-%1F, %7F-%FF,
" ", """, "<", ">", "\", "^", "`", "{", "|", "}".

Not escaping ">" is known to cause problems at least with MS Exchange (see
http://nginx.org/pipermail/nginx-ru/2010-January/031261.html) and in
Tomcat (ticket #2191).

The patch adds escaping of the following chars in all URI parts: """, "<",
">", "\", "^", "`", "{", "|", "}".  Note that comments are mostly preserved
to outline important characters being escaped.
2021-06-28 18:01:11 +03:00
Maxim Dounin 26042af6e0 Core: fixed comment about escaping in arguments.
After 4954530db2af, the ";" character is escaped by
ngx_escape_uri(NGX_ESCAPE_ARGS).
2021-06-28 18:01:09 +03:00
Maxim Dounin 11a2c4baf6 Disabled requests with both Content-Length and Transfer-Encoding.
HTTP clients are not allowed to generate such requests since Transfer-Encoding
introduction in RFC 2068, and they are not expected to appear in practice
except in attempts to perform a request smuggling attack.  While handling of
such requests is strictly defined, the most secure approach seems to reject
them.
2021-06-28 18:01:06 +03:00
Maxim Dounin 6ad2a6ce6e Added CONNECT method rejection.
No valid CONNECT requests are expected to appear within nginx, since it
is not a forward proxy.  Further, request line parsing will reject
proper CONNECT requests anyway, since we don't allow authority-form of
request-target.  On the other hand, RFC 7230 specifies separate message
length rules for CONNECT which we don't support, so make sure to always
reject CONNECTs to avoid potential abuse.
2021-06-28 18:01:04 +03:00
Maxim Dounin 5eb2916d2c Moved TRACE method rejection to a better place.
Previously, TRACE requests were rejected before parsing Transfer-Encoding.
This is not important since keepalive is not enabled at this point anyway,
though rejecting such requests after properly parsing other headers is
less likely to cause issues in case of further code changes.
2021-06-28 18:01:00 +03:00
Vladimir Homutov bee065a7bd QUIC: fixed client certificates verification in stream.
The stream session requires 'ssl' flag to be set in order to perform
certificate verification.
2021-06-23 13:22:00 +03:00
Sergey Kandaurov 8c3ff38e77 README: updated path after moving QUIC sources. 2021-06-25 12:41:58 +03:00
Sergey Kandaurov d674a2345d QUIC: fixed double memzero of new frames in ngx_quic_alloc_frame(). 2021-06-21 12:47:46 +03:00
Vladimir Homutov 787ffd4c3d Core: added the ngx_rbtree_data() macro. 2021-06-21 09:42:43 +03:00
Maxim Dounin ceafa06599 Fixed format strings for ngx_win32_version. 2021-06-18 04:00:21 +03:00
Sergey Kandaurov 3090dcd82d QUIC: compact initial secrets table. 2021-06-17 12:35:38 +03:00
Sergey Kandaurov 4600e1d9c6 gRPC: RST_STREAM(NO_ERROR) handling micro-optimization.
After 2096b21fcd10, a single RST_STREAM(NO_ERROR) may not result in an error.
This change removes several unnecessary ctx->type checks for such a case.
2021-06-17 11:44:06 +03:00
Sergey Kandaurov a07a7da04f gRPC: handling GOAWAY with a higher last stream identifier.
Previously, once received from upstream, it couldn't limit
opening additional streams in a cached keepalive connection.
2021-06-17 11:43:55 +03:00
Sergey Kandaurov e6f8a9447f QUIC: using compile time block/iv length for tokens.
Reference values can be found in RFC 3602, 2.1, 2.4.
2021-06-16 18:03:33 +03:00
Sergey Kandaurov c15dc73439 QUIC: optimized initial secrets key length computation.
AES-128 key length is known in compile time.
2021-06-16 17:55:57 +03:00
Sergey Kandaurov 4e89fd3673 QUIC: consistent use of 12-byte buffers in nonce computation.
All supported cipher suites produce 96-bit IV (RFC 5116, 5.1, RFC 8439, 2.3).
This eliminates a few magic numbers and run-time overhead.
2021-06-16 17:54:21 +03:00
Sergey Kandaurov 68bb1f1aa9 QUIC: consistent use of 5-byte buffers for header protection.
The output buffer is now also of 5 bytes.  Header protection uses
stream ciphers, which don't produce extra output nor PKCS padding.
2021-06-16 17:53:18 +03:00
Sergey Kandaurov 8d69124e36 QUIC: updated specification references.
This includes updating citations and further clarification.
2021-06-16 11:55:12 +03:00
Roman Arutyunyan a3b881bf6c HTTP/3: client GOAWAY support. 2021-06-11 13:24:24 +03:00
Roman Arutyunyan 5ad55a50c9 HTTP/3: generate more H3_FRAME_UNEXPECTED.
As per quic-http-34, these are the cases when this error should be generated:

   If an endpoint receives a second SETTINGS frame
   on the control stream, the endpoint MUST respond with a connection
   error of type H3_FRAME_UNEXPECTED

   SETTINGS frames MUST NOT be sent on any stream other than the control
   stream.  If an endpoint receives a SETTINGS frame on a different
   stream, the endpoint MUST respond with a connection error of type
   H3_FRAME_UNEXPECTED.

   A client MUST NOT send a PUSH_PROMISE frame.  A server MUST treat the
   receipt of a PUSH_PROMISE frame as a connection error of type
   H3_FRAME_UNEXPECTED; see Section 8.

   The MAX_PUSH_ID frame is always sent on the control stream.  Receipt
   of a MAX_PUSH_ID frame on any other stream MUST be treated as a
   connection error of type H3_FRAME_UNEXPECTED.

   Receipt of an invalid sequence of frames MUST be treated as a
   connection error of type H3_FRAME_UNEXPECTED; see Section 8.  In
   particular, a DATA frame before any HEADERS frame, or a HEADERS or
   DATA frame after the trailing HEADERS frame, is considered invalid.

   A CANCEL_PUSH frame is sent on the control stream.  Receiving a
   CANCEL_PUSH frame on a stream other than the control stream MUST be
   treated as a connection error of type H3_FRAME_UNEXPECTED.

   The GOAWAY frame is always sent on the control stream.
2021-06-11 12:11:08 +03:00
Roman Arutyunyan 7d9375245d HTTP/3: reordered H3_MISSING_SETTINGS and H3_FRAME_UNEXPECTED.
The quic-http-34 is ambiguous as to what error should be generated for the
first frame in control stream:

   Each side MUST initiate a single control stream at the beginning of
   the connection and send its SETTINGS frame as the first frame on this
   stream.  If the first frame of the control stream is any other frame
   type, this MUST be treated as a connection error of type
   H3_MISSING_SETTINGS.

   If a DATA frame is received on a control stream, the recipient MUST
   respond with a connection error of type H3_FRAME_UNEXPECTED.

   If a HEADERS frame is received on a control stream, the recipient MUST
   respond with a connection error of type H3_FRAME_UNEXPECTED.

Previously, H3_FRAME_UNEXPECTED had priority, but now H3_MISSING_SETTINGS has.
The arguments in the spec sound more compelling for H3_MISSING_SETTINGS.
2021-06-11 10:56:51 +03:00
Vladimir Homutov 03dd5599cd QUIC: improved errors readability. 2021-06-10 23:17:51 +03:00
Vladimir Homutov 03f59dd9f9 QUIC: persistent congestion calculation.
According to RFC 9002 (quic-recovery) 7.6.
2021-06-09 15:11:43 +03:00
Roman Arutyunyan cd7eb8fb5c QUIC: stream flow control refactored.
- Function ngx_quic_control_flow() is introduced.  This functions does
both MAX_DATA and MAX_STREAM_DATA flow controls.  The function is called
from STREAM and RESET_STREAM frame handlers.  Previously, flow control
was only accounted for STREAM.  Also, MAX_DATA flow control was not accounted
at all.

- Function ngx_quic_update_flow() is introduced.  This function advances flow
control windows and sends MAX_DATA/MAX_STREAM_DATA.  The function is called
from RESET_STREAM frame handler, stream cleanup handler and stream recv()
handler.
2021-06-07 10:12:46 +03:00
Maxim Dounin b1d9e940d1 Fixed SSL logging with lingering close.
Recent fixes to SSL shutdown with lingering close (554c6ae25ffc, 1.19.5)
broke logging of SSL variables.  To make sure logging of SSL variables
works properly, avoid freeing c->ssl when doing an SSL shutdown before
lingering close.

Reported by Reinis Rozitis
(http://mailman.nginx.org/pipermail/nginx/2021-May/060670.html).
2021-06-01 17:37:51 +03:00
Maxim Dounin 82ef446f7e SSL: ngx_ssl_shutdown() rework.
Instead of calling SSL_free() with each return point, introduced a single
place where cleanup happens.  As a positive side effect, this fixes two
potential memory leaks on ngx_handle_read_event() and ngx_handle_write_event()
errors where there were no SSL_free() calls (though unlikely practical,
as errors there are only expected to happen due to bugs or kernel issues).
2021-06-01 17:37:49 +03:00
Sergey Kandaurov 1c80b63a7e HTTP/3: undo 5a92523e50d3 after parser refactoring (e1eb7f4ca9f1).
This is no longer needed after HTTP/3 request processing has moved
into its own function ngx_http_v3_process_header().
2021-06-01 12:02:08 +03:00
Sergey Kandaurov 7181dd0571 HTTP/3: fixed parsing encoder insertions with empty header value.
When starting processing a new encoder instruction, the header state is not
memzero'ed because generally it's burdensome.  If the header value is empty,
this resulted in inserting a stale value left from the previous instruction.

Based on a patch by Zhiyong Sun.
2021-06-01 11:41:38 +03:00
Sergey Kandaurov 5572c38e66 HTTP/3: removed $http3 that served its purpose.
To specify final protocol version by hand:

    add_header Alt-Svc h3=":443";
2021-05-31 11:54:47 +03:00
Gena Makhomed 44cdd2749d Contrib: vim syntax, update core and 3rd party module directives. 2021-05-30 12:26:00 +03:00
Maxim Dounin cb924c452e Core: disabled SO_REUSEADDR on UDP sockets while testing config.
On Linux, SO_REUSEADDR allows completely duplicate UDP sockets, so using
SO_REUSEADDR when testing configuration results in packets being dropped
if there is an existing traffic on the sockets being tested (ticket #2187).
While dropped packets are expected with UDP, it is better to avoid this
when possible.

With this change, SO_REUSEADDR is no longer set on datagram sockets when
testing configuration.
2021-05-31 16:36:51 +03:00
Maxim Dounin c5072fb194 Core: disabled cloning sockets when testing config (ticket #2188).
Since we anyway do not set SO_REUSEPORT when testing configuration
(see ecb5cd305b06), trying to open additional sockets does not make much
sense, as all these additional sockets are expected to result in EADDRINUSE
errors from bind().  On the other hand, there are reports that trying
to open these sockets takes significant time under load: total configuration
testing time greater than 15s was observed in ticket #2188, compared to less
than 1s without load.

With this change, no additional sockets are opened during testing
configuration.
2021-05-31 16:36:37 +03:00
Maxim Dounin 9ee9eaeb9e Version bump. 2021-05-31 16:36:12 +03:00
Sergey Kandaurov 6fae135f9a README: updated after QUIC RFC publication, nginx 1.21 rebase. 2021-05-28 13:45:09 +03:00
Sergey Kandaurov a3e072bf8b Merged with the default branch. 2021-05-28 13:33:08 +03:00
Sergey Kandaurov 1d599c463a HTTP/3: fixed Insert With Name Reference index processing.
Based on a patch by Zhiyong Sun.
2021-05-27 13:29:00 +03:00
Roman Arutyunyan adca608327 QUIC: call stream read handler on new data arrival.
This was broken in b3f6ad181df4.
2021-05-26 13:07:06 +03:00
Roman Arutyunyan b5dab0b4c3 QUIC: make sure stream data size is lower than final size.
As per quic-transport 34, FINAL_SIZE_ERROR is generated if an endpoint received
a STREAM frame or a RESET_STREAM frame containing a final size that was lower
than the size of stream data that was already received.
2021-05-25 16:41:59 +03:00
Maxim Dounin 78036197d0 release-1.21.0 tag 2021-05-25 15:28:56 +03:00
Maxim Dounin 63edf40187 nginx-1.21.0-RELEASE 2021-05-25 15:28:55 +03:00
Maxim Dounin e7307ac138 Resolver: explicit check for compression pointers in question.
Since nginx always uses exactly one entry in the question section of
a DNS query, and never uses compression pointers in this entry, parsing
of a DNS response in ngx_resolver_process_response() does not expect
compression pointers to appear in the question section of the DNS
response.  Indeed, compression pointers in the first name of a DNS response
hardly make sense, do not seem to be allowed by RFC 1035 (which says
"a pointer to a prior occurance of the same name", note "prior"), and
were never observed in practice.

Added an explicit check to ngx_resolver_process_response()'s parsing
of the question section to properly report an error if compression pointers
nevertheless appear in the question section.
2021-05-25 15:17:50 +03:00
Maxim Dounin 77417955b5 Resolver: simplified ngx_resolver_copy().
Instead of checking on each label if we need to place a dot or not,
now it always adds a dot after a label, and reduces the resulting
length afterwards.
2021-05-25 15:17:45 +03:00
Maxim Dounin 8767b94299 Resolver: reworked ngx_resolver_copy() copy loop.
To make the code easier to read, reworked the ngx_resolver_copy()
copy loop to match the one used to calculate length.  No functional
changes.
2021-05-25 15:17:43 +03:00
Maxim Dounin 7f801ed7c0 Resolver: fixed label types handling in ngx_resolver_copy().
Previously, anything with any of the two high bits set were interpreted
as compression pointers.  This is incorrect, as RFC 1035 clearly states
that "The 10 and 01 combinations are reserved for future use".  Further,
the 01 combination is actually allocated for EDNS extended label type
(see RFC 2671 and RFC 6891), not really used though.

Fix is to reject unrecognized label types rather than misinterpreting
them as compression pointers.
2021-05-25 15:17:41 +03:00
Maxim Dounin a9387cea24 Resolver: fixed off-by-one read in ngx_resolver_copy().
It is believed to be harmless, and in the worst case it uses some
uninitialized memory as a part of the compression pointer length,
eventually leading to the "name is out of DNS response" error.
2021-05-25 15:17:38 +03:00
Maxim Dounin ad2589eac2 Resolver: fixed off-by-one write in ngx_resolver_copy().
Reported by Luis Merino, Markus Vervier, Eric Sesterhenn, X41 D-Sec GmbH.
2021-05-25 15:17:36 +03:00
Roman Arutyunyan f3b1e134a9 QUIC: refactored CRYPTO and STREAM buffer ordering.
Generic function ngx_quic_order_bufs() is introduced.  This function creates
and maintains a chain of buffers with holes.  Holes are marked with b->sync
flag.  Several buffers and holes in this chain may share the same underlying
memory buffer.

When processing STREAM frames with this function, frame data is copied only
once to the right place in the stream input chain.  Previously data could
be copied twice.  First when buffering an out-of-order frame data, and then
when filling stream buffer from ordered frame queue.  Now there's only one
data chain for both tasks.
2021-05-25 13:55:12 +03:00
Ruslan Ermilov 7787dc08c8 Location header escaping in redirects (ticket #882).
The header is escaped in redirects based on request URI or
location name (auto redirect).
2021-05-24 21:55:20 +03:00
Maxim Dounin ccf97afa71 Fixed log action when using SSL certificates with variables.
When variables are used in ssl_certificate or ssl_certificate_key, a request
is created in the certificate callback to evaluate the variables, and then
freed.  Freeing it, however, updates c->log->action to "closing request",
resulting in confusing error messages like "client timed out ... while
closing request" when a client times out during the SSL handshake.

Fix is to restore c->log->action after calling ngx_http_free_request().
2021-05-24 18:23:42 +03:00
Sergey Kandaurov ee4e5edf35 QUIC: unroll and inline ngx_quic_varint_len()/ngx_quic_build_int().
According to profiling, those two are among most frequently called,
so inlining is generally useful, and unrolling should help with it.
Further, this fixes undefined behaviour seen with invalid values.

Inspired by Yu Liu.
2021-05-22 18:40:45 +03:00
Ruslan Ermilov d7617ab6fe Stream: the "fastopen" parameter of the "listen" directive.
Based on a patch by Anbang Wen.
2021-05-20 19:59:16 +03:00
Ruslan Ermilov 1007da6550 Core: fixed comment about msie_refresh escaping.
After 12a656452ad1, the "%" character is no longer escaped by
ngx_escape_uri(NGX_ESCAPE_REFRESH).
2021-05-19 16:24:13 +03:00
Maxim Dounin d326c76aae Mail: max_errors directive.
Similarly to smtpd_hard_error_limit in Postfix and smtp_max_unknown_commands
in Exim, specifies the number of errors after which the connection is closed.
2021-05-19 03:13:31 +03:00
Maxim Dounin ac3cf225a5 Mail: IMAP pipelining support.
The change is mostly the same as the SMTP one (04e43d03e153 and 3f5d0af4e40a),
and ensures that nginx is able to properly handle or reject multiple IMAP
commands.  The s->cmd field is not really used and set for consistency.

Non-synchronizing literals handling in invalid/unknown commands is limited,
so when a non-synchronizing literal is detected at the end of a discarded
line, the connection is closed.
2021-05-19 03:13:28 +03:00
Maxim Dounin 0021187890 Mail: stricter checking of IMAP tags.
Only "A-Za-z0-9-._" characters now allowed (which is stricter than what
RFC 3501 requires, but expected to be enough for all known clients),
and tags shouldn't be longer than 32 characters.
2021-05-19 03:13:26 +03:00
Maxim Dounin 92253f5878 Mail: fixed backslash handling in IMAP literals.
Previously, s->backslash was set if any of the arguments was a quoted
string with a backslash character.  After successful command parsing
this resulted in all arguments being filtered to remove backslashes.
This is, however, incorrect, as backslashes should not be removed from
IMAP literals.  For example:

   S: * OK IMAP4 ready
   C: a01 login {9}
   S: + OK
   C: user\name "pass\"word"
   S: * BAD internal server error

resulted in "Auth-User: username" instead of "Auth-User: user\name"
as it should.

Fix is to apply backslash filtering on per-argument basis during parsing.
2021-05-19 03:13:23 +03:00
Maxim Dounin 8130c4e2ca Mail: removed dead s->arg_start handling.
As discussed in the previous change, s->arg_start handling in the "done"
labels of ngx_mail_pop3_parse_command(), ngx_mail_imap_parse_command(),
and ngx_mail_smtp_parse_command() is wrong: s->arg_start cannot be
set there, as it is handled and cleared on all code paths where the
"done" labels are reached.  The relevant code is dead and now removed.
2021-05-19 03:13:22 +03:00
Maxim Dounin b0b3391617 Mail: fixed s->arg_start clearing on invalid IMAP commands.
Previously, s->arg_start was left intact after invalid IMAP commands,
and this might result in an argument incorrectly added to the following
command.  Similarly, s->backslash was left intact as well, leading
to unneeded backslash removal.

For example (LFs from the client are explicitly shown as "<LF>"):

  S: * OK IMAP4 ready
  C: a01 login "\<LF>
  S: a01 BAD invalid command
  C: a0000000000\2 authenticate <LF>
  S: a00000000002 aBAD invalid command

The backslash followed by LF generates invalid command with s->arg_start
and s->backslash set, the following command incorrectly treats anything
from the old s->arg_start to the space after the command as an argument,
and removes the backslash from the tag.  If there is no space, s->arg_end
will be NULL.

Both things seem to be harmless though.  In particular:

- This can be used to provide an incorrect argument to a command without
  arguments.  The only command which seems to look at the single argument
  is AUTHENTICATE, and it checks the argument length before trying to
  access it.

- Backslash removal uses the "end" pointer, and stops due to "src < end"
  condition instead of scanning all the process memory if s->arg_end is
  NULL (and arg[0].len is huge).

- There should be no backslashes in unquoted strings.

An obvious fix is to clear s->arg_start and s->backslash on invalid commands,
similarly to how it is done in POP3 parsing (added in 810:e3aa8f305d21) and
SMTP parsing.

This, however, makes it clear that s->arg_start handling in the "done"
label is wrong: s->arg_start cannot be legitimately set there, as it
is expected to be cleared in all possible cases when the "done" label is
reached.  The relevant code is dead and will be removed by the following
change.
2021-05-19 03:13:20 +03:00
Maxim Dounin 65d69a19a7 Mail: POP3 pipelining support.
The change is mostly the same as the SMTP one (04e43d03e153 and 3f5d0af4e40a),
and ensures that nginx is able to properly handle or reject multiple POP3
commands, as required by the PIPELINING capability (RFC 2449).  The s->cmd
field is not really used and set for consistency.
2021-05-19 03:13:18 +03:00
Maxim Dounin 2de54c2867 Mail: optimized discarding invalid SMTP commands.
There is no need to scan buffer from s->buffer->pos, as we already scanned
the buffer till "p" and wasn't able to find an LF.

There is no real need for this change in SMTP, since it is at most a
microoptimization of a non-common code path.  Similar code in IMAP, however,
will have to start scanning from "p" to be correct, since there can be
newlines in IMAP literals.
2021-05-19 03:13:17 +03:00
Maxim Dounin 29532d2781 Mail: fixed handling of invalid SMTP commands split between reads.
Previously, if an invalid SMTP command was split between reads, nginx failed
to wait for LF before returning an error, and interpreted the rest of the
command received later as a separate command.

The sw_invalid state in ngx_mail_smtp_parse_command(), introduced in
04e43d03e153, did not work, since ngx_mail_smtp_auth_state() clears
s->state when returning an error due to NGX_MAIL_PARSE_INVALID_COMMAND.
And not clearing s->state will introduce another problem: the rest
of the command would trigger duplicate error when rest of the command is
received.

Fix is to return NGX_AGAIN from ngx_mail_smtp_parse_command() until full
command is received.
2021-05-19 03:13:15 +03:00
Maxim Dounin c511a147a1 Mail: fixed SMTP pipelining to send the response immediately.
Previously, if there were some pipelined SMTP data in the buffer when
a proxied connection with the backend was established, nginx called
ngx_mail_proxy_handler() to send these data, and not tried to send the
response to the last command.  In most cases, this response was later sent
along with the response to the pipelined command, but if for some reason
client decides to wait for the response before finishing the next command
this might result in a connection hang.

Fix is to always call ngx_mail_proxy_handler() to send the response, and
additionally post an event to send the pipelined data if needed.
2021-05-19 03:13:12 +03:00
Roman Arutyunyan 69441d941a HTTP/3: fixed server push after 9ec3e71f8a61.
When using server push, a segfault occured because
ngx_http_v3_create_push_request() accessed ngx_http_v3_session_t object the old
way.  Prior to 9ec3e71f8a61, HTTP/3 session was stored directly in c->data.
Now it's referenced by the v3_session field of ngx_http_connection_t.
2021-05-18 18:17:25 +03:00
Maxim Dounin e2a831a163 MIME: added application/wasm type (ticket #1606). 2021-05-08 20:31:03 +03:00
Maxim Dounin fa5cba0bfc Upstream: variables support in certificates. 2021-05-06 02:22:09 +03:00
Maxim Dounin fa435bf244 Auth basic: changed alcf->user_file to be a pointer.
This saves some memory in typical case when auth_basic_user_file is not
explicitly set, and unifies the code with alcf->realm.
2021-05-06 02:22:07 +03:00
Maxim Dounin 6e1f0ee6a1 Changed complex value slots to use NGX_CONF_UNSET_PTR.
With this change, it is now possible to use ngx_conf_merge_ptr_value()
to merge complex values.  This change follows much earlier changes in
ngx_conf_merge_ptr_value() and ngx_conf_set_str_array_slot()
in 1452:cd586e963db0 (0.6.10) and 1701:40d004d95d88 (0.6.22), and the
change in ngx_conf_set_keyval_slot() (7728:485dba3e2a01, 1.19.4).

To preserve compatibility with existing 3rd party modules, both NULL
and NGX_CONF_UNSET_PTR are accepted for now.
2021-05-06 02:22:03 +03:00
Roman Arutyunyan 49e955c402 QUIC: generic buffering for stream input.
Previously each stream had an input buffer.  Now memory is allocated as
bytes arrive.  Generic buffering mechanism is used for this.
2021-05-05 17:15:20 +03:00
Sergey Kandaurov 5426ba6412 QUIC: simplified sending 1-RTT only frames. 2021-05-05 19:32:49 +03:00
Vladimir Homutov b775ee18c1 QUIC: relaxed client id requirements.
Client IDs cannot be reused on different paths.  This change allows to reuse
client id previosly seen on the same path (but with different dcid) in case
when no unused client IDs are available.
2021-05-05 18:11:55 +03:00
Vladimir Homutov 3412185e83 QUIC: consider NEW_CONNECTION_ID a probing frame.
According to quic-transport, 9.1:

   PATH_CHALLENGE, PATH_RESPONSE, NEW_CONNECTION_ID, and PADDING frames
   are "probing frames", and all other frames are "non-probing frames".
2021-05-06 12:36:14 +03:00
Roman Arutyunyan c0766c7e56 HTTP/3: clean up table from session cleanup handler.
Previously table had a separate cleanup handler.
2021-04-28 11:30:27 +03:00
Roman Arutyunyan c79e86564d HTTP/3: moved session initialization to a separate file.
Previously it was in ngx_http_v3_streams.c, but it's unrelated to streams.
2021-05-05 15:15:48 +03:00
Roman Arutyunyan 2afd4c612e HTTP/3: separate header files for existing source files. 2021-05-05 15:09:23 +03:00
Roman Arutyunyan a830f1da3b HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Previously it was parsed in ngx_http_v3_streams.c, while the streams were
parsed in ngx_http_v3_parse.c.  Now all parsing is done in one file.  This
simplifies parsing API and cleans up ngx_http_v3_streams.c.
2021-05-05 15:00:17 +03:00
Roman Arutyunyan 65121fd06d HTTP/3: renamed ngx_http_v3_client_XXX() functions.
The functions are renamed to ngx_http_v3_send_XXX() similar to
ngx_http_v3_send_settings() and ngx_http_v3_send_goaway().
2021-04-27 21:32:50 +03:00
Roman Arutyunyan 193e598f14 HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t. 2021-05-05 12:54:10 +03:00
Roman Arutyunyan 968daa6a69 HTTP/3: reference h3c directly from ngx_http_connection_t.
Previously, an ngx_http_v3_connection_t object was created for HTTP/3 and
then assinged to c->data instead of the generic ngx_http_connection_t object.
Now a direct reference is added to ngx_http_connection_t, which is less
confusing and does not require a flag for http3.
2021-05-05 14:53:36 +03:00
Roman Arutyunyan 041da3d5a7 HTTP/3: ngx_http_v3_get_session() macro.
It's used instead of accessing c->quic->parent->data directly.  Apart from being
simpler, it allows to change the way session is stored in the future by changing
the macro.
2021-04-30 19:10:11 +03:00
Roman Arutyunyan c3a7f51abf HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c. 2021-05-05 15:15:17 +03:00
Roman Arutyunyan c6227e3ae2 HTTP/3: fixed decoder stream stubs.
Now ngx_http_v3_ack_header() and ngx_http_v3_inc_insert_count() always generate
decoder error.  Our implementation does not use dynamic tables and does not
expect client to send Section Acknowledgement or Insert Count Increment.

Stream Cancellation, on the other hand, is allowed to be sent anyway.  This is
why ngx_http_v3_cancel_stream() does not return an error.
2021-05-04 13:38:59 +03:00
Roman Arutyunyan f4175aae92 HTTP/3: reject empty DATA and HEADERS frames on control stream.
Previously only non-empty frames were rejected.
2021-05-05 13:28:05 +03:00
Vladimir Homutov 55e67f217a QUIC: fixed build with NGX_QUIC_DEBUG_ALLOC enabled. 2021-04-28 13:37:18 +03:00
Vladimir Homutov 543d528973 QUIC: connection migration.
The patch adds proper transitions between multiple networking addresses that
can be used by a single quic connection. New networking paths are validated
using PATH_CHALLENGE/PATH_RESPONSE frames.
2021-04-29 15:35:02 +03:00
Ruslan Ermilov 67efb01d4c Restored zeroing of ngx_channel_t in ngx_pass_open_channel().
Due to structure's alignment, some uninitialized memory contents may have
been passed between processes.

Zeroing was removed in 0215ec9aaa8a.

Reported by Johnny Wang.
2021-04-22 16:12:52 +03:00
Vladimir Homutov c257acfe21 HTTP/3: adjusted control stream parsing.
7.2.1:
   If a DATA frame is received on a control stream, the recipient MUST
   respond with a connection error of type H3_FRAME_UNEXPECTED;

7.2.2:
   If a HEADERS frame is received on a control stream, the recipient MUST
   respond with a connection error (Section 8) of type H3_FRAME_UNEXPECTED.
2021-04-22 13:49:18 +03:00
Maxim Dounin 70bd2beda2 Mail: fixed reading with fully filled buffer (ticket #2159).
With SMTP pipelining, ngx_mail_read_command() can be called with s->buffer
without any space available, to parse additional commands received to the
buffer on previous calls.  Previously, this resulted in recv() being called
with zero length, resulting in zero being returned, which was interpreted
as a connection close by the client, so nginx silently closed connection.

Fix is to avoid calling c->recv() if there is no free space in the buffer,
but continue parsing of the already received commands.
2021-04-21 23:24:59 +03:00
Maxim Dounin 27cfa45999 Version bump. 2021-04-21 23:24:48 +03:00
Roman Arutyunyan 26ce781c5b QUIC: renamed stream variables from sn to qs.
Currently both names are used which is confusing.  Historically these were
different objects, but now it's the same one.  The name qs (quic stream) makes
more sense than sn (stream node).
2021-04-19 17:25:56 +03:00
Roman Arutyunyan 91367fa2e1 QUIC: renamed stream field from c to connection. 2021-04-19 17:21:07 +03:00
Sergey Kandaurov d8d491bf6a QUIC: fixed permitted packet types for PATH_RESPONSE.
PATH_RESPONSE was explicitly forbidden in 0-RTT since at least draft-22, but
the Frame Types table was not updated until recently while in IESG evaluation.
2021-04-16 23:03:59 +03:00
Vladimir Homutov 977a00685d QUIC: added missing checks for limits in stream frames parsing. 2021-04-19 09:46:37 +03:00
Vladimir Homutov 4f66362f15 QUIC: fixed parsing of unknown frame types.
The ngx_quic_frame_allowed() function only expects known frame types.
2021-04-19 11:36:41 +03:00
Vladimir Homutov b49ac616a9 QUIC: avoid sending extra frames in case of error. 2021-04-15 12:17:19 +03:00
Maxim Dounin a048942864 release-1.19.10 tag 2021-04-13 18:13:59 +03:00
Maxim Dounin 40dc7785d1 nginx-1.19.10-RELEASE 2021-04-13 18:13:58 +03:00
Sergey Kandaurov 30de7c444d QUIC: normalize header inclusion.
Stop including QUIC headers with no user-serviceable parts inside.
This allows to provide a much cleaner QUIC interface.  To cope with that,
ngx_quic_derive_key() is now explicitly exported for v3 and quic modules.
Additionally, this completely hides the ngx_quic_keys_t internal type.
2021-04-13 12:38:34 +03:00
Sergey Kandaurov cab188a0a1 QUIC: ngx_quic_frames_stream_t made opaque. 2021-04-13 11:49:52 +03:00
Vladimir Homutov 0d1149dce5 QUIC: separate files for SSL library interfaces. 2021-04-14 14:47:04 +03:00
Vladimir Homutov 47575035a0 QUIC: separate files for tokens related processing. 2021-04-13 14:41:52 +03:00
Vladimir Homutov a737b266cb QUIC: separate files for output and ack related processing. 2021-04-13 14:41:20 +03:00
Vladimir Homutov ef1bf4102f QUIC: separate files for stream related processing. 2021-04-13 14:40:00 +03:00
Vladimir Homutov 062d66b818 QUIC: separate files for frames related processing. 2021-04-13 14:38:46 +03:00
Vladimir Homutov 4106995b34 QUIC: separate files for connection id related processing. 2021-04-13 14:37:41 +03:00
Vladimir Homutov 0da176b67b QUIC: headers cleanup.
The "ngx_event_quic.h" header file now contains only public definitions,
used by modules.  All internal definitions are moved into
the "ngx_event_quic_connection.h" header file.
2021-04-14 14:47:37 +03:00
Vladimir Homutov 32244fabef QUIC: separate function for connection ids initialization.
The function correctly cleans up resources in case of failure to create
initial server id: it removes previously created udp node for odcid from
listening rbtree.
2021-04-09 11:33:10 +03:00
Maxim Dounin e58ea4728b Changed keepalive_requests default to 1000 (ticket #2155).
It turns out no browsers implement HTTP/2 GOAWAY handling properly, and
large enough number of resources on a page results in failures to load
some resources.  In particular, Chrome seems to experience errors if
loading of all resources requires more than 1 connection (while it
is usually able to retry requests at least once, even with 2 connections
there are occasional failures for some reason), Safari if loading requires
more than 3 connections, and Firefox if loading requires more than 10
connections (can be configured with network.http.request.max-attempts,
defaults to 10).

It does not seem to be possible to resolve this on nginx side, even strict
limiting of maximum concurrency does not help, and loading issues seems to
be triggered by merely queueing of a request for a particular connection.
The only available mitigation seems to use higher keepalive_requests value.

The new default is 1000 and matches previously used default for
http2_max_requests.  It is expected to be enough for 99.98% of the pages
(https://httparchive.org/reports/state-of-the-web?start=latest#reqTotal)
even in Chrome.
2021-04-08 00:16:30 +03:00
Maxim Dounin 444fbf3091 Added $connection_time variable. 2021-04-08 00:16:17 +03:00
Maxim Dounin abd21d3202 Introduced the "keepalive_time" directive.
Similar to lingering_time, it limits total connection lifetime before
keepalive is switched off.  The default is 1 hour, which is close to
the total maximum connection lifetime possible with default
keepalive_requests and keepalive_timeout.
2021-04-08 00:15:48 +03:00
Vladimir Homutov 27968b8458 QUIC: fixed ngx_quic_send_ack_range() function.
Created frame was not added to the output queue.
2021-04-07 13:09:26 +03:00
Maxim Dounin ef20419dff HTTP/2: relaxed PRIORITY frames limit.
Firefox uses several idle streams for PRIORITY frames[1], and
"http2_max_concurrent_streams 1;" results in "client sent too many
PRIORITY frames" errors when a connection is established by Firefox.

Fix is to relax the PRIORITY frames limit to use at least 100 as
the initial value (which is the recommended by the HTTP/2 protocol
minimum limit on the number of concurrent streams, so it is not
unreasonable for clients to assume that similar number of idle streams
can be used for prioritization).

[1] https://hg.mozilla.org/mozilla-central/file/32a9e6e145d6e3071c3993a20bb603a2f388722b/netwerk/protocol/http/Http2Stream.cpp#l1270
2021-04-07 02:03:29 +03:00
Maxim Dounin 78210f7045 Configure: fixed --test-build-epoll on FreeBSD 13.
In FreeBSD 13, eventfd(2) was added, and this breaks build
with --test-build-epoll and without --with-file-aio.  Fix is
to move eventfd(2) detection to auto/os/linux, as it is used
only on Linux as a notification mechanism for epoll().
2021-04-05 20:14:16 +03:00
Vladimir Homutov c182a5db6c QUIC: fixed debug message macro. 2021-04-05 11:35:46 +03:00
Vladimir Homutov 3cc73c257d QUIC: added error codes and messages from latest drafts.
The AEAD_LIMIT_REACHED was addeded in draft-31.
The NO_VIABLE_PATH was added in draft-33.
2021-04-05 11:31:03 +03:00
Sergey Kandaurov 73b9640ea3 HTTP/3: keepalive_time support. 2021-04-16 19:42:03 +03:00
Sergey Kandaurov df562f3cb1 Merged with the default branch. 2021-04-16 19:35:55 +03:00
Sergey Kandaurov ecbde796e8 HTTP/3: removed h3scf->quic leftover after 0d2b2664b41c. 2021-04-12 12:30:30 +03:00
Sergey Kandaurov 43052283fe QUIC: fixed memory leak in ngx_hkdf_extract()/ngx_hkdf_expand().
This fixes leak on successful path when built with OpenSSL.
2021-04-07 15:14:41 +03:00
Maxim Dounin 07264de85b Gzip: updated handling of zlib variant from Intel.
In current versions (all versions based on zlib 1.2.11, at least
since 2018) it no longer uses 64K hash and does not force window
bits to 13 if it is less than 13.  That is, it needs just 16 bytes
more memory than normal zlib, so these bytes are simply added to
the normal size calculation.
2021-04-05 04:07:17 +03:00
Maxim Dounin 4a8617e18f Gzip: support for zlib-ng. 2021-04-05 04:06:58 +03:00
Maxim Dounin 451a1c7321 Version bump. 2021-04-05 04:03:10 +03:00
Maxim Dounin d60562b9f2 release-1.19.9 tag 2021-03-30 17:47:11 +03:00
Maxim Dounin 7ca8f7dfd4 nginx-1.19.9-RELEASE 2021-03-30 17:47:11 +03:00
Maxim Dounin d54ecf957f Updated OpenSSL used for win32 builds. 2021-03-30 17:44:36 +03:00
Maxim Dounin d8b6d2be87 Fixed handling of already closed connections.
In limit_req, auth_delay, and upstream code to check for broken
connections, tests for possible connection close by the client
did not work if the connection was already closed when relevant
event handler was set.  This happened because there were no additional
events in case of edge-triggered event methods, and read events
were disabled in case of level-triggered ones.

Fix is to explicitly post a read event if the c->read->ready flag
is set.
2021-03-28 17:45:39 +03:00
Maxim Dounin b6a48dc4cd Upstream: fixed broken connection check with eventport.
For connection close to be reported with eventport on Solaris,
ngx_handle_read_event() needs to be called.
2021-03-28 17:45:37 +03:00
Maxim Dounin 4c2e8597a2 Upstream: fixed non-buffered proxying with eventport.
For new data to be reported with eventport on Solaris,
ngx_handle_read_event() needs to be called after reading response
headers.  To do so, ngx_http_upstream_process_non_buffered_upstream()
now called unconditionally if there are no prepread data.  This
won't cause any read() syscalls as long as upstream connection
is not ready for reading (c->read->ready is not set), but will result
in proper handling of all events.
2021-03-28 17:45:35 +03:00
Maxim Dounin f11c96f175 Resolver: added missing event handling after reading.
If we need to be notified about further events, ngx_handle_read_event()
needs to be called after a read event is processed.  Without this,
an event can be removed from the kernel and won't be reported again,
notably when using oneshot event methods, such as eventport on Solaris.

While here, error handling is also added, similar to one present in
ngx_resolver_tcp_read().  This is not expected to make a difference
and mostly added for consistency.
2021-03-28 17:45:31 +03:00
Maxim Dounin 9b5e7e3e21 Events: fixed "port_dissociate() failed" alerts with eventport.
If an attempt is made to delete an event which was already reported,
port_dissociate() returns an error.  Fix is avoid doing anything if
ev->active is not set.

Possible alternative approach would be to avoid calling ngx_del_event()
at all if ev->active is not set.  This approach, however, will require
something else to re-add the other event of the connection, since both
read and write events are dissociated if an event is reported on a file
descriptor.  Currently ngx_eventport_del_event() re-associates write
event if called to delete read event, and vice versa.
2021-03-28 17:45:29 +03:00
Maxim Dounin b3d7438ae8 Events: fixed expiration of timers in the past.
If, at the start of an event loop iteration, there are any timers
in the past (including timers expiring now), the ngx_process_events()
function is called with zero timeout, and returns immediately even
if there are no events.  But the following code only calls
ngx_event_expire_timers() if time actually changed, so this results
in nginx spinning in the event loop till current time changes.

While such timers are not expected to appear under normal conditions,
as all such timers should be removed on previous event loop iterations,
they still can appear due to bugs, zero timeouts set in the configuration
(if this is not explicitly handled by the code), or due to external
time changes on systems without clock_gettime(CLOCK_MONOTONIC).

Fix is to call ngx_event_expire_timers() unconditionally.  Calling
it on each event loop iteration is not expected to be significant from
performance point of view, especially compared to a syscall in
ngx_process_events().
2021-03-26 01:44:59 +03:00
Maxim Dounin ea9e8a2129 HTTP/2: improved handling of "keepalive_timeout 0".
Without explicit handling, a zero timer was actually added, leading to
multiple unneeded syscalls.  Further, sending GOAWAY frame early might
be beneficial for clients.

Reported by Sergey Kandaurov.
2021-03-26 01:44:57 +03:00
Sergey Kandaurov b796f4ab9e Cancel keepalive and lingering close on EOF better (ticket #2145).
Unlike in 75e908236701, which added the logic to ngx_http_finalize_request(),
this change moves it to a more generic routine ngx_http_finalize_connection()
to cover cases when a request is finalized with NGX_DONE.

In particular, this fixes unwanted connection transition into the keepalive
state after receiving EOF while discarding request body.  With edge-triggered
event methods that means the connection will last for extra seconds as set in
the keepalive_timeout directive.
2021-03-24 14:03:33 +03:00
Maxim Dounin 5c3fed9350 gRPC: fixed handling of padding on DATA frames.
The response size check introduced in 39501ce97e29 did not take into
account possible padding on DATA frames, resulting in incorrect
"upstream sent response body larger than indicated content length" errors
if upstream server used padding in responses with known length.

Fix is to check the actual size of response buffers produced by the code,
similarly to how it is done in other protocols, instead of checking
the size of DATA frames.

Reported at:
http://mailman.nginx.org/pipermail/nginx-devel/2021-March/013907.html
2021-03-23 16:52:23 +03:00
Vladimir Homutov 27b8e164cb QUIC: PATH_CHALLENGE frame creation. 2021-03-23 11:58:43 +03:00
Vladimir Homutov c994e056f8 QUIC: distinct files for connection migration.
The connection migration-related code from quic.c with dependencies is moved
into separate file.
2021-03-31 14:57:15 +03:00
Vladimir Homutov 82f778119b QUIC: separate header for ngx_quic_connection_t. 2021-03-31 14:56:16 +03:00
Vladimir Homutov 624f1ea5c9 QUIC: simplified quic connection dispatching.
Currently listener contains rbtree with multiple nodes for single QUIC
connection: each corresponding to specific server id.  Each udp node points
to same ngx_connection_t, which points to QUIC connection via c->udp field.

Thus when an event handler is called, it only gets ngx_connection_t with
c->udp pointing to QUIC connection.  This makes it hard to obtain actual
node which was used to dispatch packet (it requires to repeat DCID lookup).

Additionally, ngx_quic_connection_t->udp field is only needed to keep a
pointer in c->udp. The node is not added into the tree and does not carry
useful information.
2021-04-02 11:31:37 +03:00
Vladimir Homutov 05ea5ebae9 UDP: extended datagram context.
Sometimes it is required to process datagram properties at higher level (i.e.
QUIC is interested in source address which may change and IP options).  The
patch adds ngx_udp_dgram_t structure used to pass packet-related information
in c->udp.
2021-04-02 18:58:19 +03:00
Vladimir Homutov da2a0632dd QUIC: fixed udp buffer initialization.
The start field is used to check if the QUIC packet is first in the datagram.
This fixes stateless reset detection.
2021-03-30 14:33:43 +03:00
Roman Arutyunyan 7cac9a6096 QUIC: do not handle empty dcid.
When a QUIC datagram arrives, its DCID is never empty.  Previously, the case
of empty DCID was handled.  Now this code is simplified.
2021-03-30 14:33:47 +03:00
Roman Arutyunyan 3e4aca7509 QUIC: do not reallocate c->sockaddr.
When a connection is created, enough memory is allocated to accomodate
any future address change.
2021-03-11 15:22:18 +03:00
Roman Arutyunyan 5719790dcd QUIC: do not copy input data.
Previously, when a new datagram arrived, data were copied from the UDP layer
to the QUIC layer via c->recv() interface.  Now UDP buffer is accessed
directly.
2021-03-11 15:25:11 +03:00
Sergey Kandaurov 65beb99539 QUIC: HKDF API compatibility with OpenSSL master branch.
OpenSSL 3.0 started to require HKDF-Extract output PRK length pointer
used to represent the amount of data written to contain the length of
the key buffer before the call.  EVP_PKEY_derive() documents this.

See HKDF_Extract() internal implementation update in this change:
https://github.com/openssl/openssl/commit/5a285ad
2021-03-31 21:43:17 +03:00
Sergey Kandaurov 5fa81bbd88 Merged with the default branch. 2021-03-30 23:34:51 +03:00
Roman Arutyunyan 9548c57590 HTTP/3: fixed $connection_requests.
Previously, the value was always "1".
2021-03-15 16:25:54 +03:00
Roman Arutyunyan 227afaea32 HTTP/3: set initial_max_streams_uni default value to 3.
The maximum number of HTTP/3 unidirectional client streams we can handle is 3:
control, decode and encode.  These streams are never closed.
2021-03-22 15:51:14 +03:00
Roman Arutyunyan 529409c0a0 HTTP/3: keepalive timeout.
This timeout limits the time when no client request streams exist.
2021-03-30 16:48:38 +03:00
Roman Arutyunyan 6b36b11167 QUIC: connection shutdown.
The function ngx_quic_shutdown_connection() waits until all non-cancelable
streams are closed, and then closes the connection.  In HTTP/3 cancelable
streams are all unidirectional streams except push streams.

The function is called from HTTP/3 when client reaches keepalive_requests.
2021-03-15 16:39:33 +03:00
Roman Arutyunyan 67c58e696f HTTP/3: send GOAWAY when last request is accepted.
The last request in connection is determined according to the keepalive_requests
directive.  Requests beyond keepalive_requests are rejected.
2021-03-15 19:26:04 +03:00
Vladimir Homutov 0502cd8079 Core: fixed build with BPF on non-64bit platforms (ticket #2152). 2021-03-23 10:58:18 +03:00
Vladimir Homutov fca753b4ed QUIC: bpf code regenerated. 2021-03-16 18:17:25 +03:00
Vladimir Homutov 79d71916a4 QUIC: fixed key extraction in bpf.
In case of long header packets, dcid length was not read correctly.

While there, macros to parse uint64 was fixed as well as format specifiers
to print it in debug mode.

Thanks to Gao Yan <gaoyan09@baidu.com>.
2021-03-15 19:05:38 +03:00
Sergey Kandaurov e1aca15496 HTTP/3: do not push until a MAX_PUSH_ID frame is received.
Fixes interop with quic-go that doesn't send MAX_PUSH_ID.
2021-03-16 13:48:29 +03:00
Sergey Kandaurov 141d5113a5 QUIC: fixed hq ALPN id for the final draft.
It was an agreement to use "hq-interop"[1] for interoperability testing.

[1] https://github.com/quicwg/base-drafts/wiki/ALPN-IDs-used-with-QUIC
2021-03-16 13:48:28 +03:00
Sergey Kandaurov 1aea7657b4 QUIC: fixed expected TLS codepoint with final draft and BoringSSL.
A reasonable codepoint is always set[1] explicitly so that it doesn't
depend on the default library value that may change[2] in the future.

[1] https://boringssl.googlesource.com/boringssl/+/3d8b8c3d
[2] https://boringssl.googlesource.com/boringssl/+/c47bfce0
2021-03-16 13:48:28 +03:00
Vladimir Homutov 3603fc6b23 QUIC: added error handling to ngx_hkdf_extract()/ngx_hkdf_expand().
The OpenSSL variant of functions lacked proper error processing.
2021-03-11 14:43:01 +03:00
Ruslan Ermilov 47651d9b50 Removed "ch" argument from ngx_pass_open_channel(). 2021-03-11 09:58:45 +03:00
Maxim Dounin a86eac0ec0 Mail: fixed build without SSL.
Broken by d84f13618277 and 12ea1de7d87c (1.19.8).

Reported by Sergey Osokin.
2021-03-11 04:46:26 +03:00
Maxim Dounin 3712c41143 Version bump. 2021-03-11 04:46:22 +03:00
Sergey Kandaurov 9e0943cf32 HTTP/3: fixed server push. 2021-03-10 17:56:34 +03:00
Sergey Kandaurov 6757269a6f Merged with the default branch. 2021-03-10 15:39:01 +03:00
Maxim Dounin a85580ed30 release-1.19.8 tag 2021-03-09 18:27:51 +03:00
Maxim Dounin 6f73a2820c nginx-1.19.8-RELEASE 2021-03-09 18:27:50 +03:00
Maxim Dounin 685ce3a4e8 Updated OpenSSL used for win32 builds. 2021-03-09 16:38:55 +03:00
Sergey Kandaurov 8dfe492b99 README: http3_max_field_size was removed in ae2e68f206f9. 2021-03-07 00:23:25 +03:00
Sergey Kandaurov efd5719654 README: bump browsers' version after 81bb3a690c10 (old drafts rip). 2021-03-07 00:23:23 +03:00
Maxim Dounin 00ef7bd79a Mail: sending of the PROXY protocol to backends.
Activated with the "proxy_protocol" directive.  Can be combined with
"listen ... proxy_protocol;" and "set_real_ip_from ...;" to pass
client address provided to nginx in the PROXY protocol header.
2021-03-05 17:16:32 +03:00
Maxim Dounin 4b2da5d364 Mail: realip module.
When configured with the "set_real_ip_from", it can set client's IP
address as visible in logs to the one obtained via the PROXY protocol.
2021-03-05 17:16:29 +03:00
Maxim Dounin aa60a47253 Mail: parsing of the PROXY protocol from clients.
Activated with the "proxy_protocol" parameter of the "listen" directive.
Obtained information is passed to the auth_http script in Proxy-Protocol-Addr,
Proxy-Protocol-Port, Proxy-Protocol-Server-Addr, and Proxy-Protocol-Server-Port
headers.
2021-03-05 17:16:24 +03:00
Maxim Dounin 05d4191476 Mail: made auth http creating request easier to extend. 2021-03-05 17:16:23 +03:00
Maxim Dounin 79523aa96d Mail: fixed log action after SSL handshake. 2021-03-05 17:16:20 +03:00
Maxim Dounin 189fcceb07 Mail: postponed session initialization under accept mutex.
Similarly to 40e8ce405859 in the stream module, this reduces the time
accept mutex is held.  This also simplifies following changes to
introduce PROXY protocol support.
2021-03-05 17:16:19 +03:00
Maxim Dounin 41c0e54f68 Mail: added missing event handling after reading data.
If we need to be notified about further events, ngx_handle_read_event()
needs to be called after a read event is processed.  Without this,
an event can be removed from the kernel and won't be reported again,
notably when using oneshot event methods, such as eventport on Solaris.

For consistency, existing ngx_handle_read_event() call removed from
ngx_mail_read_command(), as this call only covers one of the code paths
where ngx_mail_read_command() returns NGX_AGAIN.  Instead, appropriate
processing added to the callers, covering all code paths where NGX_AGAIN
is returned.
2021-03-05 17:16:17 +03:00
Maxim Dounin 7a6f694d81 Mail: added missing event handling after blocking events.
As long as a read event is blocked (ignored), ngx_handle_read_event()
needs to be called to make sure no further notifications will be
triggered when using level-triggered event methods, such as select() or
poll().
2021-03-05 17:16:16 +03:00
Maxim Dounin a607e281b8 Events: fixed eventport handling in ngx_handle_read_event().
The "!rev->ready" test seems to be a typo, introduced in the original
commit (719:f30b1a75fd3b).  The ngx_handle_write_event() code properly
tests for "rev->ready" instead.

Due to this typo, read events might be unexpectedly removed during
proxying after an event on the other part of the proxied connection.
Catched by mail proxying tests.
2021-03-05 17:16:15 +03:00
Maxim Dounin a079c32706 SSL: fixed build by Sun C with old OpenSSL versions.
Sun C complains about "statement not reached" if a "return" is followed
by additional statements.
2021-03-05 17:16:13 +03:00
Ruslan Ermilov 82088a5e7c Proxy: variables support in "proxy_cookie_flags" flags. 2021-03-02 00:58:24 +03:00
Maxim Dounin ae90ce6c39 Introduced strerrordesc_np() support.
The strerrordesc_np() function, introduced in glibc 2.32, provides an
async-signal-safe way to obtain error messages.  This makes it possible
to avoid copying error messages.
2021-03-01 20:00:45 +03:00
Maxim Dounin 198c29e4fa Improved maximum errno detection.
Previously, systems without sys_nerr (or _sys_nerr) were handled with an
assumption that errors start at 0 and continuous.  This is, however, not
something POSIX requires, and not true on some platforms.

Notably, on Linux, where sys_nerr is no longer available for newly linked
binaries starting with glibc 2.32, there are gaps in error list, which
used to stop us from properly detecting maximum errno.  Further, on
GNU/Hurd errors start at 0x40000001.

With this change, maximum errno detection is moved to the runtime code,
now able to ignore gaps, and also detects the first error if needed.
This fixes observed "Unknown error" messages as seen on Linux with
glibc 2.32 and on GNU/Hurd.
2021-03-01 20:00:43 +03:00
Maxim Dounin d596734983 HTTP/2: client_header_timeout before first request (ticket #2142).
With this change, behaviour of HTTP/2 becomes even closer to HTTP/1.x,
and client_header_timeout instead of keepalive_timeout is used before
the first request is received.

This fixes HTTP/2 connections being closed even before the first request
if "keepalive_timeout 0;" was used in the configuration; the problem
appeared in f790816a0e87 (1.19.7).
2021-03-01 17:31:28 +03:00
Maxim Dounin e6b3861e40 Contrib: vim syntax, default highlighting (ticket #2141).
Using default highlighting makes it possible to easily overrule
highlighting specified in the syntax file, see ":highlight-default"
in vim help for details.
2021-02-25 23:42:25 +03:00
Maxim Dounin c0a6c98343 SSL: added check for debugging.
If debugging is not enabled, there is no need to do extra work in
ngx_ssl_verify_callback() and ngx_ssl_handshake_log().
2021-02-20 18:03:04 +03:00
Maxim Dounin 4637365d07 SSL: added missed error reporting during variables evaluation. 2021-02-20 18:02:54 +03:00
Maxim Dounin 62acec7804 SSL: X509_NAME_oneline() error handling. 2021-02-20 18:02:49 +03:00
Ruslan Ermilov 161ea74858 Configure: marked top-level make targets as phony.
Reported by Thibault Nélis.
2021-02-20 12:44:26 +03:00
Ruslan Ermilov 351e3881ae Version bump. 2021-02-20 12:44:07 +03:00
Sergey Kandaurov 0ba0a2d785 Updated the list of supported drafts. 2021-02-19 17:27:41 +03:00
Sergey Kandaurov dc0b6961ad QUIC: multiple versions support.
Draft-29 and beyond are now supported simultaneously, no need to recompile.
2021-02-19 17:27:19 +03:00
Sergey Kandaurov f8942c14dc QUIC: removed support prior to draft-29. 2021-02-18 19:21:09 +03:00
Roman Arutyunyan d047870046 QUIC: set idle timer when sending an ack-eliciting packet.
As per quic-transport-34:

   An endpoint also restarts its idle timer when sending an ack-eliciting
   packet if no other ack-eliciting packets have been sent since last receiving
   and processing a packet.

Previously, the timer was set for any packet.
2021-02-18 12:22:28 +03:00
Roman Arutyunyan f9f6ded228 HTTP/3: limited client header size.
The limit is the size of all large client header buffers.  Client header size
is the total size of all client header names and values.
2021-02-17 11:58:32 +03:00
Roman Arutyunyan e33795e354 HTTP/3: introduced ngx_http_v3_parse_t structure.
The structure is used to parse an HTTP/3 request.  An object of this type is
added to ngx_http_request_t instead of h3_parse generic pointer.

Also, the new field is located outside of the request ephemeral zone to keep it
safe after request headers are parsed.
2021-02-17 15:56:34 +03:00
Maxim Dounin 808975b005 release-1.19.7 tag 2021-02-16 18:57:18 +03:00
Maxim Dounin 352fbd9879 nginx-1.19.7-RELEASE 2021-02-16 18:57:18 +03:00
Roman Arutyunyan 189d24c21b HTTP/3: removed http3_max_field_size.
Instead, size of one large_client_header_buffers buffer is used.
2021-02-16 18:50:01 +03:00
Sergey Kandaurov 9e38ab3ab3 Merged with the default branch. 2021-02-17 14:48:35 +03:00
Sergey Kandaurov 06a6c572d0 QUIC: added ability to reset a stream. 2021-02-17 14:25:07 +03:00
Sergey Kandaurov 6453aafa2c QUIC: fixed indentation. 2021-02-15 14:54:28 +03:00
Vladimir Homutov ea84e91474 QUIC: added check of client transport parameters.
Parameters sent by client are verified and defaults are set for parameters
omitted by client.
2021-02-15 14:05:46 +03:00
Maxim Dounin 1b19c11a62 HTTP/2: removed http2_max_field_size and http2_max_header_size.
Instead, size of one large_client_header_buffers buffer and all large
client header buffers are used.
2021-02-11 21:52:26 +03:00
Maxim Dounin c2b6c3b691 HTTP/2: keepalive_timeout now armed once between requests.
Previously, PINGs and other frames extended possible keepalive time,
making it possible to keep an open HTTP/2 connection for a long time.
Now the connection is always closed as long as keepalive_timeout expires,
similarly to how it happens in HTTP/1.x.

Note that as a part of this change, incomplete frames are no longer
trigger a separate timeout, so http2_recv_timeout (replaced by
client_header_timeout in previous patches) is essentially cancelled.
The client_header_timeout is, however, used for SSL handshake and
while reading HEADERS frames.
2021-02-11 21:52:24 +03:00
Maxim Dounin c4ca762238 HTTP/2: removed http2_idle_timeout and http2_max_requests.
Instead, keepalive_timeout and keepalive_requests are now used.  This
is expected to simplify HTTP/2 code and usage.  This also matches
directives used by upstream module for all protocols.

In case of default settings, this effectively changes maximum number
of requests per connection from 1000 to 100.  This looks acceptable,
especially given that HTTP/2 code now properly supports lingering close.

Further, this changes default keepalive timeout in HTTP/2 from 300 seconds
to 75 seconds.  This also looks acceptable, and larger than PING interval
used by Firefox (network.http.spdy.ping-threshold defaults to 58s),
the only browser to use PINGs.
2021-02-11 21:52:23 +03:00
Maxim Dounin 2ccd8272a4 HTTP/2: removed http2_recv_timeout.
Instead, the client_header_timeout is now used for HTTP/2 reading.
Further, the timeout is changed to be set once till no further data
left to read, similarly to how client_header_timeout is used in other
places.
2021-02-11 21:52:20 +03:00
Maxim Dounin 4193d48b97 HTTP/2: removed SPDY directives handling.
The spdy_* directives are not available since introduction of HTTP/2 module
in nginx 1.9.5 more than five years ago.
2021-02-11 21:52:19 +03:00
Maxim Dounin 489bdba758 HTTP/2: fixed reusing connections with active requests.
New connections are marked reusable by ngx_http_init_connection() if there
are no data available for reading.  As a result, if SSL is not used,
ngx_http_v2_init() might be called when the connection is marked reusable.
If a HEADERS frame is immediately available for reading, this resulted
in connection being preserved in reusable state with an active request,
and possibly closed later as if during worker shutdown (that is, after
all active requests were finalized).

Fix is to explicitly mark connections non-reusable in ngx_http_v2_init()
instead of (incorrectly) assuming they are already non-reusable.

Found by Sergey Kandaurov.
2021-02-11 21:52:17 +03:00
Maxim Dounin 13e340e407 HTTP/2: reuse of connections with incomplete frames.
Prodded by Taewoo Kim.
2021-02-11 21:52:12 +03:00
Maxim Dounin 50bb2b08c9 Additional connections reuse.
If ngx_drain_connections() fails to immediately reuse any connections
and there are no free connections, it now additionally tries to reuse
a connection again.  This helps to provide at least one free connection
in case of HTTP/2 with lingering close, where merely trying to reuse
a connection once does not free it, but makes it reusable again,
waiting for lingering close.
2021-02-11 21:52:11 +03:00
Maxim Dounin 1b7751c5cd Reuse of connections in lingering close.
This is particularly important in HTTP/2, where keepalive connections
are closed with lingering.  Before the patch, reusing a keepalive HTTP/2
connection resulted in the connection waiting for lingering close to
remain in the reusable connections queue, preventing ngx_drain_connections()
from closing additional connections.

The patch fixes it by marking the connection reusable again, and so
moving it in the reusable connections queue.  Further, it makes actually
possible to reuse such connections if needed.
2021-02-11 21:52:09 +03:00
Vladimir Homutov 966db12d9f QUIC: updated list of transport parameters to be sent.
The "max_ack_delay", "ack_delay_exponent", and "max_udp_payload_size"
transport parameters were not communicated to client.

The "disable_active_migration" and "active_connection_id_limit"
parameters were not saved into zero-rtt context.
2021-02-08 20:48:25 +03:00
Vladimir Homutov d141dfcc05 QUIC: distinguish reserved transport parameters in logging.
18.1.  Reserved Transport Parameters

     Transport parameters with an identifier of the form "31 * N + 27" for
     integer values of N are reserved to exercise the requirement that
     unknown transport parameters be ignored.  These transport parameters
     have no semantics, and can carry arbitrary values.
2021-02-10 14:10:14 +03:00
Roman Arutyunyan 9843c3f980 QUIC: send PING frames on PTO expiration.
Two PING frames are sent per level that generate two UDP datagrams.
2021-02-12 14:51:53 +03:00
Roman Arutyunyan efe90aef7e QUIC: improved setting the lost timer.
Setting the timer is brought into compliance with quic-recovery-34.  Now it's
set from a single function ngx_quic_set_lost_timer() that takes into account
both loss detection and PTO.  The following issues are fixed with this change:

- when in loss detection mode, discarding a context could turn off the
  timer forever after switching to the PTO mode
- when in loss detection mode, sending a packet resulted in rescheduling the
  timer as if it's always in the PTO mode
2021-02-12 14:40:33 +03:00
Roman Arutyunyan 1f86c95429 QUIC: disabled non-immediate ACKs for Initial and Handshake.
As per quic-transport-33:

   An endpoint MUST acknowledge all ack-eliciting Initial and Handshake
   packets immediately

If a packet carrying Initial or Handshake ACK was lost, a non-immediate ACK
should not be sent later.  Instead, client is expected to send a new packet
to acknowledge.

Sending non-immediate ACKs for Initial packets can cause the client to
generate an inflated RTT sample.
2021-02-04 20:39:47 +03:00
Roman Arutyunyan a61a82ba3b QUIC: fixed logging ACK frames.
Previously, the wrong end pointer was used, which could lead to errors
"quic failed to parse ack frame gap".
2021-02-09 14:31:36 +03:00
Vladimir Homutov 3cc96b7a82 QUIC: the "quic_host_key" directive.
The token generation in QUIC is reworked. Single host key is used to generate
all required keys of needed sizes using HKDF.

The "quic_stateless_reset_token_key" directive is removed.  Instead, the
"quic_host_key" directive is used, which reads key from file, or sets it
to random bytes if not specified.
2021-02-08 16:49:33 +03:00
Roman Arutyunyan 9927fc017c QUIC: use server ack_delay_exponent when sending ack.
Previously, client one was used.
2021-02-04 14:35:36 +03:00
Sergey Kandaurov 217682b911 QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
The flag was introduced to create type-aware CONNECTION_CLOSE frames,
and now is replaced with frame type information, directly accessible.
Notably, this fixes type logging for received frames in b3d9e57d0f62.
2021-02-03 12:39:41 +03:00
Roman Arutyunyan 7b7c606971 HTTP/3: reverted version check for keepalive flag.
The flag is used in ngx_http_finalize_connection() to switch client connection
to the keepalive mode.  Since eaea7dac3292 this code is not executed for HTTP/3
which allows us to revert the change and get back to the default branch code.
2021-02-02 15:09:48 +03:00
Roman Arutyunyan e12f2cbfbc HTTP/3: fixed format specifier. 2021-02-01 18:48:18 +03:00
Ruslan Ermilov 73f59ec675 HTTP/2: lingering close changed to handle NGX_AGAIN.
This part somehow slipped away from c5840ca2063d.

While it is not expected to be needed in case of lingering close,
it is good to keep it for correctness (see 2b5528023f6b).
2021-02-01 16:42:50 +03:00
Sergey Kandaurov 3344dfe75e Clean up trailers in ngx_http_clean_header() as well.
The function has not been updated with introduction of trailers support
in 7034:1b068a4e82d8 (1.13.2).
2021-01-26 12:39:28 +03:00
Roman Arutyunyan b56ed96a16 HTTP/3: refactored request body parser.
The change reduces diff to the default branch for
src/http/ngx_http_request_body.c.

Also, client Content-Length, if present, is now checked against the real body
size sent by client.
2021-01-25 16:16:47 +03:00
Roman Arutyunyan 8ac8479b5e QUIC: fixed stateless reset recognition and send.
Previously, if an unexpected packet was received on an existing QUIC
connection, stateless reset token was neither recognized nor sent.
2021-02-01 14:46:36 +03:00
Roman Arutyunyan b3b99f89e8 QUIC: refactored packet processing.
- split ngx_quic_process_packet() in two functions with the second one called
  ngx_quic_process_payload() in charge of decrypring and handling the payload
- renamed ngx_quic_payload_handler() to ngx_quic_handle_frames()
- moved error cleanup from ngx_quic_input() to ngx_quic_process_payload()
- moved handling closed connection from ngx_quic_handle_frames() to
  ngx_quic_process_payload()
- minor fixes
2021-01-28 12:35:18 +03:00
Vladimir Homutov d58bbb8942 QUIC: stateless retry.
Previously, quic connection object was created when Retry packet was sent.
This is neither necessary nor convenient, and contradicts the idea of retry:
protecting from bad clients and saving server resources.

Now, the connection is not created, token is verified cryptographically
instead of holding it in connection.
2021-01-29 15:53:47 +03:00
Roman Arutyunyan a1810c53c0 HTTP/3: call ngx_handle_read_event() from client header handler.
This function should be called at the end of an event handler to prepare the
event for the next handler call.  Particularly, the "active" flag is set or
cleared depending on data availability.

With this call missing in one code path, read handler was not called again
after handling the initial part of the client request, if the request was too
big to fit into a single STREAM frame.

Now ngx_handle_read_event() is called in this code path.  Also, read timer is
restarted.
2021-01-29 19:42:47 +03:00
Sergey Kandaurov 3018ec12aa README: reflect renaming of several transport parameter directives.
Reported by Kyriakos Zarifis.
2021-01-27 13:09:45 +03:00
Maxim Dounin b16c756c9e Year 2021. 2021-01-19 20:35:17 +03:00
Maxim Dounin 515aee2338 Core: removed post_accept_timeout.
Keeping post_accept_timeout in ngx_listening_t is no longer needed since
we've switched to 1 second timeout for deferred accept in 5541:fdb67cfc957d.

Further, using it in HTTP code can result in client_header_timeout being
used from an incorrect server block, notably if address-specific virtual
servers are used along with a wildcard listening socket, or if we've switched
to a different server block based on SNI in SSL handshake.
2021-01-19 20:32:00 +03:00
Maxim Dounin 91cbbe5b29 Removed incorrect optimization of HEAD requests.
The stub status module and ngx_http_send_response() (used by the empty gif
module and the "return" directive) incorrectly assumed that responding
to HEAD requests always results in r->header_only being set.  This is not
true, and results in incorrect behaviour, for example, in the following
configuration:

   location / {
       image_filter size;
       return 200 test;
   }

Fix is to remove this incorrect micro-optimization from both stub status
module and ngx_http_send_response().

Reported by Chris Newton.
2021-01-19 20:21:12 +03:00
Maxim Dounin ca5c4398af Upstream: fixed zero size buf alerts on extra data (ticket #2117).
After 7675:9afa45068b8f and 7678:bffcc5af1d72 (1.19.1), during non-buffered
simple proxying, responses with extra data might result in zero size buffers
being generated and "zero size buf" alerts in writer.  This bug is similar
to the one with FastCGI proxying fixed in 7689:da8d758aabeb.

In non-buffered mode, normally the filter function is not called if
u->length is already 0, since u->length is checked after each call of
the filter function.  There is a case when this can happen though: if
the response length is 0, and there are pre-read response body data left
after reading response headers.  As such, a check for u->length is needed
at the start of non-buffered filter functions, similar to the one
for p->length present in buffered filter functions.

Appropriate checks added to the existing non-buffered copy filters
in the upstream (used by scgi and uwsgi proxying) and proxy modules.
2021-01-12 16:59:31 +03:00
Gena Makhomed 318d14ac02 Contrib: vim syntax, update core and 3rd party module directives. 2020-12-29 13:13:57 +02:00
Maxim Dounin 7d14ffdcf0 Version bump. 2021-01-11 22:06:27 +03:00
Roman Arutyunyan 54694b3165 HTTP/3: removed HTTP/3-specific code.
The ngx_http_set_lingering_close() function is not called for HTTP/3.

The change reduces diff to the default branch.
2020-12-21 17:35:13 +00:00
Roman Arutyunyan 4fe4a1be5e HTTP/3: client header validation.
A header with the name containing null, CR, LF, colon or uppercase characters,
is now considered an error.  A header with the value containing null, CR or LF,
is also considered an error.

Also, header is considered invalid unless its name only contains lowercase
characters, digits, minus and optionally underscore.  Such header can be
optionally ignored.
2021-01-18 13:43:36 +03:00
Roman Arutyunyan 979b89029f HTTP/3: added comment. 2021-01-12 21:08:55 +00:00
Roman Arutyunyan 51d921cf70 HTTP/3: client pseudo-headers restrictions.
- :method, :path and :scheme are expected exactly once and not empty
- :method and :scheme character validation is added
- :authority cannot appear more than once
2021-01-22 15:57:41 +03:00
Roman Arutyunyan 50430c7e1d HTTP/3: refactored request parser.
The change reduces diff to the default branch for
src/http/ngx_http_request.c and src/http/ngx_http_parse.c.
2021-01-22 16:34:06 +03:00
Sergey Kandaurov feb160c9a8 QUIC: draft-33 salt and retry keys.
Notably, the version negotiation table is updated to reject draft-33/QUICv1
(which requires a new TLS codepoint) unless explicitly asked to built with.
2021-01-11 15:25:48 +03:00
Vladimir Homutov de172f3c85 QUIC: fixed header protection macro name. 2020-12-30 20:47:35 +03:00
Vladimir Homutov 5a3c80e12a QUIC: ngx_quic_bpf module.
The quic kernel bpf helper inspects packet payload for DCID, extracts key
and routes the packet into socket matching the key.

Due to reuseport feature, each worker owns a personal socket, which is
identified by the same key, used to create DCID.

BPF objects are locked in RAM and are subject to RLIMIT_MEMLOCK.
The "ulimit -l" command may be used to setup proper limits, if maps
cannot be created with EPERM or updated with ETOOLONG.
2020-12-25 15:01:15 +03:00
Maxim Dounin 02fd0972a4 release-1.19.6 tag 2020-12-15 17:41:39 +03:00
Maxim Dounin ba9e32309a nginx-1.19.6-RELEASE 2020-12-15 17:41:39 +03:00
Maxim Dounin 0608fbec68 Updated OpenSSL used for win32 builds. 2020-12-15 16:49:24 +03:00
Vladimir Homutov ff201f3fe3 Core: added interface to linux bpf() system call.
It contains wrappers for operations with BPF maps and for loading BPF programs.
2020-12-15 15:23:07 +03:00
Vladimir Homutov ca5b8fcf8e QUIC: ngx_quic_module. 2020-12-25 14:18:51 +03:00
Vladimir Homutov b16ca606b1 QUIC: moved all quic sources into src/event/quic. 2020-12-25 14:01:28 +03:00
Sergey Kandaurov e210134561 QUIC: removed unused <openssl/aes.h> inclusion.
The low-level API was used in early QUIC development.
2020-12-22 16:41:56 +03:00
Sergey Kandaurov fd9e51d00b QUIC: fixed -Wtype-limits with GCC <= 5 (ticket #2104). 2020-12-22 12:04:16 +03:00
Sergey Kandaurov 7378eed63f QUIC: fixed logging PATH_CHALLENGE/RESPONSE and build with GCC < 5. 2020-12-22 12:04:15 +03:00
Sergey Kandaurov 42780e0edc QUIC: fixed building ALPN callback without debug and http2. 2020-12-22 12:04:15 +03:00
Sergey Kandaurov b4d3563ff8 QUIC: fixed build with OpenSSL < 1.1.1.
The <openssl/kdf.h> header is available since OpenSSL 1.1.0, and HKDF API
used for separate Extract and Expand steps in TLSv1.3 - since OpenSSL 1.1.1.
2020-12-22 12:03:43 +03:00
Sergey Kandaurov 33b0a8f597 QUIC: converted to SSL_CIPHER_get_protocol_id().
This API is available in BoringSSL for quite some time:
https://boringssl.googlesource.com/boringssl/+/3743aaf
2020-12-21 15:05:43 +03:00
Sergey Kandaurov b9f5a4b8d3 HTTP/3: staticize internal parsing functions. 2020-12-16 12:47:41 +00:00
Sergey Kandaurov ebac406f83 HTTP/3: staticize ngx_http_v3_methods. 2020-12-16 12:47:38 +00:00
Sergey Kandaurov 0767813576 Merged with the default branch. 2020-12-15 16:55:43 +00:00
Maxim Dounin 3b6b7483f0 Fixed double close of non-regular files in flv and mp4.
With introduction of open_file_cache in 1454:f497ed7682a7, opening a file
with ngx_open_cached_file() automatically adds a cleanup handler to close
the file.  As such, calling ngx_close_file() directly for non-regular files
is no longer needed and will result in duplicate close() call.

In 1454:f497ed7682a7 ngx_close_file() call for non-regular files was removed
in the static module, but wasn't in the flv module.  And the resulting
incorrect code was later copied to the mp4 module.  Fix is to remove the
ngx_close_file() call from both modules.

Reported by Chris Newton.
2020-12-11 13:42:07 +03:00
Maxim Dounin 1033f84eeb Removed extra allocation for r->uri.
The ngx_http_parse_complex_uri() function cannot make URI longer and does
not null-terminate URI, so there is no need to allocate an extra byte.  This
allocation appears to be a leftover from changes in 461:a88a3e4e158f (0.1.5),
where null-termination of r->uri and many other strings was removed.
2020-12-10 20:09:39 +03:00
Maxim Dounin 2361e675a2 Fixed parsing of absolute URIs with empty path (ticket #2079).
When the request line contains request-target in the absolute-URI form,
it can contain path-empty instead of a single slash (see RFC 7230, RFC 3986).
Previously, the ngx_http_parse_request_line() function only accepted empty
path when there was no query string.

With this change, non-empty query is also correctly handled.  That is,
request line "GET http://example.com?foo HTTP/1.1" is accepted and results
in $uri "/" and $args "foo".

Note that $request_uri remains "?foo", similarly to how spaces in URIs
are handled.  Providing "/?foo", similarly to how "/" is provided for
"GET http://example.com HTTP/1.1", requires allocation.
2020-12-10 20:09:30 +03:00
Roman Arutyunyan 37494c700d QUIC: always calculate rtt for largest acknowledged packet.
Previously, when processing client ACK, rtt could be calculated for a packet
different than the largest if it was missing in the sent chain.  Even though
this is an unlikely situation, rtt based on a different packet could be larger
than needed leading to bigger pto timeout and performance degradation.
2020-12-09 21:26:21 +00:00
Roman Arutyunyan 9712e7c84d QUIC: send and process ack_delay for Initial and Handshake levels.
Previously, this only worked for Application level because before
quic-transport-30, there were the following constraints:

   Because the receiver doesn't use the ACK Delay for Initial and Handshake
   packets, a sender SHOULD send a value of 0.

   When adjusting an RTT sample using peer-reported acknowledgement delays, an
   endpoint ...  MUST ignore the ACK Delay field of the ACK frame for packets
   sent in the Initial and Handshake packet number space.
2020-12-10 14:54:53 +00:00
Roman Arutyunyan 87ed36b6e5 QUIC: use client max_ack_delay when computing pto timeout.
Previously, server max_ack_delay was used which is wrong.

Also, level check is simplified.
2020-12-09 16:15:24 +00:00
Roman Arutyunyan ba527cd792 QUIC: resend handshake packets along with initial.
To speed up handshake, resend both initial and handshake packets if there's
at least one unacknowledged initial packet.
2020-12-08 17:10:22 +00:00
Roman Arutyunyan cffdf76263 QUIC: set the temporary flag for input frame buffers.
Missing flag prevented frame data from being copied as the buffer was not
considered a memory buffer.
2020-12-08 14:44:41 +00:00
Ruslan Ermilov 24794a7fa0 SSL: fixed SSL shutdown on lingering close.
Ensure c->recv is properly reset to ngx_recv if SSL_shutdown()
blocks on writing.

The bug had appeared in 554c6ae25ffc.
2020-12-08 01:43:36 +03:00
Roman Arutyunyan 819ca27d64 QUIC: coalesce output packets into a single UDP datagram.
Now initial output packet is not padded anymore if followed by a handshake
packet.  If the datagram is still not big enough to satisfy minimum size
requirements, handshake packet is padded.
2020-12-07 15:09:08 +00:00
Roman Arutyunyan 73a64aa9eb QUIC: introduced QUIC buffers.
Buffers are used to hold frame data.  They have a fixed size and are reused
after being freed.
2020-12-01 19:11:01 +00:00
Vladimir Homutov 0fdfd7f7fa QUIC: fixed handling of clients connected to wildcard address.
The patch replaces c->send() occurences with c->send_chain(), because the
latter accounts for the local address, which may be different if the wildcard
listener is used.

Previously, server sent response to client using address different from
one client connected to.
2020-12-07 14:06:00 +03:00
Sergey Kandaurov 2a92fecbf9 QUIC: disabling bidirectional SSL shutdown earlier.
Notably, this fixes an issue with Chrome that can emit a "certificate_unknown"
alert during the SSL handshake where c->ssl->no_wait_shutdown is not yet set.
2020-12-06 14:24:38 +00:00
Vladimir Homutov 03a273fe76 QUIC: fixed missing quic flag on listener in the stream module. 2020-12-04 15:19:03 +03:00
Roman Arutyunyan dc5ab4196f HTTP/3: introduced ngx_http_v3_filter.
The filter is responsible for creating HTTP/3 response header and body.

The change removes differences to the default branch for
ngx_http_chunked_filter_module and ngx_http_header_filter_module.
2020-11-27 17:46:21 +00:00
Vladimir Homutov 8402a8068a QUIC: fixed send contexts cleanup.
The ngx_quic_get_send_ctx() macro takes 'level' argument, not send context
index.
2020-12-02 10:55:49 +03:00
Vladimir Homutov 5439bfc399 QUIC: removed ngx_quic_hexdump() macro.
Instead, appropriate format specifier for hexadecimal is used
in ngx_log_debug().

The STREAM frame "data" debug is moved into ngx_quic_log_frame(), similar
to all other frame fields debug.
2020-11-27 18:43:36 +03:00
Ruslan Ermilov e8a65f3b5b Upstream: excluded down servers from the next_upstream tries.
Previously, the number of next_upstream tries included servers marked
as "down", resulting in "no live upstreams" with the code 502 instead
of the code derived from an attempt to connect to the last tried "up"
server (ticket #2096).
2020-11-27 00:01:20 +03:00
Ruslan Ermilov afd0a08e17 Version bump. 2020-11-26 23:46:59 +03:00
Roman Arutyunyan dce8a2f3d2 HTTP/3: eliminated r->method_start.
The field was introduced to ease parsing HTTP/3 requests.

The change reduces diff to the default branch.
2020-11-25 17:57:43 +00:00
Maxim Dounin b89b408080 release-1.19.5 tag 2020-11-24 18:06:34 +03:00
Maxim Dounin aa0eafea6d nginx-1.19.5-RELEASE 2020-11-24 18:06:34 +03:00
Pavel Pautov 36ddc95f84 gRPC: RST_STREAM(NO_ERROR) handling after "trailer only" responses.
Similarly to the problem fixed in 2096b21fcd10 (ticket #1792),
when a "trailer only" gRPC response (that is, a response with the
END_STREAM flag in the HEADERS frame) was immediately followed by
RST_STREAM(NO_ERROR) in the data preread along with the response
header, RST_STREAM wasn't properly skipped and caused "upstream
rejected request with error 0" errors.
Observed with "unknown service" gRPC errors returned by grpc-go.

Fix is to set ctx->done if we are going to parse additional data,
so the RST_STREAM(NO_ERROR) is properly skipped.  Additionally, now
ngx_http_grpc_filter() will complain about frames sent for closed
stream if there are any.
2020-11-18 18:41:16 -08:00
Sergey Kandaurov d660500c67 Use .Mt to mark up email addresses. 2020-11-19 17:15:22 +00:00
Igor Ippolitov 9472505ba9 Core: "-e" command line option.
When installing or running from a non-root user it is sometimes required to
override default, compiled in error log path. There was no way to do this
without rebuilding the binary (ticket #147).

This patch introduced "-e" command line option which allows one to override
compiled in error log path.
2020-11-19 16:59:00 +00:00
Roman Arutyunyan 9da2167d27 HTTP/3: null-terminate empty header value.
Header value returned from the HTTP parser is expected to be null-terminated or
have a spare byte after the value bytes.  When an empty header value was passed
by client in a literal header representation, neither was true.  This could
result in segfault.  The fix is to assign a literal empty null-terminated
string in this case.

Thanks to Andrey Kolyshkin.
2020-11-17 20:54:10 +00:00
Roman Arutyunyan 0393266e5f HTTP/3: finalize chunked response body chain with NULL.
Unfinalized chain could result in segfault.  The problem was introduced in
ef83990f0e25.

Patch by Andrey Kolyshkin.
2020-11-17 21:12:36 +00:00
Sergey Kandaurov ccbbe4b470 Merged with the default branch. 2020-11-24 17:19:40 +00:00
Sergey Kandaurov 660cbf2a61 QUIC: rejecting zero-length packets with PROTOCOL_VIOLATION.
Per the latest post draft-32 specification updates on the topic:
https://github.com/quicwg/base-drafts/pull/4391
2020-11-18 20:56:11 +00:00
Sergey Kandaurov c4bbc9c1d0 QUIC: simplified and streamlined ngx_quic_decrypt().
Both clearflags and badflags are removed.  It makes a little sense now
to keep them as intermediate storage.
2020-11-17 21:33:16 +00:00
Sergey Kandaurov adc7d2d3f9 QUIC: merged create_long/short_packet() functions.
They no longer differ.
2020-11-17 21:33:12 +00:00
Sergey Kandaurov 4532fb0f3f QUIC: macros for manipulating header protection and reserved bits.
This gets rid of magic numbers from quic protection and allows to push down
header construction specifics further to quic transport.
2020-11-17 21:32:22 +00:00
Sergey Kandaurov c61ad80d7e QUIC: hide header creation internals in ngx_event_quic_transport.c.
It doesn't make sense to expose the header type in a public function.
2020-11-17 21:32:06 +00:00
Sergey Kandaurov bb47c3dfe4 QUIC: refactored long header parsing.
The largely duplicate type-specific functions ngx_quic_parse_initial_header(),
ngx_quic_parse_handshake_header(), and a missing one for 0-RTT, were merged.
The new order of functions listed in ngx_event_quic_transport.c reflects this.

|_ ngx_quic_parse_long_header    - version-invariant long header fields
\_ ngx_quic_supported_version    - a helper to decide we can go further
\_ ngx_quic_parse_long_header_v1 - QUICv1-specific long header fields

0-RTT packets previously appeared as Handshake are now logged as appropriate:
 *1 quic packet rx long flags:db version:ff00001d
 *1 quic packet rx early len:870

Logging SCID/DCID is no longer duplicated as were seen with Initial packets.
2020-11-17 21:32:04 +00:00
Sergey Kandaurov ea0e574048 QUIC: sorted header parsing functions in order of appearance.
No functional changes.
2020-11-17 21:31:51 +00:00
Sergey Kandaurov 7565da40d3 QUIC: removed macros for stream limits unused since c5324bb3a704. 2020-11-17 12:22:24 +00:00
Sergey Kandaurov f7fe85c087 Core: hide "struct ngx_quic_connection_s" and further reduce diffs.
As with the previous change, it became feasible with feec2cc762f6
that removes ngx_quic_connection_t from ngx_connection_s.
2020-11-13 15:11:29 +00:00
Sergey Kandaurov f1094694ff Core: reduced diff to the default branch.
It became feasible to reduce after feec2cc762f6 that
removes ngx_quic_connection_t from ngx_connection_s.
2020-11-13 15:11:27 +00:00
Sergey Kandaurov be8e1f536e QUIC: microoptimization in varint parsing.
Removed a useless mask from the value being shifted, since it is 1-byte wide.
2020-11-13 13:24:45 +00:00
Roman Arutyunyan 6d48d90763 Fixed generating chunked response after 46e3542d51b3.
If trailers were missing and a chain carrying the last_buf flag had no data
in it, then last HTTP/1 chunk was broken.  The problem was introduced while
implementing HTTP/3 response body generation.

The change fixes the issue and reduces diff to the mainline nginx.
2020-11-10 20:42:45 +00:00
Roman Arutyunyan f635285c28 QUIC: generate default stateless reset token key.
Previously, if quic_stateless_reset_token_key was empty or unspecified,
initial stateless reset token was not generated.  However subsequent tokens
were generated with empty key, which resulted in error with certain SSL
libraries, for example OpenSSL.

Now a random 32-byte stateless reset token key is generated if none is
specified in the configuration.  As a result, stateless reset tokens are now
generated for all server ids.
2020-11-11 21:08:48 +00:00
Roman Arutyunyan 67342b0eb2 QUIC: removed comment. 2020-11-11 19:40:41 +00:00
Roman Arutyunyan 0e146ed3d4 QUIC: added quic_stateless_reset_token_key Stream directive.
A similar directive is already available in HTTP.
2020-11-11 19:39:23 +00:00
Roman Arutyunyan 167b65f656 QUIC: reallocate qc->dcid on retry.
Previously new dcid was generated in the same memory that was allocated for
qc->dcid when creating the QUIC connection.  However this memory was also
referenced by initial_source_connection_id and retry_source_connection_id
transport parameters.  As a result these parameters changed their values after
retry which broke the protocol.
2020-11-11 17:56:02 +00:00
Roman Arutyunyan e7985ce0ab QUIC: renamed c->qs to c->quic. 2020-11-10 19:40:00 +00:00
Roman Arutyunyan 2722ff0de4 QUIC: got rid of the c->quic field.
Now QUIC connection is accessed via the c->udp field.
2020-11-10 18:38:42 +00:00
Roman Arutyunyan 168b097cbf QUIC: connection multiplexing per port.
Also, connection migration within a single worker is implemented.
2020-11-11 11:57:50 +00:00
Maxim Dounin 5a3d86ff33 Configure: shared sources for addon modules.
Addon modules, both dynamic and static, can now use shared source files.
Shared sources result in only one make rule even if specified several
times in different modules.
2020-11-10 17:13:20 +03:00
Maxim Dounin 1a48498155 Configure: initialization of NGX_ADDON_SRCS. 2020-11-10 17:13:17 +03:00
Maxim Dounin b8884a0cbe Configure: style. 2020-11-10 17:13:14 +03:00
Maxim Dounin 46aa3f5070 Request body: removed error assumption (ticket #2058).
Before introduction of request body filter in 42d9beeb22db, the only
possible return code from the ngx_http_request_body_filter() call
without actual buffers was NGX_HTTP_INTERNAL_SERVER_ERROR, and
the code in ngx_http_read_client_request_body() hardcoded the only
possible error to simplify the code of initial call to set rb->rest.

This is no longer true after introduction of request body filters though,
as a request body filter might need to return other errors, such as 403.
Fix is to preserve the error code actually returned by the call
instead of assuming 500.
2020-11-09 22:41:54 +03:00
Maxim Dounin 97f7577562 Request body: improved logging.
Added logging before returning NGX_HTTP_INTERNAL_SERVER_ERROR if there
are busy buffers after a request body flush.  This should never happen
with current code, though bugs can be introduced by 3rd party modules.
Make sure debugging will be easy enough.
2020-11-09 22:40:53 +03:00
Roman Arutyunyan a601bbdf44 QUIC: renamed field and function related to client ids.
Particularly, c->curr_seqnum is renamed to c->client_seqnum and
ngx_quic_alloc_connection_id() is renamed to ngx_quic_alloc_client_id().
2020-11-09 18:58:29 +00:00
Sergey Kandaurov cb43caba9d QUIC: multiple versions support in ALPN.
Previously, a version based on NGX_QUIC_DRAFT_VERSION was always set.
Now it is taken from the negotiated QUIC version that may differ.
2020-11-10 00:32:56 +03:00
Sergey Kandaurov 4f6e91f0c9 QUIC: multiple versions support.
Draft-29 and beyond are now treated as compatible versions.
2020-11-10 00:23:04 +03:00
Sergey Kandaurov b7f2dde342 QUIC: preparatory changes for multiple QUIC versions support.
A negotiated version is decoupled from NGX_QUIC_VERSION and, if supported,
now stored in c->quic->version after packets processing.  It is then used
to create long header packets.  Otherwise, the list of supported versions
(which may be many now) is sent in the Version Negotiation packet.

All packets in the connection are expected to have the same version.
Incoming packets with mismatched version are now rejected.
2020-11-10 00:20:44 +03:00
Ruslan Ermilov 1b6523d504 SSL: fixed non-working SSL shutdown on lingering close.
When doing lingering close, the socket was first shut down for writing,
so SSL shutdown initiated after lingering close was not able to send
the close_notify alerts (ticket #2056).

The fix is to call ngx_ssl_shutdown() before shutting down the socket.
2020-11-06 23:44:54 +03:00
Ruslan Ermilov af0e4bedad Removed dead code from ngx_http_set_keepalive().
The code removed became dead after 98f03cd8d6cc (0.8.14),
circa when the request reference counting was introduced.
2020-11-06 23:44:47 +03:00
Vladimir Homutov 211af3d876 QUIC: added proper logging of special values.
A number of unsigned variables has a special value, usually -1 or some maximum,
which produces huge numeric value in logs and makes them hard to read.

In order to distinguish such values in log, they are casted to the signed type
and printed as literal '-1'.
2020-11-06 18:21:31 +03:00
Sergey Kandaurov 4598902e81 QUIC: fixed address validation issues in a new connection.
The client address validation didn't complete with a valid token,
which was broken after packet processing refactoring in d0d3fc0697a0.

An invalid or expired token was treated as a connection error.
Now we proceed as outlined in draft-ietf-quic-transport-32,
section 8.1.3 "Address Validation for Future Connections" below,
which is unlike validating the client address using Retry packets.

   When a server receives an Initial packet with an address validation
   token, it MUST attempt to validate the token, unless it has already
   completed address validation.  If the token is invalid then the
   server SHOULD proceed as if the client did not have a validated
   address, including potentially sending a Retry.

The connection is now closed in this case on internal errors only.
2020-11-02 17:38:11 +00:00
Sergey Kandaurov e9ddd91457 QUIC: refactored key handling.
All key handling functionality is moved into ngx_quic_protection.c.
Public structures from ngx_quic_protection.h are now private and new
methods are available to manipulate keys.

A negotiated cipher is cached in QUIC connection from the set secret callback
to avoid calling SSL_get_current_cipher() on each encrypt/decrypt operation.
This also reduces the number of unwanted c->ssl->connection occurrences.
2020-11-02 18:21:34 +03:00
Sergey Kandaurov 3e522efdf7 QUIC: refactored SSL_do_handshake() handling.
No functional changes.
2020-10-29 21:50:49 +00:00
Sergey Kandaurov af8c42f6e3 QUIC: passing ssl_conn to SSL_get0_alpn_selected() directly.
No functional changes.
2020-10-29 21:50:19 +00:00
Sergey Kandaurov 45cec3fc53 Merged with the default branch. 2020-10-29 14:53:58 +00:00
Roman Arutyunyan e958f103b2 QUIC: handle more frames in ngx_quic_resend_frames().
When a packet is declared lost, its frames are handled differently according to
13.3. Retransmission of Information.
2020-10-29 14:25:02 +00:00
Vladimir Homutov 716d09c8c0 QUIC: avoided retransmission of stale ack frames.
Acknowledgments are regenerated using the most recent data available.
2020-10-28 14:22:51 +03:00
Vladimir Homutov 5f90fe994b Core: added format specifiers to output binary data as hex.
Now "s", "V", and "v" format specifiers may be prefixed with "x" (lowercase)
or "X" (uppercase) to output corresponding data in hexadecimal format.

In collaboration with Maxim Dounin.
2020-10-28 10:56:11 +03:00
Vladimir Homutov e29c49b31f Version bump. 2020-11-05 22:37:27 +03:00
Roman Arutyunyan de8e89aacb QUIC: changed STREAM frame debugging. 2020-10-27 18:21:36 +00:00
Roman Arutyunyan 3c7a646b3a QUIC: changed ACK frame debugging.
Previously ACK ranges were logged as a gap/range sequence.  Now these
values are expanded to packet number ranges for easier reading.
2020-10-28 09:15:04 +00:00
Maxim Dounin 2a89a3fb40 release-1.19.4 tag 2020-10-27 18:09:20 +03:00
Maxim Dounin 80e7a65808 nginx-1.19.4-RELEASE 2020-10-27 18:09:20 +03:00
Roman Arutyunyan ea3987c5ae QUIC: unified range format for rx and tx ACK frames.
Previously, tx ACK frames held ranges in an array of ngx_quic_ack_range_t,
while rx ACK frames held ranges in the serialized format.  Now serialized format
is used for both types of frames.
2020-10-27 13:24:00 +00:00
Vladimir Homutov 949eec2c5f QUIC: cleanup send context properly.
The patch resets ctx->frames queue, which may contain frames.  It was possible
that congestion or amplification limits prevented all frames to be sent.

Retransmitted frames could be accounted twice as inflight: first time in
ngx_quic_congestion_lost() called from ngx_quic_resend_frames(), and later
from ngx_quic_discard_ctx().
2020-10-27 00:14:24 +03:00
Vladimir Homutov d3480a33f5 QUIC: added push event afer the address was validated.
This allows to continue processing when the anti-amplification limit was hit.
2020-10-27 00:00:56 +03:00
Vladimir Homutov ed32475c7e QUIC: updated anti-amplification check for draft 32.
This accounts for the following change:

   *  Require expansion of datagrams to ensure that a path supports at
      least 1200 bytes:

      -  During the handshake ack-eliciting Initial packets from the
         server need to be expanded
2020-10-26 23:58:34 +03:00
Vladimir Homutov f6692368a8 QUIC: got rid of "pkt" abbreviation in logs. 2020-10-26 23:47:49 +03:00
Vladimir Homutov 2f353e67ee QUIC: added "rx" and "tx" prefixes to packet debug. 2020-10-26 23:47:16 +03:00
Vladimir Homutov 1a6f6bfd26 QUIC: added connection state debug to event handlers. 2020-10-26 23:17:54 +03:00
Vladimir Homutov 1190d9c21c QUIC: added logging of a declined packet without retry token. 2020-10-26 00:34:24 +03:00
Vladimir Homutov ab43d69d98 QUIC: revised value separators in debug and error messages.
All values are prefixed with name and separated from it using colon.
Multiple values are listed without commas in between.

Rationale: this greatly simplifies log parsing for analysis.
2020-10-27 14:12:31 +03:00
Vladimir Homutov 3c4e0cfc22 QUIC: single function for frame debug logging.
The function may be called for any initialized frame, both rx and tx.

While there, shortened level names.
2020-10-27 14:32:08 +03:00
Vladimir Homutov aac3894fb6 QUIC: optimized acknowledgement generation.
For application level packets, only every second packet is now acknowledged,
respecting max ack delay.

13.2.1 Sending ACK Frames

   In order to assist loss detection at the sender, an endpoint SHOULD
   generate and send an ACK frame without delay when it receives an ack-
   eliciting packet either:

   *  when the received packet has a packet number less than another
      ack-eliciting packet that has been received, or

   *  when the packet has a packet number larger than the highest-
      numbered ack-eliciting packet that has been received and there are
      missing packets between that packet and this packet.


13.2.2.  Acknowledgement Frequency

    A receiver SHOULD send an ACK frame after receiving at least two
    ack-eliciting packets.
2020-10-23 17:08:50 +03:00
Vladimir Homutov cba0f87bfa QUIC: added missing "quic" prefix in debug messages. 2020-10-23 18:22:01 +03:00
Maxim Dounin e7c6bb858f SSL: ssl_reject_handshake directive (ticket #195).
In some cases it might be needed to reject SSL handshake based on SNI
server name provided, for example, to make sure an invalid certificate
is not returned to clients trying to contact a name-based virtual server
without SSL configured.  Previously, a "ssl_ciphers aNULL;" was used for
this.  This workaround, however, is not compatible with TLSv1.3, in
particular, when using BoringSSL, where it is not possible to configure
TLSv1.3 ciphers at all.

With this change, the ssl_reject_handshake directive is introduced,
which instructs nginx to reject SSL handshakes with an "unrecognized_name"
alert in a particular server block.

For example, to reject handshake with names other than example.com,
one can use the following configuration:

    server {
        listen 443 ssl;
        ssl_reject_handshake on;
    }

    server {
        listen 443 ssl;
        server_name example.com;
        ssl_certificate example.com.crt;
        ssl_certificate_key example.com.key;
    }

The following configuration can be used to reject all SSL handshakes
without SNI server name provided:

    server {
        listen 443 ssl;
        ssl_reject_handshake on;
    }

    server {
        listen 443 ssl;
        server_name ~^;
        ssl_certificate example.crt;
        ssl_certificate_key example.key;
    }

Additionally, the ssl_reject_handshake directive makes configuring
certificates for the default server block optional.  If no certificates
are configured in the default server for a given listening socket,
certificates must be defined in all non-default server blocks with
the listening socket in question.
2020-10-22 18:02:28 +03:00
Maxim Dounin e88d0fc7a4 Stream: proxy_ssl_conf_command directive.
Similarly to ssl_conf_command, proxy_ssl_conf_command can be used to
set arbitrary OpenSSL configuration parameters as long as nginx is
compiled with OpenSSL 1.0.2 or later, when connecting to upstream
servers with SSL.  Full list of available configuration commands
can be found in the SSL_CONF_cmd manual page
(https://www.openssl.org/docs/man1.1.1/man3/SSL_CONF_cmd.html).
2020-10-22 18:00:27 +03:00
Maxim Dounin 54bb307c7b Upstream: proxy_ssl_conf_command and friends.
Similarly to ssl_conf_command, proxy_ssl_conf_command (grpc_ssl_conf_command,
uwsgi_ssl_conf_command) can be used to set arbitrary OpenSSL configuration
parameters as long as nginx is compiled with OpenSSL 1.0.2 or later,
when connecting to upstream servers with SSL.  Full list of available
configuration commands can be found in the SSL_CONF_cmd manual page
(https://www.openssl.org/docs/man1.1.1/man3/SSL_CONF_cmd.html).
2020-10-22 18:00:23 +03:00
Maxim Dounin 4caf623ede SSL: ssl_conf_command directive.
With the ssl_conf_command directive it is now possible to set
arbitrary OpenSSL configuration parameters as long as nginx is compiled
with OpenSSL 1.0.2 or later.  Full list of available configuration
commands can be found in the SSL_CONF_cmd manual page
(https://www.openssl.org/docs/man1.1.1/man3/SSL_CONF_cmd.html).

In particular, this allows configuring PrioritizeChaCha option
(ticket #1445):

    ssl_conf_command Options PrioritizeChaCha;

It can be also used to configure TLSv1.3 ciphers in OpenSSL,
which fails to configure them via the SSL_CTX_set_cipher_list()
interface (ticket #1529):

    ssl_conf_command Ciphersuites TLS_CHACHA20_POLY1305_SHA256;

Configuration commands are applied after nginx own configuration
for SSL, so they can be used to override anything set by nginx.
Note though that configuring OpenSSL directly with ssl_conf_command
might result in a behaviour nginx does not expect, and should be
done with care.
2020-10-22 18:00:22 +03:00
Maxim Dounin b8cb995f51 Core: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.
With this change, it is now possible to use ngx_conf_merge_ptr_value()
to merge keyval arrays.  This change actually follows much earlier
changes in ngx_conf_merge_ptr_value() and ngx_conf_set_str_array_slot()
in 1452:cd586e963db0 (0.6.10) and 1701:40d004d95d88 (0.6.22).

To preserve compatibility with existing 3rd party modules, both NULL
and NGX_CONF_UNSET_PTR are accepted for now.
2020-10-22 18:00:20 +03:00
Sergey Kandaurov 41510b9c70 QUIC: updated README.
- ACK ranges are implemented
 - up to draft-32 is now supported
 - removed mentions of early alpha quality and further cleanup
2020-10-22 12:55:15 +01:00
Sergey Kandaurov b041c03f09 QUIC: restored proper usage of ngx_quic_drop_ack_ranges().
ACK Ranges are again managed based on the remembered Largest Acknowledged
sent in the packet being acknowledged, which partially reverts c01964fd7b8b.
2020-10-22 11:05:50 +01:00
Vladimir Homutov c6693e556f QUIC: fixed dropping output ack ranges on input ack.
While there, additional debug messages were added.
2020-10-21 20:39:25 +03:00
Vladimir Homutov 718bfcae4d QUIC: added macro for unset packet number. 2020-10-21 18:44:25 +03:00
Vladimir Homutov 982d7b7bff QUIC: drop acknowledged ranges.
13.2.4.  Limiting Ranges by Tracking ACK Frames

   When a packet containing an ACK frame is sent, the largest
   acknowledged in that frame may be saved.  When a packet containing an
   ACK frame is acknowledged, the receiver can stop acknowledging
   packets less than or equal to the largest acknowledged in the sent
   ACK frame.
2020-10-20 18:53:25 +03:00
Vladimir Homutov 0a4c1a3fa4 QUIC: added ACK frame range support.
The history of acknowledged packet is kept in send context as ranges.
Up to NGX_QUIC_MAX_RANGES ranges is stored.

As a result, instead of separate ack frames, single frame with ranges
is sent.
2020-10-20 18:53:00 +03:00
Sergey Kandaurov 4279c3cc87 QUIC: expand UDP datagrams with an ack-eliciting Initial packet.
Per draft-ietf-quic-transport-32 on the topic:

:   Similarly, a server MUST expand the payload of all UDP datagrams carrying
:   ack-eliciting Initial packets to at least the smallest allowed maximum
:   datagram size of 1200 bytes.
2020-10-21 12:46:23 +01:00
Sergey Kandaurov 8b3023ea6b QUIC: teach how to compute only the length of created QUIC headers.
It will be used for precise expansion of UDP datagram payload.
2020-10-21 12:03:23 +01:00
Sergey Kandaurov da44036046 QUIC: simplified ngx_quic_create_long_header().
As seen in the quic-transport draft, which this implementation follows:
Initial packets sent by the server MUST set the Token Length field to zero.
2020-10-21 12:03:22 +01:00
Sergey Kandaurov a5f7f2f2a1 QUIC: avoided excessive initialization in ngx_quic_send_frames().
A zero-length token was used to initialize a prezeroed packet header.
2020-10-21 12:03:22 +01:00
Sergey Kandaurov c7bada2ea9 QUIC: sorted ngx_quic_send_frames() declarations. 2020-10-21 12:03:21 +01:00
Vladimir Homutov dc12426a87 QUIC: account packet header length in amplification limit.
This is the restoration of 02ee77f8d53d accidentally reverted by 93be5658a250.
2020-10-19 12:19:38 +03:00
Vladimir Homutov 25c51c105c QUIC: reverted previous 3 commits.
Changes were intended for the test repository.
2020-10-19 10:32:53 +03:00
Vladimir Homutov 32830dcac9 try: --skiptests 2020-10-19 10:10:21 +03:00
Vladimir Homutov 498f03e9d4 QUIC: added ACK frame range support.
The history of acknowledged packet is kept in send context as ranges.
Up to NGX_QUIC_MAX_RANGES ranges is stored.

As a result, instead of separate ack frames, single frame with ranges
is sent.
2020-10-14 23:21:36 +03:00
Ruslan Ermilov e82f73faf1 Cpp test: added stream. 2020-10-13 07:44:09 +03:00
Maxim Dounin 35952858fe Limit req: unlocking of nodes on complex value errors.
Previously, if there were multiple limits configured, errors in
ngx_http_complex_value() during processing of a non-first limit
resulted in reference count leak in shared memory nodes of already
processed limits.  Fix is to explicity unlock relevant nodes, much
like we do when rejecting requests.
2020-10-08 17:44:34 +03:00
Maxim Dounin 5addcc5141 Mail: proxy_smtp_auth directive.
The proxy_smtp_auth directive instructs nginx to authenticate users
on backend via the AUTH command (using the PLAIN SASL mechanism),
similar to what is normally done for IMAP and POP3.

If xclient is enabled along with proxy_smtp_auth, the XCLIENT command
won't try to send the LOGIN parameter.
2020-10-03 21:04:57 +03:00
Maxim Dounin ffb91df1f2 Version bump. 2020-10-03 21:01:12 +03:00
Maxim Dounin 12e5f21bcd release-1.19.3 tag 2020-09-29 17:32:10 +03:00
Maxim Dounin caa012fdac nginx-1.19.3-RELEASE 2020-09-29 17:32:10 +03:00
Maxim Dounin 3e2d87ad82 Updated OpenSSL used for win32 builds. 2020-09-29 15:56:16 +03:00
Maxim Dounin 74f0a26f66 Proxy: error checking for array init, missed in 7716:d6a5e14aa3e4.
Found by Coverity (CID 1467637).
2020-09-29 15:54:09 +03:00
Maxim Dounin d1cd8c4888 Userid: userid_flags fixup.
In 7717:e3e8b8234f05, the 1st bit was incorrectly used.  It shouldn't
be used for bitmask values, as it is used by NGX_CONF_BITMASK_SET.

Additionally, special value "off" added to make it possible to clear
inherited userid_flags value.
2020-09-29 15:52:18 +03:00
Maxim Dounin 888dd2ff13 Resolver: improved error messages (ticket #2024). 2020-09-28 17:41:22 +03:00
Maxim Dounin bbf1d8b7a6 Userid: userid_flags directive to set cookie flags. 2020-09-28 17:07:48 +03:00
Ruslan Ermilov 105928e76f Proxy: added the "proxy_cookie_flags" directive. 2020-09-27 23:21:11 +03:00
Ruslan Ermilov 08089f9311 Proxy: changed interface of some internal functions.
This is in preparation for the next change.

Also, moved optimization from ngx_http_proxy_rewrite_regex_handler()
to ngx_http_proxy_rewrite().
2020-09-27 23:21:10 +03:00
Ruslan Ermilov 1ca5d331c5 Proxy: strengthen syntax checking for some directives.
The "false" parameter of the proxy_redirect directive is deprecated.
Warning has been emitted since c2230102df6f (0.7.54).

The "off" parameter of the proxy_redirect, proxy_cookie_domain, and
proxy_cookie_path directives tells nginx not to inherit the
configuration from the previous configuration level.

Previously, after specifying the directive with the "off" parameter,
any other directives were ignored, and syntax checking was disabled.

The syntax was enforced to allow either one directive with the "off"
parameter, or several directives with other parameters.

Also, specifying "proxy_redirect default foo" no longer works like
"proxy_redirect default".
2020-09-27 23:21:09 +03:00
Vladimir Homutov dee178452f SSL: added the "ssl_keys_file" directive. 2020-09-15 22:44:46 +03:00
Vladimir Homutov 42b39fd65a QUIC: account packet header length in amplification limit.
Header length calculation is adjusted to account real connection id lengths
instead of worst case.
2020-10-15 11:37:01 +03:00
Sergey Kandaurov 545241eb55 QUIC: fixed ngx_http_upstream_init() much like HTTP/2 connections. 2020-10-12 14:00:00 +01:00
Vladimir Homutov 028185db49 QUIC: reset error and error_reason prior to processing packet. 2020-10-09 16:57:19 +03:00
Sergey Kandaurov d91ea78765 QUIC: fixed dead store assignment.
Found by Clang Static Analyzer.
2020-10-07 14:51:05 +01:00
Vladimir Homutov 31cee96bde QUIC: fixed format specifier in debug message. 2020-10-07 15:29:23 +03:00
Vladimir Homutov 836007bb35 QUIC: added debug message with final packet processing status. 2020-10-02 16:20:41 +03:00
Roman Arutyunyan 56da17436a QUIC: set local_socklen in stream connections.
Previously, this field was not set while creating a QUIC stream connection.
As a result, calling ngx_connection_local_sockaddr() led to getsockname()
bad descriptor error.
2020-10-07 12:24:03 +01:00
Vladimir Homutov 8b94732aa4 QUIC: enabled more key-related debug by default. 2020-10-02 12:40:49 +03:00
Vladimir Homutov 0e47f4bfa5 QUIC: added connection id debug. 2020-10-02 12:56:34 +03:00
Vladimir Homutov 7beae31be5 QUIC: updated c->log->action strings to reflect proper state. 2020-10-07 13:38:17 +03:00
Vladimir Homutov 5de89a7d8c QUIC: fixed memory leak in ngx_quic_send_frames().
The function did not free passed frames in case of error.
2020-10-07 10:14:02 +03:00
Sergey Kandaurov 236b7fb58b QUIC: fixed measuring ACK Delay against 0-RTT packets. 2020-10-06 18:08:55 +01:00
Sergey Kandaurov 1c5823b107 QUIC: do not resend empty queue when speeding up handshake.
If client acknowledged an Initial packet with CRYPTO frame and then
sent another Initial packet containing duplicate CRYPTO again, this
could result in resending frames off the empty send queue.
2020-10-05 13:02:53 +01:00
Sergey Kandaurov 6eec0e2364 QUIC: zero out packet length in frames prior to send.
It could be that a frame was previously sent and may have stale information.
This was previously broken by merging frames on resend in b383120afca3.
2020-10-05 13:02:38 +01:00
Vladimir Homutov d4515820cf QUIC: fixed build with clang and NGX_QUIC_DEBUG_CRYPTO enabled.
The ngx_quic_hexdump() function is wrapped into macros to cast "data"
argument to "* u_char".
2020-10-05 14:36:17 +03:00
Vladimir Homutov d88396734b QUIC: inline function instead of macro for hexdump.
This prevents name clashes with local variables.
2020-10-05 10:03:01 +03:00
Vladimir Homutov 6c644adb0e QUIC: fixed handling of incorrect packets.
Instead of ignoring, connection was closed. This was broken in d0d3fc0697a0.
2020-10-01 22:20:51 +03:00
Sergey Kandaurov 52172fc8d9 Merged with the default branch. 2020-10-01 12:21:11 +01:00
Sergey Kandaurov 7499800d7f QUIC: a bandaid for calculating ack_delay with non-monotonic time. 2020-10-01 12:10:37 +01:00
Sergey Kandaurov 85086a5267 QUIC: speeding up handshake completion.
As per quic-recovery draft, section-6.2.3: resend CRYPTO frames
when receiving an Initial packet containing duplicate CRYPTO data.
2020-10-01 12:10:22 +01:00
Sergey Kandaurov 1fca2f6698 QUIC: fixed clang-ast asserts. 2020-10-01 12:09:47 +01:00
Sergey Kandaurov e8b61e9b4c QUIC: fixed build with OpenSSL after bed310672f39. 2020-10-01 12:00:12 +01:00
Vladimir Homutov 64b3828e19 QUIC: moved ssl configuration pointer to quic configuration.
The ssl configuration is obtained at config time and saved for future use.
2020-10-01 10:04:35 +03:00
Vladimir Homutov 5bd6c60156 QUIC: added stateless reset support.
The new "quic_stateless_reset_token_key" directive is added.  It sets the
endpoint key used to generate stateless reset tokens and enables feature.

If the endpoint receives short-header packet that can't be matched to
existing  connection, a stateless reset packet is generated with
a proper token.

If a valid stateless reset token is found in the incoming packet,
the connection is closed.

Example configuration:

http {
    quic_stateless_reset_token_key  "foo";
    ...
}
2020-09-30 20:54:46 +03:00
Vladimir Homutov fc0cbbee53 QUIC: refined the "c->quic->initialized" flag usage.
The flag is tied to the initial secret creation.  The presence of c->quic
pointer is sufficient to enable execution of ngx_quic_close_quic().

The ngx_quic_new_connection() function now returns the allocated quic
connection object and the c->quic pointer is set by the caller.

If an early error occurs before secrets initialization (i.e. in cases
of invalid retry token or nginx exiting), it is still possible to
generate an error response by trying to initialize secrets directly
in the ngx_quic_send_cc() function.

Before the change such early errors failed to send proper connection close
message and logged an error.

An auxilliary ngx_quic_init_secrets() function is introduced to avoid
verbose call to ngx_quic_set_initial_secret() requiring local variable.
2020-09-30 21:27:52 +03:00
Vladimir Homutov 19c1c5f206 QUIC: packet processing refactoring.
All packet header parsing is now performed by ngx_quic_parse_packet()
function, located in the ngx_quic_transport.c file.

The packet processing is centralized in the ngx_quic_process_packet()
function which decides if the packet should be accepted, ignored or
connection should be closed, depending on the connection state.

As a result of refactoring, behavior has changed in some places:

 - minimal size of Initial packet is now always tested
 - connection IDs are always tested in existing connections
 - old keys are discarded on encryption level switch
2020-09-30 15:14:09 +03:00
Vladimir Homutov 5b112f3ad6 QUIC: simplified packet header parsing.
Now flags are processed in ngx_quic_input(), and raw->pos points to the first
byte after the flags. Redundant checks from ngx_quic_parse_short_header() and
ngx_quic_parse_long_header() are removed.
2020-09-25 21:47:28 +03:00
Roman Arutyunyan d54717995e QUIC: keep the entire packet size in pkt->len.
Previously pkt->len kept the length of the packet remainder starting from
pkt->raw->pos.
2020-09-25 21:46:55 +03:00
Vladimir Homutov edd2c9f3e2 QUIC: switched to using fixed-length server connection IDs. 2020-09-18 15:53:37 +03:00
Roman Arutyunyan a1c43297d9 QUIC: resend frames by moving them to output queue.
Previously, when a packet was declared lost, another packet was sent with the
same frames.  Now lost frames are moved to the output frame queue and push
event is posted.  This has the advantage of forming packets with more frames
than before.

Also, the start argument is removed from the ngx_quic_resend_frames()
function as excess information.
2020-09-30 20:23:16 +01:00
Roman Arutyunyan 771d716bdb QUIC: switch stream context to a server selected by SNI.
Previously the default server configuration context was used until the
:authority or host header was parsed.  This led to using the configuration
parameters like client_header_buffer_size or request_pool_size from the default
server rather than from the server selected by SNI.

Also, the switch to the right server log is implemented.  This issue manifested
itself as QUIC stream being logged to the default server log until :authority
or host is parsed.
2020-09-29 22:09:09 +01:00
Sergey Kandaurov 6137585b59 QUIC: unbreak client certificate verification after 0d2b2664b41c.
Initially, client certificate verification didn't work due to the missing
hc->ssl on a QUIC stream, which is started to be set in 7738:7f0981be07c4.
Then it was lost in 7999:0d2b2664b41c introducing "quic" listen parameter.

This change re-adds hc->ssl back for all QUIC connections, similar to SSL.
2020-09-23 13:13:04 +01:00
Vladimir Homutov 5b904ab35b QUIC: prevented posted push event while in the draining state.
If the push event was posted before ngx_quic_close_connection(), it could send
data in the draining state.
2020-09-21 13:58:17 +03:00
Roman Arutyunyan 86c79ad10e HTTP/3: rearranged length check when parsing header.
The new code looks simpler and is similar to other checks.
2020-09-16 20:21:03 +01:00
Roman Arutyunyan 5dcfdc596c HTTP/3: removed HTTP/3 parser call from discard body filter.
Request body discard is disabled for QUIC streams anyway.
2020-09-16 19:48:33 +01:00
Roman Arutyunyan a5a7072e05 HTTP/3: reject HTTP/2 frames.
As per HTTP/3 draft 30, section 7.2.8:

   Frame types that were used in HTTP/2 where there is no corresponding
   HTTP/3 frame have also been reserved (Section 11.2.1).  These frame
   types MUST NOT be sent, and their receipt MUST be treated as a
   connection error of type H3_FRAME_UNEXPECTED.
2020-09-16 12:27:23 +01:00
Pavel Pautov 87d1d7e5c6 Stream: set module.
Adds 'set' directive to the stream server context.
2020-08-28 14:10:54 -07:00
Sergey Kandaurov 22caa5b254 SSL: abort handshake on SSL_set_SSL_CTX() errors.
In rare cases, such as memory allocation failure, SSL_set_SSL_CTX() returns
NULL, which could mean that a different SSL configuration has not been set.
Note that this new behaviour seemingly originated in OpenSSL-1.1.0 release.
2020-09-24 13:51:29 +01:00
Maxim Dounin 6fc2fe625a HTTP/2: run posted requests after reading body.
HTTP/2 code failed to run posted requests after calling the request body
handler, and this resulted in connection hang if a subrequest was created
in the body handler and no other actions were made.
2020-09-23 19:52:31 +03:00
Maxim Dounin 3a97288cad HTTP/2: fixed segfault on DATA frames after 400 errors.
If 400 errors were redirected to an upstream server using the error_page
directive, DATA frames from the client might cause segmentation fault
due to null pointer dereference.  The bug had appeared in 6989:2c4dbcd6f2e4
(1.13.0).

Fix is to skip such frames in ngx_http_v2_state_read_data() (similarly
to 7561:9f1f9d6e056a).  With the fix, behaviour of 400 errors in HTTP/2
is now similar to one in HTTP/1.x, that is, nginx doesn't try to read the
request body.

Note that proxying 400 errors, as well as other early stage errors, to
upstream servers might not be a good idea anyway.  These errors imply
that reading and processing of the request (and the request headers)
wasn't complete, and proxying of such incomplete request might lead to
various errors.

Reported by Chenglong Zhang.
2020-09-23 19:50:49 +03:00
Maxim Dounin fbe1e1d447 SSL: disabled shutdown when there are buffered data.
This fixes "SSL_shutdown() failed (SSL: ... bad write retry)" errors
as observed on the second SSL_shutdown() call after SSL shutdown fixes in
09fb2135a589 (1.19.2), notably when HTTP/2 connections are closed due
to read timeouts while there are incomplete writes.
2020-09-16 18:26:25 +03:00
Maxim Dounin 8588e16fc9 SSL: disabled shutdown after connection errors.
This fixes "SSL_shutdown() failed (SSL: ... bad write retry)" errors
as observed on the second SSL_shutdown() call after SSL shutdown fixes in
09fb2135a589 (1.19.2), notably when sending fails in ngx_http_test_expect(),
similarly to ticket #1194.

Note that there are some places where c->error is misused to prevent
further output, such as ngx_http_v2_finalize_connection() if there
are pending streams, or in filter finalization.  These places seem
to be extreme enough to don't care about missing shutdown though.
For example, filter finalization currently prevents keepalive from
being used.
2020-09-16 18:26:24 +03:00
Maxim Dounin f921ca5a0e SSL: fixed event handling during shutdown.
The c->read->ready and c->write->ready flags need to be cleared to ensure
that appropriate read or write events will be reported by kernel.  Without
this, SSL shutdown might wait till the timeout after blocking on writing
or reading even if there is a socket activity.
2020-09-16 18:26:23 +03:00
Maxim Dounin f19487ac4b SSL: workaround for incorrect SSL_write() errors in OpenSSL 1.1.1.
OpenSSL 1.1.1 fails to return SSL_ERROR_SYSCALL if an error happens
during SSL_write() after close_notify alert from the peer, and returns
SSL_ERROR_ZERO_RETURN instead.  Broken by this commit, which removes
the "i == 0" check around the SSL_RECEIVED_SHUTDOWN one:

https://git.openssl.org/?p=openssl.git;a=commitdiff;h=8051ab2

In particular, if a client closed the connection without reading
the response but with properly sent close_notify alert, this resulted in
unexpected "SSL_write() failed while ..." critical log message instead
of correct "SSL_write() failed (32: Broken pipe)" at the info level.

Since SSL_ERROR_ZERO_RETURN cannot be legitimately returned after
SSL_write(), the fix is to convert all SSL_ERROR_ZERO_RETURN errors
after SSL_write() to SSL_ERROR_SYSCALL.
2020-09-16 18:26:22 +03:00
Sergey Kandaurov c07f0b76ed Cache: keep c->body_start when Vary changes (ticket #2029).
If the variant hash doesn't match one we used as a secondary cache key,
we switch back to the original key.  In this case, c->body_start was kept
updated from an existing cache node overwriting the new response value.
After file cache update, it led to discrepancy between a cache node and
cache file seen as critical errors "file cache .. has too long header".
2020-09-09 19:26:27 +03:00
Roman Arutyunyan 1c1960e839 HTTP/3: skip unknown frames on request stream.
As per HTTP/3 draft 29, section 4.1:

   Frames of unknown types (Section 9), including reserved frames
   (Section 7.2.8) MAY be sent on a request or push stream before,
   after, or interleaved with other frames described in this section.

Also, trailers frame is now used as an indication of the request body end.
2020-08-24 09:56:36 +03:00
Roman Arutyunyan bf3f6ca721 HTTP/3: fixed handling request body eof.
While for HTTP/1 unexpected eof always means an error, for HTTP/3 an eof right
after a DATA frame end means the end of the request body.  For this reason,
since adding HTTP/3 support, eof no longer produced an error right after recv()
but was passed to filters which would make a decision.  This decision was made
in ngx_http_parse_chunked() and ngx_http_v3_parse_request_body() based on the
b->last_buf flag.

Now that since 0f7f1a509113 (1.19.2) rb->chunked->length is a lower threshold
for the expected number of bytes, it can be set to zero to indicate that more
bytes may or may not follow.  Now it's possible to move the check for eof from
parser functions to ngx_http_request_body_chunked_filter() and clean up the
parsing code.

Also, in the default branch, in case of eof, the following three things
happened, which were replaced with returning NGX_ERROR while implementing
HTTP/3:

- "client prematurely closed connection" message was logged
- c->error flag was set
- NGX_HTTP_BAD_REQUEST was returned

The change brings back this behavior for HTTP/1 as well as HTTP/3.
2020-09-16 18:59:25 +01:00
Vladimir Homutov 160bfe5969 QUIC: switched to draft 29 by default. 2020-09-11 10:56:05 +03:00
Roman Arutyunyan 3a60eda160 QUIC: allowed old DCID for initial packets until first ACK.
If a packet sent in response to an initial client packet was lost, then
successive client initial packets were dropped by nginx with the unexpected
dcid message logged.  This was because the new DCID generated by the server was
not available to the client.
2020-09-09 16:35:29 +03:00
Roman Arutyunyan b39e287f48 QUIC: eliminated idle timeout restart for dropped packets. 2020-09-08 15:54:02 +03:00
Sergey Kandaurov 1876298d26 QUIC: removed check for packet size beyond MAX_UDP_PAYLOAD_SIZE.
The check tested the total size of a packet header and unprotected packet
payload, which doesn't include the packet number length and expansion of
the packet protection AEAD.  If the packet was corrupted, it could cause
false triggering of the condition due to unsigned type underflow leading
to a connection error.

Existing checks for the QUIC header and protected packet payload lengths
should be enough.
2020-09-08 13:35:50 +03:00
Sergey Kandaurov 23360e59fc QUIC: check that the packet length is of at least sample size.
From quic-tls draft, section 5.4.2:
   An endpoint MUST discard packets that are not long enough to contain
   a complete sample.

The check includes the Packet Number field assumed to be 4 bytes long.
2020-09-08 13:28:56 +03:00
Sergey Kandaurov a3d0d3aa18 QUIC: update packet length for short packets too.
During long packet header parsing, pkt->len is updated with the Length
field value that is used to find next coalesced packets in a datagram.
For short packets it still contained the whole QUIC packet size.

This change uniforms packet length handling to always contain the total
length of the packet number and protected packet payload in pkt->len.
2020-09-08 13:27:39 +03:00
Roman Arutyunyan 90b249a639 QUIC: added logging output stream frame offset. 2020-09-07 20:55:36 +03:00
Vladimir Homutov a9144afcee QUIC: refactored ngx_quic_retry_input().
The function now returns NGX_DECLINED for packets that need to be ignored
and integrates nicely into ngx_quic_input().
2020-09-04 15:48:53 +03:00
Roman Arutyunyan a36b8068c0 QUIC: do not send STOP_SENDING after STREAM fin.
Previously STOP_SENDING was sent to client upon stream closure if rev->eof and
rev->error were not set.  This was an indirect indication that no RESET_STREAM
or STREAM fin has arrived.  But it is indeed possible that rev->eof is not set,
but STREAM fin has already been received, just not read out by the application.
In this case sending STOP_SENDING does not make sense and can be misleading for
some clients.
2020-09-06 14:51:23 +03:00
Vladimir Homutov a157dea810 QUIC: added support for multiple connection IDs.
The peer may issue additional connection IDs up to the limit defined by
transport parameter "active_connection_id_limit", using NEW_CONNECTION_ID
frames, and retire such IDs using RETIRE_CONNECTION_ID frame.
2020-09-03 13:11:27 +03:00
Vladimir Homutov 0eded5126d QUIC: style.
Moved processing of RETIRE_CONNECTION_ID right after the NEW_CONNECTION_ID.
2020-08-27 10:15:37 +03:00
Vladimir Homutov 4534a09448 QUIC: pass return code from ngx_quic_decrypt() to the caller.
It is required to distinguish internal errors from corrupted packets and
perform actions accordingly: drop the packet or close the connection.

While there, made processing of ngx_quic_decrypt() erorrs similar and
removed couple of protocol violation errors.
2020-09-02 22:34:15 +03:00
Vladimir Homutov f2efcf7755 QUIC: discard unrecognized long packes.
While there, updated comment about discarded packets.
2020-09-02 09:54:15 +03:00
Roman Arutyunyan e5bc0f12a2 HTTP/3: do not set the never-indexed literal bit by default.
The "Literal Header Field Never Indexed" header field representation is not
used in HTTP/2, and it makes little sense to make a distinction in HTTP/3.
2020-08-31 18:42:26 +03:00
Vladimir Homutov 364dcdd9c5 QUIC: discard incorrect packets instead of closing the connection.
quic-transport

5.2:
    Packets that are matched to an existing connection are discarded if
    the packets are inconsistent with the state of that connection.

5.2.2:
   Servers MUST drop incoming packets under all other circumstances.
2020-09-01 17:20:42 +03:00
Roman Arutyunyan 84b9ab590a QUIC: do not update largest packet number from a bad packet.
The removal of QUIC packet protection depends on the largest packet number
received.  When a garbage packet was received, the decoder still updated the
largest packet number from that packet.  This could affect removing protection
from subsequent QUIC packets.
2020-09-01 15:21:49 +03:00
Roman Arutyunyan 96c1fd6c69 QUIC: handle PATH_CHALLENGE frame.
A PATH_RESPONSE frame with the same data is sent in response.
2020-08-28 12:01:35 +03:00
Roman Arutyunyan 179a9aa334 QUIC: enforce flow control on incoming STREAM and CRYPTO frames. 2020-08-25 17:22:57 +03:00
Roman Arutyunyan 0001eb2ce2 HTTP/3: drop the unwanted remainder of the request.
As per HTTP/3 draft 29, section 4.1:

   When the server does not need to receive the remainder of the request,
   it MAY abort reading the request stream, send a complete response, and
   cleanly close the sending part of the stream.
2020-08-25 12:45:21 +03:00
Roman Arutyunyan 037128d3f5 QUIC: send STOP_SENDING on stream closure.
The frame is sent for a read-enabled stream which has not received a FIN or
RESET_STREAM.
2020-08-25 14:07:26 +03:00
Vladimir Homutov a6cff7c24d QUIC: updated README.
- version negotiation is implemented
 - quic recovery implementation is greatly improved
2020-08-21 14:55:32 +03:00
Sergey Kandaurov b9b0e8f5d7 QUIC: disabled bidirectional SSL shutdown after 09fb2135a589.
On QUIC connections, SSL_shutdown() is used to call the send_alert callback
to send a CONNECTION_CLOSE frame.  The reverse side is handled by other means.
At least BoringSSL doesn't differentiate whether this is a QUIC SSL method,
so waiting for the peer's close_notify alert should be explicitly disabled.
2020-08-21 14:41:42 +03:00
Sergey Kandaurov bd1d3532bf QUIC: stripped down debug traces that have served its purpose.
The most observable remainers are incoming packet and stream payload
that could still be useful to debug various QUIC and HTTP/3 frames.
2020-08-21 14:41:41 +03:00
Vladimir Homutov 9ec291891f QUIC: dead code removed.
This case was already handled in c70446e3d771.
2020-08-21 10:00:25 +03:00
Vladimir Homutov 1748c01703 QUIC: removed outdated TODOs.
The logical quic connection state is tested by handler functions that
process corresponding types of packets (initial/handshake/application).
The packet is declined if state is incorrect.

No timeout is required for the input queue.
2020-08-20 16:45:48 +03:00
Vladimir Homutov 0846ce51bb QUIC: added version negotiation support.
If a client attemtps to start a new connection with unsupported version,
a version negotiation packet is sent that contains a list of supported
versions (currently this is a single version, selected at compile time).
2020-08-20 17:11:04 +03:00
Roman Arutyunyan f3006e0d43 HTTP/3: special handling of client errors in the upstream module.
The function ngx_http_upstream_check_broken_connection() terminates the HTTP/1
request if client sends eof.  For QUIC (including HTTP/3) the c->write->error
flag is now checked instead.  This flag is set when the entire QUIC connection
is closed or STOP_SENDING was received from client.
2020-08-20 12:33:00 +03:00
Roman Arutyunyan 301bf01f06 HTTP/3: request more client body bytes.
Previously the request body DATA frame header was read by one byte because
filters were called only when the requested number of bytes were read.  Now,
after 08ff2e10ae92 (1.19.2), filters are called after each read.  More bytes
can be read at once, which simplifies and optimizes the code.

This also reduces diff with the default branch.
2020-08-18 17:23:16 +03:00
Sergey Kandaurov 2021aa19fb QUIC: fixed format specifiers. 2020-08-19 16:00:12 +03:00
Sergey Kandaurov 3c988540d9 QUIC: changed c->quic->pto_count type to ngx_uint_t.
This field is served as a simple counter for PTO backoff.
2020-08-19 15:58:03 +03:00
Sergey Kandaurov a62392bdd7 QUIC: do not artificially delay sending queued frames.
This interacts badly with retransmissions of lost packets
and can provoke spurious client retransmits.
2020-08-19 13:24:54 +03:00
Sergey Kandaurov b64d9073fd QUIC: do not arm loss detection timer on packet threshold. 2020-08-19 13:24:53 +03:00
Sergey Kandaurov f53fe3e070 QUIC: do not arm loss detection timer for succeeding packets. 2020-08-19 13:24:47 +03:00
Sergey Kandaurov 7b29edad30 QUIC: handling packets with send time equal to lost send time.
Previously, such packets weren't handled as the resulting zero remaining time
prevented setting the loss detection timer, which, instead, could be disarmed.
For implementation details, see quic-recovery draft 29, appendix A.10.
2020-08-19 13:24:30 +03:00
Sergey Kandaurov 8402cb2f3e QUIC: sending probe packets on PTO timer expiration.
The PTO handler is split into separate PTO and loss detection handlers
that operate interchangeably depending on which timer should be set.

The present ngx_quic_lost_handler is now only used for packet loss detection.
It replaces ngx_quic_pto_handler if there are packets preceeding largest_ack.
Once there is no more such packets, ngx_quic_pto_handler is installed again.

Probes carry unacknowledged data previously sent in the oldest packet number,
one per each packet number space.  That is, it could be up to two probes.

PTO backoff is now increased before scheduling next probes.
2020-08-19 13:24:23 +03:00
Sergey Kandaurov 89121eccf7 QUIC: changed ctx->largest_ack initial value to type maximum.
In particular, this prevents declaring packet number 0 as lost if
there aren't yet any acknowledgements in this packet number space.
For example, only Initial packets were acknowledged in handshake.
2020-08-18 23:33:40 +03:00
Sergey Kandaurov 5ec053cab6 HTTP/3: fixed context storage in request body parser. 2020-08-18 17:11:32 +03:00
Roman Arutyunyan 82df85de1a Merged with the default branch. 2020-08-18 16:22:00 +03:00
Roman Arutyunyan 64c17e86d5 QUIC: coalesce neighbouring stream send buffers.
Previously a single STREAM frame was created for each buffer in stream output
chain which is wasteful with respect to memory.  The following changes were
made in the stream send code:

- ngx_quic_stream_send_chain() no longer calls ngx_quic_stream_send() and got
  a separate implementation that coalesces neighbouring buffers into a single
  frame
- the new ngx_quic_stream_send_chain() respects the limit argument, which fixes
  sendfile_max_chunk and limit_rate
- ngx_quic_stream_send() is reimplemented to call ngx_quic_stream_send_chain()
- stream frame size limit is moved out to a separate function
  ngx_quic_max_stream_frame()
- flow control is moved out to a separate function ngx_quic_max_stream_flow()
- ngx_quic_stream_send_chain() is relocated next to ngx_quic_stream_send()
2020-08-18 12:28:33 +03:00
Sergey Kandaurov 706b5c3d6c QUIC: packet based bytes_in_flight accounting.
A packet size is kept in one of the frames belonging to the packet.
2020-08-14 16:54:13 +03:00
Sergey Kandaurov c62e3d6ece QUIC: fixed leak of bytes_in_flight on keys discard.
This applies to discarding Initial and Handshake keys.
2020-08-14 16:54:06 +03:00
Sergey Kandaurov d0e545b601 QUIC: fixed leak of bytes_in_flight attributed to lost packets. 2020-08-14 16:53:56 +03:00
Maxim Dounin 9752bd5fe6 release-1.19.2 tag 2020-08-11 17:52:30 +03:00
Maxim Dounin 826de4cfbc nginx-1.19.2-RELEASE 2020-08-11 17:52:30 +03:00
Maxim Dounin 32ef2e4b08 Core: reusing connections in advance.
Reworked connections reuse, so closing connections is attempted in
advance, as long as number of free connections is less than 1/16 of
worker connections configured.  This ensures that new connections can
be handled even if closing a reusable connection requires some time,
for example, for a lingering close (ticket #2017).

The 1/16 ratio is selected to be smaller than 1/8 used for disabling
accept when working with accept mutex, so nginx will try to balance
new connections to different workers first, and will start reusing
connections only if this won't help.
2020-08-10 18:53:07 +03:00
Maxim Dounin 56574e093f Core: added a warning about reusing connections.
Previously, reusing connections happened silently and was only
visible in monitoring systems.  This was shown to be not very user-friendly,
and administrators often didn't realize there were too few connections
available to withstand the load, and configured timeouts (keepalive_timeout
and http2_idle_timeout) were effectively reduced to keep things running.

To provide at least some information about this, a warning is now logged
(at most once per second, to avoid flooding the logs).
2020-08-10 18:52:59 +03:00
Maxim Dounin 96c75385ce SSL: disabled sending shutdown after ngx_http_test_reading().
Sending shutdown when ngx_http_test_reading() detects the connection is
closed can result in "SSL_shutdown() failed (SSL: ... bad write retry)"
critical log messages if there are blocked writes.

Fix is to avoid sending shutdown via the c->ssl->no_send_shutdown flag,
similarly to how it is done in ngx_http_keepalive_handler() for kqueue
when pending EOF is detected.

Reported by Jan Prachař
(http://mailman.nginx.org/pipermail/nginx-devel/2018-December/011702.html).
2020-08-10 18:52:34 +03:00
Maxim Dounin 0e790dab12 HTTP/2: fixed c->timedout flag on timed out connections.
Without the flag, SSL shutdown is attempted on such connections,
resulting in useless work and/or bogus "SSL_shutdown() failed
(SSL: ... bad write retry)" critical log messages if there are
blocked writes.
2020-08-10 18:52:20 +03:00
Maxim Dounin 72ab8cd2c5 SSL: fixed shutdown handling.
Previously, bidirectional shutdown never worked, due to two issues
in the code:

1. The code only tested SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE
   when there was an error in the error queue, which cannot happen.
   The bug was introduced in an attempt to fix unexpected error logging
   as reported with OpenSSL 0.9.8g
   (http://mailman.nginx.org/pipermail/nginx/2008-January/003084.html).

2. The code never called SSL_shutdown() for the second time to wait for
   the peer's close_notify alert.

This change fixes both issues.

Note that after this change bidirectional shutdown is expected to work for
the first time, so c->ssl->no_wait_shutdown now makes a difference.  This
is not a problem for HTTP code which always uses c->ssl->no_wait_shutdown,
but might be a problem for stream and mail code, as well as 3rd party
modules.

To minimize the effect of the change, the timeout, which was used to be 30
seconds and not configurable, though never actually used, is now set to
3 seconds.  It is also expanded to apply to both SSL_ERROR_WANT_READ and
SSL_ERROR_WANT_WRITE, so timeout is properly set if writing to the socket
buffer is not possible.
2020-08-10 18:52:09 +03:00
Maxim Dounin 8c8dd9ff3b Request body: optimized handling of small chunks.
If there is a previous buffer, copy small chunks into it instead of
allocating additional buffer.
2020-08-06 05:02:57 +03:00
Maxim Dounin a49ff210f4 Request body: allowed large reads on chunk boundaries.
If some additional data from a pipelined request happens to be
read into the body buffer, we copy it to r->header_in or allocate
an additional large client header buffer for it.
2020-08-06 05:02:55 +03:00
Maxim Dounin 22b2d452e0 Request body: all read data are now sent to filters.
This is a prerequisite for the next change to allow large reads
on chunk boundaries.
2020-08-06 05:02:44 +03:00
Maxim Dounin b281dab3a7 Added size check to ngx_http_alloc_large_header_buffer().
This ensures that copying won't write more than the buffer size
even if the buffer comes from hc->free and it is smaller than the large
client header buffer size in the virtual host configuration.  This might
happen if size of large client header buffers is different in name-based
virtual hosts, similarly to the problem with number of buffers fixed
in 6926:e662cbf1b932.
2020-08-06 05:02:22 +03:00
Roman Arutyunyan 9bcefb54f1 QUIC: handle client RESET_STREAM and STOP_SENDING.
For RESET_STREAM the c->read->error flag is set.
For STOP_SENDING the c->write->error flag is set.
2020-08-03 13:31:48 +03:00
Roman Arutyunyan a814e5049a QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Creating client-initiated streams is moved from ngx_quic_handle_stream_frame()
to a separate function ngx_quic_create_client_stream().  This function is
responsible for creating streams with lower ids as well.

Also, simplified and fixed initial data buffering in
ngx_quic_handle_stream_frame().  It is now done before calling the initial
handler as the handler can destroy the stream.
2020-08-11 19:10:57 +03:00
Roman Arutyunyan 04d6190f86 QUIC: fixed ngx_http_test_reading() for QUIC streams.
Previously this function generated an error trying to figure out if client shut
down the write end of the connection.  The reason for this error was that a
QUIC stream has no socket descriptor.  However checking for eof is not the
right thing to do for an HTTP/3 QUIC stream since HTTP/3 clients are expected
to shut down the write end of the stream after sending the request.

Now the function handles QUIC streams separately.  It checks if c->read->error
is set.  The error flags for c->read and c->write are now set for all streams
when closing the QUIC connection instead of setting the pending_eof flag.
2020-08-11 10:41:39 +03:00
Sergey Kandaurov 25f8b56153 QUIC: fixed ACK Ranges processing.
According to quic-transport draft 29, section 19.3.1:

   The value of the Gap field establishes the largest packet number
   value for the subsequent ACK Range using the following formula:

      largest = previous_smallest - gap - 2

   Thus, given a largest packet number for the range, the smallest value
   is determined by the formula:

      smallest = largest - ack_range

While here, changed min/max to uint64_t for consistency.
2020-08-07 12:34:15 +03:00
Sergey Kandaurov a7b7ca0e0d QUIC: fixed possible use-after-free on stream cleanup.
A QUIC stream could be destroyed by handler while in ngx_quic_stream_input().
To detect this, ngx_quic_find_stream() is used to check that it still exists.

Previously, a stream id was passed to this routine off the frame structure.
In case of stream cleanup, it is freed along with other frames belonging to
the stream on cleanup.  Then, a cleanup handler reuses last frames to update
MAX_STREAMS and serve other purpose.  Thus, ngx_quic_find_stream() is passed
a reused frame with zeroed out part pointed by stream_id.  If a stream with
id 0x0 still exists, this leads to use-after-free.
2020-08-07 12:34:11 +03:00
Sergey Kandaurov 54936090ee QUIC: fixed format specifiers and removed casts. 2020-07-28 18:54:20 +03:00
Sergey Kandaurov 593b3f32d2 QUIC: consistent Stream ID logging format. 2020-07-28 17:11:25 +03:00
Roman Arutyunyan 9fb0feab7d QUIC: added HTTP/3 directives list to README.
Also removed server push from TODO list.
2020-07-28 15:53:42 +03:00
Maxim Dounin 86debc07b0 FastCGI: fixed zero size buf alerts on extra data (ticket #2018).
After 05e42236e95b (1.19.1) responses with extra data might result in
zero size buffers being generated and "zero size buf" alerts in writer
(if f->rest happened to be 0 when processing additional stdout data).
2020-07-27 16:02:15 +03:00
balus c2a03e03bb Core: enclosed parameters of the ngx_buf.h macros in parentheses. 2020-07-27 13:21:51 +03:00
Sergey Kandaurov 8aed171e59 OCSP: fixed certificate reference leak. 2020-07-23 17:31:09 +03:00
Roman Arutyunyan 1cb69c22fa HTTP/3: server pushes.
New directives are added:
- http3_max_concurrent_pushes
- http3_push
- http3_push_preload
2020-07-23 13:41:24 +03:00
Roman Arutyunyan eff039022b QUIC: limited the number of client-initiated streams.
The limits on active bidi and uni client streams are maintained at their
initial values initial_max_streams_bidi and initial_max_streams_uni by sending
a MAX_STREAMS frame upon each client stream closure.

Also, the following is changed for data arriving to non-existing streams:

- if a stream was already closed, such data is ignored
- when creating a new stream, all streams of the same type with lower ids are
  created too
2020-07-27 19:15:17 +03:00
Roman Arutyunyan d6157edc80 QUIC: limited the number of server-initiated streams.
Also, ngx_quic_create_uni_stream() is replaced with
ngx_quic_open_stream() which is capable of creating a bidi stream.
2020-07-27 18:51:42 +03:00
Roman Arutyunyan 88a0db101e Xslt: disabled ranges.
Previously, the document generated by the xslt filter was always fully sent
to client even if a range was requested and response status was 206 with
appropriate Content-Range.

The xslt module is unable to serve a range because of suspending the header
filter chain.  By the moment full response xml is buffered by the xslt filter,
range header filter is not called yet, but the range body filter has already
been called and did nothing.

The fix is to disable ranges by resetting the r->allow_ranges flag much like
the image filter that employs a similar technique.
2020-07-22 22:16:19 +03:00
Ruslan Ermilov 7287c1c2f4 Core: close PID file when writing fails.
Reported by Jinhua Tan.
2020-07-21 20:34:29 +03:00
Roman Arutyunyan da55aaa1f3 HTTP/3: support $server_protocol variable.
Now it holds "HTTP/3.0".  Previously it was empty.
2020-07-14 16:52:44 +03:00
Roman Arutyunyan 6ffd56a4c4 Style: moved function declarations to match usual code style.
Plus a few other minor style changes.
2020-07-23 11:40:10 +03:00
Roman Arutyunyan c7f1f9beb8 HTTP/3: renamed server configuration variables from v3cf to h3scf.
Now they are similar to HTTP/2 where they are called h2scf.
2020-07-23 13:12:01 +03:00
Roman Arutyunyan 9d47ea2ffc HTTP/3: renamed ngx_http_v3.c to ngx_http_v3_encode.c.
The file contains only encoding functions.
2020-07-13 12:38:08 +03:00
Roman Arutyunyan 4de5e5ffbf HTTP/3: encode frame ids with ngx_http_v3_encode_varlen_int().
Even though typically frame ids fit into a single byte, calling
ngx_http_v3_encode_varlen_int() adds to the code clarity.
2020-07-13 12:33:00 +03:00
Roman Arutyunyan 0676bed5c6 HTTP/3: generate Location response header for absolute redirects. 2020-07-23 12:31:40 +03:00
Roman Arutyunyan 459fd8e589 HTTP/3: header encoding functions. 2020-07-13 16:00:00 +03:00
Roman Arutyunyan 3697fe9f72 QUIC: updated README to mention "quic" listen parameter. 2020-07-22 13:45:34 +03:00
Sergey Kandaurov 9bbd65b36a QUIC: fixed bulding perl module by reducing header pollution.
The ngx_http_perl_module module doesn't have a notion of including additional
search paths through --with-cc-opt, which results in compile error incomplete
type 'enum ssl_encryption_level_t' when building nginx without QUIC support.
The enum is visible from quic event headers and eventually pollutes ngx_core.h.

The fix is to limit including headers to compile units that are real consumers.
2020-07-22 14:48:49 +03:00
Roman Arutyunyan e4a574cad4 SSL: fixed compilation without QUIC after 0d2b2664b41c. 2020-07-22 13:34:48 +03:00
Roman Arutyunyan b8698bf9d9 HTTP/3: do not call shutdown() for QUIC streams.
Previously, this triggered an alert "shutdown() failed" in error log.
2020-07-22 11:03:42 +03:00
Roman Arutyunyan 03f7cbabc1 QUIC: eliminated connection handler argument in ngx_quic_run().
Now c->listening->handler() is called instead.
2020-07-21 23:08:23 +03:00
Roman Arutyunyan 049af62328 QUIC: added "quic" listen parameter in Stream.
Also, introduced ngx_stream_quic_module.
2020-07-21 23:08:39 +03:00
Roman Arutyunyan 0c9a1fd9cc QUIC: added "quic" listen parameter.
The parameter allows processing HTTP/0.9-2 over QUIC.

Also, introduced ngx_http_quic_module and moved QUIC settings there
2020-07-21 23:09:22 +03:00
Roman Arutyunyan c1e4763682 QUIC: do not verify the selected ALPN protocol.
The right protocol is selected by the HTTP code.  In the QUIC code only verify
that some protocol was selected and trigger an error otherwise.
2020-07-18 00:08:04 +03:00
Roman Arutyunyan fa3392dc10 QUIC: fixed stream read event log.
Previously, the main connection log was there.  Now it's the stream connection
log.
2020-07-18 00:08:29 +03:00
Sergey Kandaurov 2e5c317431 Fixed format specifiers. 2020-07-20 15:19:03 +03:00
Vladimir Homutov 288a3eef97 QUIC: added anti-amplification limit.
According to quic-transport draft 29, section 21.12.1.1:

   Prior to validation, endpoints are limited in what they are able to
   send.  During the handshake, a server cannot send more than three
   times the data it receives; clients that initiate new connections or
   migrate to a new network path are limited.
2020-07-16 16:36:02 +03:00
Vladimir Homutov 497a37971f QUIC: added limit of queued data.
The ngx_quic_queue_frame() functions puts a frame into send queue and
schedules a push timer to actually send data.

The patch adds tracking for data amount in the queue and sends data
immediately if amount of data exceeds limit.
2020-07-16 15:02:38 +03:00
Vladimir Homutov 6771c2464b QUIC: implemented probe timeout (PTO) calculation. 2020-07-16 16:05:44 +03:00
Vladimir Homutov eefc09faa7 QUIC: reworked retransmission mechanism.
Instead of timer-based retransmissions with constant packet lifetime,
this patch implements ack-based loss detection and probe timeout
for the cases, when no ack is received, according to the quic-recovery
draft 29.
2020-07-13 17:31:29 +03:00
Vladimir Homutov 108baa4d33 QUIC: reworked ngx_quic_send_frames() function.
Instead of returning NGX_DONE/NGX_OK, the function now itself moves
passed frames range into sent queue and sets PTO timer if required.
2020-07-15 15:10:17 +03:00
Vladimir Homutov 37d1ec06ef QUIC: renaming.
The c->quic->retransmit timer is now called "pto".
The ngx_quic_retransmit() function is renamed to "ngx_quic_detect_lost()".

This is a preparation for the following patches.
2020-07-13 10:07:15 +03:00
Vladimir Homutov fa72cd0ce7 QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
To minimize difference with the following changes.
2020-07-13 10:07:20 +03:00
Vladimir Homutov 36d8584477 QUIC: delay field of an ACK frame is now calculated. 2020-07-10 15:33:51 +03:00
Vladimir Homutov 2141a5e0a2 QUIC: added rtt estimation.
According to the quic-recovery 29, Section 5: Estimating the Round-Trip Time.

Currently, integer arithmetics is used, which loses sub-millisecond accuracy.
2020-07-16 15:44:06 +03:00
Sergey Kandaurov 2107ce98ba Merged with the default branch. 2020-07-13 15:34:22 +03:00
Roman Arutyunyan 3ae88f0b8d Slice filter: clear original Accept-Ranges.
The slice filter allows ranges for the response by setting the r->allow_ranges
flag, which enables the range filter.  If the range was not requested, the
range filter adds an Accept-Ranges header to the response to signal the
support for ranges.

Previously, if an Accept-Ranges header was already present in the first slice
response, client received two copies of this header.  Now, the slice filter
removes the Accept-Ranges header from the response prior to setting the
r->allow_ranges flag.
2020-07-09 16:21:37 +03:00
Roman Arutyunyan 092fa3d12c Version bump. 2020-07-09 17:33:22 +03:00
Maxim Dounin 5b77a9862b release-1.19.1 tag 2020-07-07 18:56:06 +03:00
Maxim Dounin 6cdb5e572c nginx-1.19.1-RELEASE 2020-07-07 18:56:05 +03:00
Maxim Dounin e757117c04 gRPC: generate error when response size is wrong.
As long as the "Content-Length" header is given, we now make sure
it exactly matches the size of the response.  If it doesn't,
the response is considered malformed and must not be forwarded
(https://tools.ietf.org/html/rfc7540#section-8.1.2.6).  While it
is not really possible to "not forward" the response which is already
being forwarded, we generate an error instead, which is the closest
equivalent.

Previous behaviour was to pass everything to the client, but this
seems to be suboptimal and causes issues (ticket #1695).  Also this
directly contradicts HTTP/2 specification requirements.

Note that the new behaviour for the gRPC proxy is more strict than that
applied in other variants of proxying.  This is intentional, as HTTP/2
specification requires us to do so, while in other types of proxying
malformed responses from backends are well known and historically
tolerated.
2020-07-06 18:36:25 +03:00
Maxim Dounin 1f7aab0d12 FastCGI: protection from responses with wrong length.
Previous behaviour was to pass everything to the client, but this
seems to be suboptimal and causes issues (ticket #1695).  Fix is to
drop extra data instead, as it naturally happens in most clients.

Additionally, we now also issue a warning if the response is too
short, and make sure the fact it is truncated is propagated to the
client.  The u->error flag is introduced to make it possible to
propagate the error to the client in case of unbuffered proxying.

For responses to HEAD requests there is an exception: we do allow
both responses without body and responses with body matching the
Content-Length header.
2020-07-06 18:36:23 +03:00
Maxim Dounin f0c778db04 Upstream: drop extra data sent by upstream.
Previous behaviour was to pass everything to the client, but this
seems to be suboptimal and causes issues (ticket #1695).  Fix is to
drop extra data instead, as it naturally happens in most clients.

This change covers generic buffered and unbuffered filters as used
in the scgi and uwsgi modules.  Appropriate input filter init
handlers are provided by the scgi and uwsgi modules to set corresponding
lengths.

Note that for responses to HEAD requests there is an exception:
we do allow any response length.  This is because responses to HEAD
requests might be actual full responses, and it is up to nginx
to remove the response body.  If caching is enabled, only full
responses matching the Content-Length header will be cached
(see b779728b180c).
2020-07-06 18:36:22 +03:00
Maxim Dounin 5a04e1ee79 Proxy: style. 2020-07-06 18:36:21 +03:00
Maxim Dounin 5433f7700a Proxy: detection of data after final chunk.
Previously, additional data after final chunk was either ignored
(in the same buffer, or during unbuffered proxying) or sent to the
client (in the next buffer already if it was already read from the
socket).  Now additional data are properly detected and ignored
in all cases.  Additionally, a warning is now logged and keepalive
is disabled in the connection.
2020-07-06 18:36:20 +03:00
Maxim Dounin 0853f59982 Proxy: drop extra data sent by upstream.
Previous behaviour was to pass everything to the client, but this
seems to be suboptimal and causes issues (ticket #1695).  Fix is to
drop extra data instead, as it naturally happens in most clients.
2020-07-06 18:36:19 +03:00
Maxim Dounin e4bdc6d747 Memcached: protect from too long responses.
If a memcached response was followed by a correct trailer, and then
the NUL character followed by some extra data - this was accepted by
the trailer checking code.  This in turn resulted in ctx->rest underflow
and caused negative size buffer on the next reading from the upstream,
followed by the "negative size buf in writer" alert.

Fix is to always check for too long responses, so a correct trailer cannot
be followed by extra data.
2020-07-06 18:36:17 +03:00
Ruslan Ermilov 5008985e09 HTTP/2: lingering close after GOAWAY.
After sending the GOAWAY frame, a connection is now closed using
the lingering close mechanism.

This allows for the reliable delivery of the GOAWAY frames, while
also fixing connection resets observed when http2_max_requests is
reached (ticket #1250), or with graceful shutdown (ticket #1544),
when some additional data from the client is received on a fully
closed connection.

For HTTP/2, the settings lingering_close, lingering_timeout, and
lingering_time are taken from the "server" level.
2020-07-03 16:16:47 +03:00
Roman Arutyunyan 1258c98695 HTTP/3: simplified handling return codes from parse functions. 2020-07-02 20:07:24 +03:00
Roman Arutyunyan 4ba5f50fb2 HTTP/3: put ngx_http_v3_parse_varlen_int() return code in variable.
This makes calling this function similar to other parse functions.
2020-07-03 12:07:43 +03:00
Roman Arutyunyan 9db31cffb4 HTTP/3: simplifed handling ngx_http_v3_parse_literal() return code. 2020-07-03 12:05:05 +03:00
Roman Arutyunyan fd81c91474 HTTP/3: limited prefixed integer size by 62 bits. 2020-07-03 09:26:12 +03:00
Roman Arutyunyan fa9142e87f HTTP/3: fixed overflow in prefixed integer parser.
Previously, the expression (ch & 0x7f) was promoted to a signed integer.
Depending on the platform, the size of this integer could be less than 8 bytes,
leading to overflow when handling the higher bits of the result.  Also, sign
bit of this integer could be replicated when adding to the 64-bit st->value.
2020-07-03 16:41:31 +03:00
Sergey Kandaurov 7fa11fe28b HTTP/3: fixed prefix in decoding Section Acknowledgement. 2020-07-02 17:35:57 +03:00
Roman Arutyunyan 1e59bcec9b HTTP/3: set r->headers_in.chunked flag after parsing headers.
Previously it was set when creating the request object.  The side-effect was
trying to discard the request body in case of header parse error.
2020-06-30 15:32:09 +03:00
Roman Arutyunyan df0a95b586 HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Previously errors led only to closing streams.

To simplify closing QUIC connection from a QUIC stream context, new macro
ngx_http_v3_finalize_connection() is introduced.  It calls
ngx_quic_finalize_connection() for the parent connection.
2020-07-02 16:47:51 +03:00
Roman Arutyunyan a3fd09e793 HTTP/3: error code definitions for HTTP/3 and QPACK. 2020-06-30 12:30:57 +03:00
Roman Arutyunyan 601c9c8886 QUIC: Introduced ngx_quic_finalize_connection().
The function finalizes QUIC connection with an application protocol error
code and sends a CONNECTION_CLOSE frame with type=0x1d.

Also, renamed NGX_QUIC_FT_CONNECTION_CLOSE2 to NGX_QUIC_FT_CONNECTION_CLOSE_APP.
2020-07-02 16:33:59 +03:00
Roman Arutyunyan 11e75ce4bc HTTP/3: downgraded literal size error level to NGX_LOG_INFO.
Now it's similar to HTTP/2.
2020-07-02 16:33:36 +03:00
Roman Arutyunyan 8a99b8cabd HTTP/3: refactored dynamic table implementation.
Previously dynamic table was not functional because of zero limit on its size
set by default.  Now the following changes enable it:

- new directives to set SETTINGS_QPACK_MAX_TABLE_CAPACITY and
  SETTINGS_QPACK_BLOCKED_STREAMS
- send settings with SETTINGS_QPACK_MAX_TABLE_CAPACITY and
  SETTINGS_QPACK_BLOCKED_STREAMS to the client
- send Insert Count Increment to the client
- send Header Acknowledgement to the client
- evict old dynamic table entries on overflow
- decode Required Insert Count from client
- block stream if Required Insert Count is not reached
2020-07-02 15:34:05 +03:00
Roman Arutyunyan 902358052c HTTP/3: fixed prefixed integer encoding and decoding.
Previously bytes were ordered from MSB to LSB, but the right order is the
reverse.
2020-07-02 15:15:55 +03:00
Maxim Dounin bd0efda3da SSL: fixed unexpected certificate requests (ticket #2008).
Using SSL_CTX_set_verify(SSL_VERIFY_PEER) implies that OpenSSL will
send a certificate request during an SSL handshake, leading to unexpected
certificate requests from browsers as long as there are any client
certificates installed.  Given that ngx_ssl_trusted_certificate()
is called unconditionally by the ngx_http_ssl_module, this affected
all HTTPS servers.  Broken by 699f6e55bbb4 (not released yet).

Fix is to set verify callback in the ngx_ssl_trusted_certificate() function
without changing the verify mode.
2020-06-29 17:15:51 +03:00
Roman Arutyunyan 9e72031709 HTTP/3: http3_max_field_size directive to limit string size.
Client streams may send literal strings which are now limited in size by the
new directive.  The default value is 4096.

The directive is similar to HTTP/2 directive http2_max_field_size.
2020-06-29 15:56:14 +03:00
Roman Arutyunyan 9eae53813f HTTP/3: introduced ngx_http_v3_get_module_srv_conf() macro.
The macro helps to access a module's server configuration from a QUIC
stream context.
2020-06-26 11:58:00 +03:00
Roman Arutyunyan 865e4f4e16 HTTP/3: fixed dropping first non-pseudo header. 2020-06-26 10:05:28 +03:00
Sergey Kandaurov 45440e5519 HTTP/3: do not emit a DATA frame header for header_only responses.
This resulted in the frame error due to the invalid DATA frame length.
2020-06-25 20:31:13 +03:00
Vladimir Homutov 21ffa1fea0 Style. 2020-06-19 11:29:30 +03:00
Sergey Kandaurov 98a1c01bb6 README: documented draft-28, draft-29 support. 2020-06-23 11:57:00 +03:00
Sergey Kandaurov a07fa1cbf4 Update Initial salt and Retry secret from quic-tls-29.
See sections 5.2 and 5.8 for the current values.
2020-06-23 11:57:00 +03:00
Sergey Kandaurov 7731665186 Get rid of hardcoded numbers used for quic handshake errors. 2020-06-23 11:57:00 +03:00
Sergey Kandaurov 8634e4d110 Discard short packets which could not be decrypted.
So that connections are protected from failing from on-path attacks.
Decryption failure of long packets used during handshake still leads
to connection close since it barely makes sense to handle them there.
2020-06-23 11:57:00 +03:00
Sergey Kandaurov 4bec083118 Close connection with PROTOCOL_VIOLATION on decryption failure.
A previously used undefined error code is now replaced with the generic one.

Note that quic-transport prescribes keeping connection intact, discarding such
QUIC packets individually, in the sense that coalesced packets could be there.
This is selectively handled in the next change.
2020-06-23 11:57:00 +03:00
Sergey Kandaurov 79cbb7167c Define KEY_UPDATE_ERROR from quic-tls-24. 2020-06-23 11:57:00 +03:00
Sergey Kandaurov 3c79cc18f3 Reject new QUIC connection with CONNECTION_REFUSED on shutdown. 2020-06-23 11:57:00 +03:00
Sergey Kandaurov 14b468b6ae Close QUIC connection with NO_ERROR on c->close.
That way it makes more sense.  Previously it was closed with INTERNAL_ERROR.
2020-06-23 11:57:00 +03:00
Sergey Kandaurov 75c37350c2 Do not close QUIC sockets in ngx_close_listening_sockets().
This breaks graceful shutdown of QUIC connections in terms of quic-transport.
2020-06-23 11:57:00 +03:00
Sergey Kandaurov 5e12fc0fb0 QUIC error SERVER_BUSY renamed to CONNECTION_REFUSED in draft-29. 2020-06-23 11:57:00 +03:00
Vladimir Homutov b1628fe8de QUIC: cleaned up quic encryption state tracking.
The patch removes remnants of the old state tracking mechanism, which did
not take into account assimetry of read/write states and was not very
useful.

The encryption state now is entirely tracked using SSL_quic_read/write_level().
2020-06-18 14:29:24 +03:00
Vladimir Homutov d934c2b980 QUIC: added ALPN checks.
quic-transport draft 29:

    section 7:

    *  authenticated negotiation of an application protocol (TLS uses
       ALPN [RFC7301] for this purpose)

    ...

    Endpoints MUST explicitly negotiate an application protocol.  This
    avoids situations where there is a disagreement about the protocol
    that is in use.

    section 8.1:

    When using ALPN, endpoints MUST immediately close a connection (see
    Section 10.3 of [QUIC-TRANSPORT]) with a no_application_protocol TLS
    alert (QUIC error code 0x178; see Section 4.10) if an application
    protocol is not negotiated.

Changes in ngx_quic_close_quic() function are required to avoid attempts
to generated and send packets without proper keys, what happens in case
of failed ALPN check.
2020-06-18 13:58:46 +03:00
Vladimir Homutov 2a006072aa QUIC: fixed off-by-one in frame range handler.
The ctx->pnum is incremented after the packet is sent, thus pointing to the
next packet number, which should not be used in comparison.
2020-06-18 11:16:35 +03:00
Vladimir Homutov 085547cfc0 QUIC: further limiting maximum QUIC packet size.
quic-transport draft 29, section 14:

    QUIC depends upon a minimum IP packet size of at least 1280 bytes.
    This is the IPv6 minimum size [RFC8200] and is also supported by most
    modern IPv4 networks.  Assuming the minimum IP header size, this
    results in a QUIC maximum packet size of 1232 bytes for IPv6 and 1252
    bytes for IPv4.

Since the packet size can change during connection lifetime, the
ngx_quic_max_udp_payload() function is introduced that currently
returns minimal allowed size, depending on address family.
2020-06-16 11:54:05 +03:00
Vladimir Homutov bd10b24229 QUIC: raise error on missing transport parameters.
quic-tls, 8.2:

    The quic_transport_parameters extension is carried in the ClientHello
    and the EncryptedExtensions messages during the handshake.  Endpoints
    MUST send the quic_transport_parameters extension; endpoints that
    receive ClientHello or EncryptedExtensions messages without the
    quic_transport_parameters extension MUST close the connection with an
    error of type 0x16d (equivalent to a fatal TLS missing_extension
    alert, see Section 4.10).
2020-06-15 17:06:40 +03:00
Vladimir Homutov b3d75381c7 QUIC: Fixed connection cleanup.
A posted event need to be deleted during the connection close.
2020-06-15 16:59:53 +03:00
Eran Kornblau 2aaa7b63b7 Fixed potential leak of temp pool.
In case ngx_hash_add_key() fails, need to goto failed instead of returning,
so that temp_pool will be destoryed.
2020-06-15 03:58:31 -04:00
Maxim Dounin b6eef24479 Cache: introduced min_free cache clearing.
Clearing cache based on free space left on a file system is
expected to allow better disk utilization in some cases, notably
when disk space might be also used for something other than nginx
cache (including nginx own temporary files) and while loading
cache (when cache size might be inaccurate for a while, effectively
disabling max_size cache clearing).

Based on a patch by Adam Bambuch.
2020-06-22 18:03:00 +03:00
Maxim Dounin 853e43ecd0 Too large st_blocks values are now ignored (ticket #157).
With XFS, using "allocsize=64m" mount option results in large preallocation
being reported in the st_blocks as returned by fstat() till the file is
closed.  This in turn results in incorrect cache size calculations and
wrong clearing based on max_size.

To avoid too aggressive cache clearing on such volumes, st_blocks values
which result in sizes larger than st_size and eight blocks (an arbitrary
limit) are no longer trusted, and we use st_size instead.

The ngx_de_fs_size() counterpart is intentionally not modified, as
it is used on closed files and hence not affected by this problem.
2020-06-22 18:02:59 +03:00
Maxim Dounin 7b991edb4b Large block sizes on Linux are now ignored (ticket #1168).
NFS on Linux is known to report wsize as a block size (in both f_bsize
and f_frsize, both in statfs() and statvfs()).  On the other hand,
typical file system block sizes on Linux (ext2/ext3/ext4, XFS) are limited
to pagesize.  (With FAT, block sizes can be at least up to 512k in
extreme cases, but this doesn't really matter, see below.)
To avoid too aggressive cache clearing on NFS volumes on Linux, block
sizes larger than pagesize are now ignored.

Note that it is safe to ignore large block sizes.  Since 3899:e7cd13b7f759
(1.0.1) cache size is calculated based on fstat() st_blocks, and rounding
to file system block size is preserved mostly for Windows.

Note well that on other OSes valid block sizes seen are at least up
to 65536.  In particular, UFS on FreeBSD is known to work well with block
and fragment sizes set to 65536.
2020-06-22 18:02:58 +03:00
Roman Arutyunyan c991549a4e OCSP: fixed use-after-free on error.
When validating second and further certificates, ssl callback could be called
twice to report the error.  After the first call client connection is
terminated and its memory is released.  Prior to the second call and in it
released connection memory is accessed.

Errors triggering this behavior:
- failure to create the request
- failure to start resolving OCSP responder name
- failure to start connecting to the OCSP responder

The fix is to rearrange the code to eliminate the second call.
2020-06-15 20:17:16 +03:00
Quantum f7954e72ba Correctly flush request body to uwsgi with SSL.
The flush flag was not set when forwarding the request body to the uwsgi
server. When using uwsgi_pass suwsgi://..., this causes the uwsgi server
to wait indefinitely for the request body and eventually time out due to
SSL buffering.

This is essentially the same change as 4009:3183165283cc, which was made
to ngx_http_proxy_module.c.

This will fix the uwsgi bug https://github.com/unbit/uwsgi/issues/1490.
2020-06-15 17:35:26 -04:00
Vladimir Homutov 3cb92e42a8 Style. 2020-06-10 21:37:48 +03:00
Vladimir Homutov e16023a735 Limited max udp payload size for outgoing packets.
This allows to avoid problems with packet fragmentation in real networks.
This is a temporary workaround.
2020-06-10 21:37:08 +03:00
Vladimir Homutov 3239735a54 Increased default initial retransmit timeout.
This is a temporary workaround, proper retransmission mechanism based on
quic-recovery rfc draft is yet to be implemented.

Currently hardcoded value is too small for real networks.  The patch
sets static PTO, considering rtt of ~333ms, what gives about 1s.
2020-06-10 21:33:20 +03:00
Vladimir Homutov b5436b1bcc Fixed usage of own/client transport parameters. 2020-06-10 21:23:10 +03:00
Vladimir Homutov 586ffd9b41 Stream: fixed processing of zero length UDP packets (ticket #1982). 2020-06-08 11:40:34 +03:00
Sergey Kandaurov 6f6e3e6e67 Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED. 2020-06-05 20:59:27 +03:00
Sergey Kandaurov 9c1b503837 Stream ID handling in RESET_STREAM and STOP_SENDING frames. 2020-06-05 20:59:27 +03:00
Sergey Kandaurov 9922e9a4db Reject invalid STREAM ID with STREAM_STATE_ERROR connection error. 2020-06-05 20:59:26 +03:00
Sergey Kandaurov ae303e8ef9 Introduced connection error APPLICATION_ERROR from draft-28. 2020-06-05 13:20:03 +03:00
Sergey Kandaurov 250ff7c03c Receipt of CONNECTION_CLOSE in 0-RTT is permitted in draft-28. 2020-06-05 13:20:02 +03:00
Sergey Kandaurov 894a1af249 Treat receipt of NEW_TOKEN as connection error PROTOCOL_VIOLATION. 2020-06-05 13:20:02 +03:00
Maxim Dounin 858609acd8 SSL: added verify callback to ngx_ssl_trusted_certificate().
This ensures that certificate verification is properly logged to debug
log during upstream server certificate verification.  This should help
with debugging various certificate issues.
2020-06-03 19:11:32 +03:00
Roman Arutyunyan dfb9f8fa7b Decoupled validation of Host and :authority for HTTP/2 and HTTP/3.
Previously an error was triggered for HTTP/2 when host with port was passed
by client.
2020-06-02 15:59:14 +03:00
Ruslan Ermilov 0ffe3f60cb Fixed SIGQUIT not removing listening UNIX sockets (closes #753).
Listening UNIX sockets were not removed on graceful shutdown, preventing
the next runs.  The fix is to replace the custom socket closing code in
ngx_master_process_cycle() by the ngx_close_listening_sockets() call.
2020-06-01 22:31:23 +03:00
Ruslan Ermilov c00dbb3971 Fixed removing of listening UNIX sockets when "changing binary".
When changing binary, sending a SIGTERM to the new binary's master process
should not remove inherited UNIX sockets unless the old binary's master
process has exited.
2020-06-01 20:19:27 +03:00
Sergey Kandaurov 3ff3f33fe7 Compatibility with BoringSSL master branch.
Recently BoringSSL introduced SSL_set_quic_early_data_context()
that serves as an additional constrain to enable 0-RTT in QUIC.

Relevant changes:
 * https://boringssl.googlesource.com/boringssl/+/7c52299%5E!/
 * https://boringssl.googlesource.com/boringssl/+/8519432%5E!/
2020-06-01 19:53:13 +03:00
Sergey Kandaurov a8f6ffe53d Fixed transport parameters on a new connection with a valid token.
Previously, the retry transport parameter was sent regardless.
2020-06-01 19:16:44 +03:00
Roman Arutyunyan fcb3cd9ae0 Require ":authority" or "Host" in HTTP/3 and HTTP/2 requests.
Also, if both are present, require that they have the same value.  These
requirements are specified in HTTP/3 draft 28.

Current implementation of HTTP/2 treats ":authority" and "Host"
interchangeably.  New checks only make sure at least one of these values is
present in the request.  A similar check existed earlier and was limited only
to HTTP/1.1 in 38c0898b6df7.
2020-05-29 12:42:23 +03:00
Vladimir Homutov 3a1ddd803b Added propagation of the "wildcard" flag to c->listening.
The flags was originally added by 8f038068f4bc, and is propagated correctly
in the stream module.  With QUIC introduction, http module now uses datagram
sockets as well, thus the fix.
2020-05-29 13:29:24 +03:00
Sergey Kandaurov 59a7a800e1 Made NGX_QUIC_DRAFT_VERSION tunable from configure parameters.
Now it can be switched using --with-cc-opt='-DNGX_QUIC_DRAFT_VERSION=28'.
2020-05-29 15:07:46 +03:00
Sergey Kandaurov eefeb8ed3e QUIC draft-28 transport parameters support.
Draft-27 and draft-28 support can now be enabled interchangeably,
it's based on the compile-time macro NGX_QUIC_DRAFT_VERSION.
2020-05-29 15:06:33 +03:00
Sergey Kandaurov e076bf84bb Introduced macros for building length-value transport parameters. 2020-05-29 13:05:57 +03:00
Sergey Kandaurov 892adedeb8 Renamed max_packet_size to max_udp_payload_size, from draft-28.
No functional changes.
2020-05-29 12:56:08 +03:00
Sergey Kandaurov e2570743bb Rejected forbidden transport parameters with TRANSPORT_PARAMETER_ERROR. 2020-05-29 12:55:39 +03:00
Sergey Kandaurov a10e9100a7 Fixed return codes in ngx_quic_add_handshake_data() callback. 2020-05-29 12:50:20 +03:00
Sergey Kandaurov 8ead0f088d README: update after merging 1.19.0. 2020-05-26 20:41:43 +03:00
Sergey Kandaurov ec7d07eac8 Merged with the default branch. 2020-05-26 20:26:44 +03:00
Gena Makhomed 2583b4994d Contrib: vim syntax, update core and 3rd party module directives. 2020-05-26 19:17:11 +03:00
Maxim Dounin 4df960954b Version bump. 2020-05-26 22:03:00 +03:00
Maxim Dounin c7b17a1468 release-1.19.0 tag 2020-05-26 18:00:20 +03:00
Maxim Dounin 86dcfc4dfb nginx-1.19.0-RELEASE 2020-05-26 18:00:20 +03:00
Maxim Dounin 01b3f95a78 Updated OpenSSL used for win32 builds. 2020-05-25 22:10:37 +03:00
Vladimir Homutov abb49cc7cc Updated README with "Contributing" section and draft details. 2020-05-25 18:37:43 +03:00
Maxim Dounin cb4f81dd71 HTTP/2: invalid connection preface logging (ticket #1981).
Previously, invalid connection preface errors were only logged at debug
level, providing no visible feedback, in particular, when a plain text
HTTP/2 listening socket is erroneously used for HTTP/1.x connections.
Now these are explicitly logged at the info level, much like other
client-related errors.
2020-05-25 18:33:42 +03:00
Sergey Kandaurov 44b841fccb Fixed format specifiers. 2020-05-23 15:53:08 +03:00
Roman Arutyunyan 4ff6dca06e OCSP: certificate status cache.
When enabled, certificate status is stored in cache and is used to validate
the certificate in future requests.

New directive ssl_ocsp_cache is added to configure the cache.
2020-05-22 17:25:27 +03:00
Roman Arutyunyan 9c7b6a5bea SSL: client certificate validation with OCSP (ticket #1534).
OCSP validation for client certificates is enabled by the "ssl_ocsp" directive.
OCSP responder can be optionally specified by "ssl_ocsp_responder".

When session is reused, peer chain is not available for validation.
If the verified chain contains certificates from the peer chain not available
at the server, validation will fail.
2020-05-22 17:30:12 +03:00
Roman Arutyunyan 7b35d3ef69 OCSP stapling: iterate over all responder addresses.
Previously only the first responder address was used per each stapling update.
Now, in case of a network or parsing error, next address is used.

This also fixes the issue with unsupported responder address families
(ticket #1330).
2020-05-22 20:35:05 +03:00
Roman Arutyunyan aa25f7cbcd OCSP stapling: keep extra chain in the staple object. 2020-05-17 14:24:35 +03:00
Roman Arutyunyan bf8e1fc66f HTTP/3: reallocate strings inserted into the dynamic table.
They should always be allocated from the main QUIC connection pool.
2020-05-14 16:02:32 +03:00
Roman Arutyunyan 278d5912aa Fixed client buffer reallocation for HTTP/3.
Preserving pointers within the client buffer is not needed for HTTP/3 because
all data is either allocated from pool or static.  Unlike with HTTP/1, data
typically cannot be referenced directly within the client buffer.  Trying to
preserve NULLs or external pointers lead to broken pointers.

Also, reverted changes in ngx_http_alloc_large_header_buffer() not relevant
for HTTP/3 to minimize diff to mainstream.
2020-05-19 16:20:33 +03:00
Roman Arutyunyan 34ac45d0a8 Fixed $request_length for HTTP/3.
New field r->parse_start is introduced to substitute r->request_start and
r->header_name_start for request length accounting.  These fields only work for
this purpose in HTTP/1 because HTTP/1 request line and header line start with
these values.

Also, error logging is now fixed to output the right part of the request.
2020-05-19 15:47:37 +03:00
Roman Arutyunyan e6c8d371a7 HTTP/3: restricted symbols in header names.
As per HTTP/3 draft 27, a request or response containing uppercase header
field names MUST be treated as malformed.  Also, existing rules applied
when parsing HTTP/1 header names are also applied to HTTP/3 header names:

- null character is not allowed
- underscore character may or may not be treated as invalid depending on the
  value of "underscores_in_headers"
- all non-alphanumeric characters with the exception of '-' are treated as
  invalid

Also, the r->locase_header field is now filled while parsing an HTTP/3
header.

Error logging for invalid headers is fixed as well.
2020-05-19 15:34:00 +03:00
Roman Arutyunyan 28bcacbe7a HTTP/3: split header parser in two functions.
The first one parses pseudo-headers and is analagous to the request line
parser in HTTP/1.  The second one parses regular headers and is analogous to
the header parser in HTTP/1.

Additionally, error handling of client passing malformed uri is now fixed.
2020-05-19 15:29:10 +03:00
Roman Arutyunyan 35586c3acb HTTP/3: move body parser call out of ngx_http_parse_chunked().
The function ngx_http_parse_chunked() is also called from the proxy module to
parse the upstream response.  It should always parse HTTP/1 body in this case.
2020-05-14 14:49:53 +03:00
Roman Arutyunyan 4ad1869197 HTTP/3: prevent array access by negative index for unknown streams.
Currently there are no such streams, but the function
ngx_http_v3_get_uni_stream() supports them.
2020-05-19 15:41:41 +03:00
Sergey Kandaurov 85bf88ffa8 README: documented Retry, 0-RTT, TLSv1.3 configuration. 2020-05-23 14:41:08 +03:00
Vladimir Homutov c39e666583 Style.
Rephrased error message and removed trailing space.  Long comments were
shortened/rephrased.
2020-05-21 15:48:39 +03:00
Vladimir Homutov b46205cae6 Added sending of extra CONNECTION_CLOSE frames.
According to quic-transport draft 28 section 10.3.1:

   When sending CONNECTION_CLOSE, the goal is to ensure that the peer
   will process the frame.  Generally, this means sending the frame in a
   packet with the highest level of packet protection to avoid the
   packet being discarded.  After the handshake is confirmed (see
   Section 4.1.2 of [QUIC-TLS]), an endpoint MUST send any
   CONNECTION_CLOSE frames in a 1-RTT packet.  However, prior to
   confirming the handshake, it is possible that more advanced packet
   protection keys are not available to the peer, so another
   CONNECTION_CLOSE frame MAY be sent in a packet that uses a lower
   packet protection level.
2020-05-22 18:14:35 +03:00
Vladimir Homutov e19c3c0399 Added more context to CONNECTION CLOSE frames.
Now it is possible to specify frame type that caused an error
and a human-readable reason phrase.
2020-05-22 18:08:02 +03:00
Vladimir Homutov bf08ad6564 Fixed retransmission of frames after closing connection.
Frames in sent queues are discarded, as no acknowledgment is expected
if the connection is closing.
2020-05-21 15:41:01 +03:00
Vladimir Homutov 742ea8420e Avoided excessive definitions for connection state.
There is no need in a separate type for the QUIC connection state.
The only state not found in the SSL library is NGX_QUIC_ST_UNAVAILABLE,
which is actually a flag used by the ngx_quic_close_quic() function
to prevent cleanup of uninitialized connection.
2020-05-21 15:38:52 +03:00
Sergey Kandaurov 620dfec5cb README: pointed out Alt-Svc "ma" parameter useful with curl. 2020-05-22 18:22:00 +03:00
Vladimir Homutov 8cf95255ac Fixed a typo. 2020-05-22 18:16:34 +03:00
Sergey Kandaurov 930c135a02 Assorted fixes.
Found by Clang Static Analyzer.
2020-05-20 15:36:24 +03:00
Vladimir Homutov 0982c2ee43 Avoid retransmitting of packets with discarded keys.
Sections 4.10.1 and 4.10.2 of quic transport describe discarding of initial
and handshake keys.  Since the keys are discarded, we no longer need
to retransmit packets and corresponding queues should be emptied.

This patch removes previously added workaround that did not require
acknowledgement for initial packets, resulting in avoiding retransmission,
which is wrong because a packet could be lost and we have to retransmit it.
2020-05-18 13:54:53 +03:00
Vladimir Homutov d39920689b Fixed frame retransmissions.
It was possible that retransmit timer was not set after the first
retransmission attempt, due to ngx_quic_retransmit() did not set
wait time properly, and the condition in retransmit handler was incorrect.
2020-05-18 13:54:35 +03:00
Vladimir Homutov 7d4864b89a Removed outdated debug. 2020-05-14 18:10:53 +03:00
Vladimir Homutov c18864a097 Fixed a typo. 2020-05-14 17:22:29 +03:00
Sergey Kandaurov 7005f46678 README: Retry support, protocol error messages implemented. 2020-05-14 16:33:46 +03:00
Vladimir Homutov 2b8786afe8 Fixed time comparison. 2020-05-12 18:45:44 +03:00
Vladimir Homutov 685b42cef6 Added tests for connection id lengths in initial packet. 2020-05-14 14:49:28 +03:00
Vladimir Homutov aa4f97dd73 Discard packets without fixed bit or reserved bits set.
Section 17.2 and 17.3 of QUIC transport:

Fixed bit: Packets containing a zero value for this bit are not
valid packets in this version and MUST be discarded.

Reserved bit: An endpoint MUST treat receipt of a packet that has
a non-zero value for these bits, after removing both packet and
header protection, as a connection error of type PROTOCOL_VIOLATION.
2020-05-14 01:06:45 +03:00
Vladimir Homutov b507229c73 Added generation of CC frames with error on connection termination.
When an error occurs, then c->quic->error field may be populated
with an appropriate error code, and the CONNECTION CLOSE frame will be
sent to the peer before the connection is closed.  Otherwise, the error
treated as internal and INTERNAL_ERROR code is sent.

The pkt->error field is populated by functions processing packets to
indicate an error when it does not fit into pass/fail return status.
2020-05-14 15:54:45 +03:00
Sergey Kandaurov 4d3b28b39c Address validation using NEW_TOKEN frame. 2020-05-14 15:47:24 +03:00
Sergey Kandaurov fbff14f583 Address validation using Retry packets.
The behaviour is toggled with the new directive "quic_retry on|off".
QUIC token construction is made suitable for issuing with NEW_TOKEN.
2020-05-14 15:47:18 +03:00
Sergey Kandaurov 92324d157c Server CID change refactored. 2020-05-13 18:34:34 +03:00
Sergey Kandaurov b6e8c1b542 Preserve original DCID and unbreak parsing 0-RTT packets.
As per QUIC transport, the first flight of 0-RTT packets obviously uses same
Destination and Source Connection ID values as the client's first Initial.

The fix is to match 0-RTT against original DCID after it has been switched.
2020-05-12 18:18:58 +03:00
Sergey Kandaurov 95ff5f6be4 Removed redundant long packet type checks. 2020-05-09 17:41:07 +03:00
Sergey Kandaurov a05371cf9e Removed redundant SSL_do_handshake call before any handshake data. 2020-05-09 17:39:47 +03:00
Vladimir Homutov 72b6655e9c Cleaned up reordering code.
The ordered frame handler is always called for the existing stream, as it is
allocated from this stream.  Instead of searching stream by id, pointer to the
stream node is passed.
2020-05-08 13:08:04 +03:00
Vladimir Homutov 8e16e4eff5 Cleaned up firefox workaround.
The idea is to skip any zeroes that follow valid QUIC packet.  Currently such
behavior can be only observed with Firefox which sends zero-padded initial
packets.
2020-05-07 12:34:04 +03:00
Roman Arutyunyan dd7a856040 OCSP stapling: moved response verification to a separate function. 2020-05-06 21:44:14 +03:00
Jinhua Tan 1275c315f1 Upstream: jump out of loop after matching the status code. 2020-05-13 22:02:47 +08:00
Sergey Kandaurov ff83e85899 Variables: fixed buffer over-read when evaluating "$arg_". 2020-05-08 19:19:16 +03:00
Sergey Kandaurov 04ba271d3e Restored ngx_quic_encrypt return type.
It was inadvertently changed while working on removing memory allocations.
2020-05-06 14:34:44 +03:00
Vladimir Homutov 2c62f443a9 Store clearflags in pkt->flags after decryption.
It doesn't make sense to store protected flags.
2020-04-30 12:22:35 +03:00
Sergey Kandaurov 76ef3c1768 Configure: fixed static compilation with OpenSSL 1.1.1 / BoringSSL.
See 7246:04ebf29eaf5b for details.
2020-05-01 13:02:30 +03:00
Sergey Kandaurov 5fc7d63f80 Mention quic branch in README. 2020-04-30 15:59:14 +03:00
Sergey Kandaurov 7a34d6e74a Configure: unbreak with old OpenSSL, --with-http_v3_module added. 2020-04-30 15:47:43 +03:00
Vladimir Homutov 8abc8b130f Removed outdated/incorrect comments and fixed style.
- we need transport parameters early to get packet size limits at least.
2020-04-29 14:45:55 +03:00
Vladimir Homutov 675ec33c5b Reworked macros for parsing/assembling packet types.
Previously, macros checking a packet type with the long header also checked
whether this is a long header.  Now it requires a separate preceding check.
2020-04-30 12:38:38 +03:00
Sergey Kandaurov 390ffc92f2 Renamed retransmit event object in preparation for retry support. 2020-04-29 14:59:21 +03:00
Sergey Kandaurov 58dcabc2be Server CID change. 2020-04-28 18:24:01 +03:00
Sergey Kandaurov 90bd619f81 Factored out sending ACK from payload handler.
Now there's no need to annotate every frame in ACK-eliciting packet.
Sending ACK was moved to the first place, so that queueing ACK frame
no longer postponed up to the next packet after pushing STREAM frames.
2020-04-28 18:23:56 +03:00
Vladimir Homutov dfc9c2dd14 Added README. 2020-04-28 18:16:13 +03:00
Roman Arutyunyan b93e22b5fd Respect MAX_DATA and MAX_STREAM_DATA from QUIC client. 2020-04-28 16:37:32 +03:00
Roman Arutyunyan fa1795919c QUIC basic congestion control. 2020-04-28 16:42:43 +03:00
Roman Arutyunyan 70e34b17c8 Fixed packet retransmission.
Previously frames in ctx->sent queue could be lost.
2020-04-24 17:20:37 +03:00
Roman Arutyunyan e15adc3eb8 Assign connection number to every QUIC stream log. 2020-04-23 18:05:05 +03:00
Vladimir Homutov ff7635070e Error messages cleanup.
+ added "quic" prefix to all error messages
 + rephrased some messages
 + removed excessive error logging from frame parser
 + added ngx_quic_check_peer() function to check proper source/destination
   match and do it one place
2020-04-24 14:38:49 +03:00
Vladimir Homutov 530342f5fe Cleaned up hexdumps in debug output.
- the ngx_quic_hexdump0() macro is renamed to ngx_quic_hexdump();
   the original ngx_quic_hexdump() macro with variable argument is
   removed, extra information is logged normally, with ngx_log_debug()

 - all labels in hex dumps are prefixed with "quic"

 - the hexdump format is simplified, length is moved forward to avoid
   situations when the dump is truncated, and length is not shown

 - ngx_quic_flush_flight() function contents is debug-only, placed under
   NGX_DEBUG macro to avoid "unused variable" warnings from compiler

 - frame names in labels are capitalized, similar to other places
2020-04-24 11:33:00 +03:00
Vladimir Homutov f6306e8faf Debug cleanup.
+ all dumps are moved under one of the following macros (undefined by default):
    NGX_QUIC_DEBUG_PACKETS
    NGX_QUIC_DEBUG_FRAMES
    NGX_QUIC_DEBUG_FRAMES_ALLOC
    NGX_QUIC_DEBUG_CRYPTO

 + all QUIC debug messages got "quic " prefix

 + all input frames are reported as "quic frame in FOO_FRAME bar:1 baz:2"

 + all outgoing frames re reported as "quic frame out foo bar baz"

 + all stream operations are prefixed with id, like: "quic stream id 0x33 recv"

 + all transport parameters are prefixed with "quic tp"
   (hex dump is moved to caller, to avoid using ngx_cycle->log)

 + packet flags and some other debug messages are updated to
   include packet type
2020-04-24 10:11:47 +03:00
Ruslan Ermilov ae9fcb3ec1 gRPC: WINDOW_UPDATE after END_STREAM handling (ticket #1797).
As per https://tools.ietf.org/html/rfc7540#section-6.9,
WINDOW_UPDATE received after a frame with the END_STREAM flag
should be handled and not treated as an error.
2020-04-23 15:10:26 +03:00
Ruslan Ermilov 7ccceefa39 gRPC: RST_STREAM(NO_ERROR) handling (ticket #1792).
As per https://tools.ietf.org/html/rfc7540#section-8.1,

: 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).  Clients MUST NOT discard responses as a
: result of receiving such a RST_STREAM, though clients can
: always discard responses at their discretion for other
: reasons.

Previously, RST_STREAM(NO_ERROR) received from upstream after
a frame with the END_STREAM flag was incorrectly treated as an
error.  Now, a single RST_STREAM(NO_ERROR) is properly handled.

This fixes problems observed with modern grpc-c [1], as well
as with the Go gRPC module.

[1] https://github.com/grpc/grpc/pull/1661
2020-04-23 15:10:24 +03:00
Ruslan Ermilov 0aff2ed3bc Version bump. 2020-04-23 15:10:21 +03:00
Vladimir Homutov 3df104d74a TODOs cleanup in transport.
We always generate stream frames that have length. The 'len' member is used
during parsing incoming frames and can be safely ignored when generating
output.
2020-04-23 12:25:00 +03:00
Vladimir Homutov 3a9bdecdcd Retired the ngx_quic_parse_int_multi() function.
It used variable-length arguments what is not really necessary.
2020-04-23 12:10:56 +03:00
Vladimir Homutov 7727d103ff Removed support of drafts older than currently latest 27. 2020-04-23 11:50:20 +03:00
Vladimir Homutov 9268eb82e6 Added proper handling of connection close phases.
There are following flags in quic connection:

closing  - true, when a connection close is initiated, for whatever reason
draining - true, when a CC frame is received from peer

The following state machine is used for closing:

 +------------------+
 |       I/HS/AD    |
 +------------------+
 |        |       |
 |        |       V
 |        |   immediate close initiated:
 |        |     reasons: close by top-level protocol, fatal error
 |        |     + sends CC (probably with app-level message)
 |        |     + starts close_timer: 3 * PTO (current probe timeout)
 |        |       |
 |        |       V
 |        |   +---------+  - Reply to input with CC (rate-limited)
 |        |   | CLOSING |  - Close/Reset all streams
 |        |   +---------+
 |        |       |    |
 |        V       V    |
 |       receives CC   |
 |          |          |
idle        |          |
timer       |          |
 |          V          |
 |      +----------+   |  - MUST NOT send anything (MAY send a single CC)
 |      | DRAINING |   |  - if not already started, starts close_timer: 3 * PTO
 |      +----------+   |  - if not already done, close all streams
 |          |          |
 |          |          |
 |       close_timer fires
 |          |
 V          V
 +------------------------+
 |       CLOSED           | - clean up all the resources, drop connection
 +------------------------+   state completely

The ngx_quic_close_connection() function gets an "rc" argument, that signals
reason of connection closing:
    NGX_OK    - initiated by application (i.e. http/3), follow state machine
    NGX_DONE  - timedout (while idle or draining)
    NGX_ERROR - fatal error, destroy connection immediately

The PTO calculations are not yet implemented, hardcoded value of 5s is used.
2020-04-23 13:41:08 +03:00
Vladimir Homutov 51a4a7cace Refactored ngx_quic_close_connection().
The function is split into three:
    ngx_quic_close_connection() itself cleans up all core nginx things
    ngx_quic_close_quic()  deals with everything inside c->quic
    ngx_quic_close_streams() deals with streams cleanup

The quic and streams cleanup functions may return NGX_AGAIN, thus signalling
that cleanup is not ready yet, and the close cannot continue to next step.
2020-04-23 11:15:44 +03:00
Sergey Kandaurov 143642175b HTTP/3: directives with limited values converted to post handler.
The purpose is to show a precise line number with an invalid value.
2020-04-22 15:59:19 +03:00
Sergey Kandaurov b609fbb299 HTTP/3: bytes holding directives changed to ngx_conf_set_size_slot.
This allows to specify directive values with measurement units.
2020-04-22 15:48:39 +03:00
Sergey Kandaurov 8da6bbe021 Improved ngx_quic_build_int() code and readability.
The function now generates somewhat shorter assembler after inlining.
2020-04-22 14:52:16 +03:00
Roman Arutyunyan 29f6610c6a Fixed QUIC buffer consumption in send_chain(). 2020-04-21 17:52:32 +03:00
Roman Arutyunyan f5497fb4b2 HTTP/3: fixed encoding variable-length integers. 2020-04-21 17:11:49 +03:00
Vladimir Homutov fddff472ae Fixed memory leak with reordered stream frames. 2020-04-20 18:32:46 +03:00
Roman Arutyunyan 9ad3701249 Fixed includes in quic headers. 2020-04-21 12:06:24 +03:00
Vladimir Homutov 52ee48aee1 Added MAX_STREAM_DATA stub handler.
Currently sending code is ignoring this.
2020-04-20 17:18:04 +03:00
Vladimir Homutov 034b7aa141 Respecting maximum packet size.
The header size macros for long and short packets were fixed to provide
correct values in bytes.

Currently the sending code limits frames so they don't exceed max_packet_size.
But it does not account the case when a single frame can exceed the limit.

As a result of this patch, big payload (CRYPTO and STREAM) will be split
into a number of smaller frames that fit into advertised max_packet_size
(which specifies final packet size, after encryption).
2020-04-20 22:25:22 +03:00
Vladimir Homutov 6b721fa123 Removed source/destination swap from the function creating header.
The function now creates a header according to fileds provided in the "pkt"
argument without applying any logic regarding sending side.
2020-04-20 12:12:17 +03:00
Sergey Kandaurov 5bd2c23508 Revert "Rejecting new connections with non-zero Initial packet."
chrome-unstable 83.0.4103.7 starts with Initial packet number 1.

I couldn't find a proper explanation besides this text in quic-transport:
    An endpoint MAY skip packet numbers when sending
    packets to detect this (Optimistic ACK Attack) behavior.
2020-04-17 12:01:45 +03:00
Vladimir Homutov 5900b8eca0 Fixed error descriptions.
The check for array bound is done inside function that returns error
description.  Missing initialization element is added.
2020-04-16 16:54:22 +03:00
Vladimir Homutov 236228d223 Removed outdated TODO.
If required, frame handler can invoke output itself.  There is no need to
call output directly in the payload handler, queuing is enough.
2020-04-16 13:28:43 +03:00
Vladimir Homutov 2febedf38c Added handling of incorrect values in TP configuration.
Some parameters have minimal/maximum values defined by standard.
2020-04-16 12:17:41 +03:00
Sergey Kandaurov 97c2ac2892 Parsing of truncated packet numbers.
For sample decoding algorithm, see quic-transport-27#appendix-A.
2020-04-16 12:46:48 +03:00
Vladimir Homutov 4a267b8304 Added primitive flow control mechanisms.
+ MAX_STREAM_DATA frame is sent when recv() is performed on stream
   The new value is a sum of total bytes received by stream + free
   space in a buffer;

   The sending of MAX_STREM_DATA frame in response to STREAM_DATA_BLOCKED
   frame is adjusted to follow the same logic as above.

 + MAX_DATA frame is sent when total amount of received data is 2x
   of current limit.  The limit is doubled.

 + Default values of transport parameters are adjusted to more meaningful
   values:

   initial stream limits are set to quic buffer size instead of
   unrealistically small 255.

   initial max data is decreased to 16 buffer sizes, in an assumption that
   this is enough for a relatively short connection, instead of randomly
   chosen big number.

All this allows to initiate a stable flow of streams that does not block
on stream/connection limits (tested with FF 77.0a1 and 100K requests)
2020-04-15 18:54:03 +03:00
Vladimir Homutov fb07bd3fc1 Create new stream immediately on receiving new stream id.
Before the patch, full STREAM frame handling was delayed until the frame with
zero offset is received.  Only node in the streams tree was created.

This lead to problems when such stream was deleted, in particular, it had no
handlers set for read events.

This patch creates new stream immediately, but delays data delivery until
the proper offset will arrive. This is somewhat similar to how accept()
operation works.

The ngx_quic_add_stream() function is no longer needed and merged into stream
handler.  The ngx_quic_stream_input() now only handles frames for existing
streams and does not deal with stream creation.
2020-04-15 14:29:00 +03:00
Vladimir Homutov a99a268a5d Free remaining frames on connection close.
Frames can still float in the following queues:

 - crypto frames reordering queues (one per encryption level)
 - moved crypto frames cleanup to the moment where all streams are closed
 - stream frames reordering queues (one per packet number namespace)
 - frames retransmit queues (one per packet number namespace)
2020-04-15 13:09:39 +03:00
Maxim Dounin c0570462f1 release-1.17.10 tag 2020-04-14 17:19:26 +03:00
Maxim Dounin e59dc472db nginx-1.17.10-RELEASE 2020-04-14 17:19:26 +03:00
Vladimir Homutov a72ce93da9 Sorted functions and functions declarations. 2020-04-14 16:30:41 +03:00
Vladimir Homutov 0a59aa67e4 Added reordering support for STREAM frames.
Each stream node now includes incoming frames queue and sent/received counters
for tracking offset. The sent counter is not used, c->sent is used, not like
in crypto buffers, which have no connections.
2020-04-15 11:11:54 +03:00
Maxim Dounin 50bb38eacc Updated OpenSSL used for win32 builds. 2020-04-14 15:15:16 +03:00
Vladimir Homutov 30f51174ec Crypto buffer frames reordering.
If offset in CRYPTO frame doesn't match expected, following actions are taken:
    a) Duplicate frames or frames within [0...current offset] are ignored
    b) New data from intersecting ranges (starts before current_offset, ends
       after) is consumed
    c) "Future" frames are stored in a sorted queue (min offset .. max offset)

Once a frame is consumed, current offset is updated and the queue is inspected:
    we iterate the queue until the gap is found and act as described
    above for each frame.

The amount of data in buffered frames is limited by corresponding macro.

The CRYPTO and STREAM frame structures are now compatible: they share
the same set of initial fields.  This allows to have code that deals with
both of this frames.

The ordering layer now processes the frame with offset and invokes the
handler when it can organise an ordered stream of data.
2020-04-14 12:16:25 +03:00
Vladimir Homutov 6d8f571730 Cleaned up magic numbers in ngx_quic_output_frames(). 2020-04-13 14:57:58 +03:00
Vladimir Homutov 7a7ef3cbfb Rename types and variables used for packet number space.
Quote: Conceptually, a packet number space is the context in which a packet
       can be processed and acknowledged.

ngx_quic_namespace_t => ngx_quic_send_ctx_t
qc->ns               => qc->send_ctx
ns->largest          => send_ctx->largest_ack

The ngx_quic_ns(level) macro now returns pointer, not just index:
    ngx_quic_get_send_ctx(c->quic, level)

ngx_quic_retransmit_ns() => ngx_quic_retransmit()
ngx_quic_output_ns() => ngx_quic_output_frames()
2020-04-14 12:06:32 +03:00
Sergey Kandaurov 8acaa933af Merged with the default branch. 2020-04-14 19:35:20 +03:00
Roman Arutyunyan 3dc5ecbe69 HTTP/3: fixed reading request body. 2020-04-13 17:54:23 +03:00
Ruslan Ermilov 814df8f412 The new auth_delay directive for delaying unauthorized requests.
The request processing is delayed by a timer.  Since nginx updates
internal time once at the start of each event loop iteration, this
normally ensures constant time delay, adding a mitigation from
time-based attacks.

A notable exception to this is the case when there are no additional
events before the timer expires.  To ensure constant-time processing
in this case as well, we trigger an additional event loop iteration
by posting a dummy event for the next event loop iteration.
2020-04-08 01:02:17 +03:00
Vladimir Homutov 093f4f21b5 Added basic offset support in client CRYPTO frames.
The offset in client CRYPTO frames is tracked in c->quic->crypto_offset_in.
This means that CRYPTO frames with non-zero offset are now accepted making
possible to finish handshake with client certificates that exceed max packet
size (if no reordering happens).

The c->quic->crypto_offset field is renamed to crypto_offset_out to avoid
confusion with tracking of incoming CRYPTO stream.
2020-04-07 15:50:38 +03:00
Sergey Kandaurov df34c84733 Fixed build with OpenSSL using old callbacks API. 2020-04-07 12:54:34 +03:00
Vladimir Homutov 88b9aed247 ACK ranges processing.
+ since number of ranges in unknown, provide a function to parse them once
   again in handler to avoid memory allocation

 + ack handler now processes all ranges, not only the first

 + ECN counters are parsed and saved into frame if present
2020-04-06 16:19:26 +03:00
Vladimir Homutov c0c3a400ef Ignore non-yet-implemented frames.
Such frames are grouped together in a switch and just ignored, instead of
closing the connection  This may improve test coverage.  All such frames
require acknowledgment.
2020-04-06 11:16:45 +03:00
Vladimir Homutov c025e2cf80 Added check for SSL_get_current_cipher() results.
The function may return NULL and result need to be checked before use.
2020-04-04 22:25:41 +03:00
Vladimir Homutov 97ebd69704 Added a bit more debugging in STREAM frame parser. 2020-04-06 11:17:14 +03:00
Vladimir Homutov e9f4adf0b3 Do not set timers after the connection is closed.
The qc->closing flag is set when a connection close is initiated for the first
time.

No timers will be set if the flag is active.

TODO: this is a temporary solution to avoid running timer handlers after
connection (and it's pool) was destroyed.  It looks like currently we have
no clear policy of connection closing in regard to timers.
2020-04-04 22:27:29 +03:00
Sergey Kandaurov d42d04baf6 Discarding Handshake packets if no Handshake keys yet.
Found with a previously received Initial packet with ACK only, which
instantiates a new connection but do not produce the handshake keys.

This can be triggered by a fairly well behaving client, if the server
stands behind a load balancer that stripped Initial packets exchange.

Found by F5 test suite.
2020-04-06 14:54:10 +03:00
Sergey Kandaurov 9c12453342 Rejecting new connections with non-zero Initial packet. 2020-04-06 14:54:10 +03:00
Sergey Kandaurov 4a03675be3 TLS Key Update in QUIC.
Old keys retention is yet to be implemented.
2020-04-06 14:54:08 +03:00
Sergey Kandaurov bf825ce6cc Removed excessive debugging in QUIC packet creation.
While here, eliminated further difference in between.
2020-04-04 17:34:39 +03:00
Sergey Kandaurov 755dd33d97 Logging of packet numbers in QUIC packet creation. 2020-04-04 17:34:04 +03:00
Vladimir Homutov dc3a60c8d9 Removed unneccesary milliseconds conversion. 2020-04-03 16:33:59 +03:00
Vladimir Homutov 7e1e892a8a Proper handling of packet number in header.
- fixed setting of largest received packet number.
 - sending properly truncated packet number
 - added support for multi-byte packet number
2020-04-03 14:02:16 +03:00
Sergey Kandaurov 3d9b7f1c8b Advertizing MAX_STREAMS (0x12) credit in advance.
This makes sending large number of bidirectional stream work within ngtcp2,
which doesn't bother sending optional STREAMS_BLOCKED when exhausted.

This also introduces tracking currently opened and maximum allowed streams.
2020-04-03 13:49:44 +03:00
Sergey Kandaurov 48608142a3 Fixed computing nonce again, by properly shifting packet number. 2020-04-03 13:49:40 +03:00
Vladimir Homutov 4b40730b18 Fixed missing propagation of need_ack flag from frames to packet. 2020-04-03 09:53:51 +03:00
Vladimir Homutov 58b439447e Fixed excessive push timer firing.
The timer is set when an output frame is generated; there is no need to arm
it after it was fired.
2020-04-02 14:53:01 +03:00
Sergey Kandaurov 9f9700d6e3 Fixed computing nonce by xoring all packet number bytes.
Previously, the stub worked only with pnl=0.
2020-04-02 11:40:25 +03:00
Vladimir Homutov dc0b7674f1 Output buffering.
Currently, the output is called periodically, each 200 ms to invoke
ngx_quic_output() that will push all pending frames into packets.

TODO: implement flags a-là Nagle & co (NO_DELAY/NO_PUSH...)
2020-04-01 17:09:11 +03:00
Vladimir Homutov 41fca95d9a Implemented retransmission and retransmit queue.
All frames collected to packet are moved into a per-namespace send queue.
QUIC connection has a timer which fires on the closest max_ack_delay time.
The frame is deleted from the queue when a corresponding packet is acknowledged.

The NGX_QUIC_MAX_RETRANSMISSION is a timeout that defines maximum length
of retransmission of a frame.
2020-04-01 17:06:26 +03:00
Vladimir Homutov 7eac371881 Introduced packet namespace in QUIC connection.
The structure contains all data that is related to the namespace:
packet number and output queue (next patch).
2020-04-01 14:31:08 +03:00
Vladimir Homutov 82558fa46a Refactored QUIC secrets storage.
The quic->keys[4] array now contains secrets related to the corresponding
encryption level.  All protection-level functions get proper keys and do
not need to switch manually between levels.
2020-04-01 14:25:25 +03:00
Vladimir Homutov 38b5f39e8e Added missing debug description. 2020-04-01 17:21:52 +03:00
Sergey Kandaurov 56456e36fc TLS Early Data support. 2020-04-01 13:27:42 +03:00
Sergey Kandaurov f68c876ca3 TLS Early Data key derivation support. 2020-04-01 13:27:42 +03:00
Sergey Kandaurov e0e880bfab Sending HANDSHAKE_DONE just once with BoringSSL.
If early data is accepted, SSL_do_handshake() completes as soon as ClientHello
is processed.  SSL_in_init() will report the handshake is still in progress.
2020-04-01 13:27:42 +03:00
Sergey Kandaurov 21f4be001a QUIC packet padding to fulfil header protection sample demands. 2020-04-01 13:27:42 +03:00
Sergey Kandaurov 7d5fe69bb2 Improved SSL_do_handshake() error handling in QUIC.
It can either return a recoverable SSL_ERROR_WANT_READ or fatal errors.
2020-04-01 13:27:42 +03:00
Sergey Kandaurov 108bc03458 Style. 2020-04-01 13:27:41 +03:00
Vladimir Homutov ed21279b6f Removed unused field from ngx_quic_header_t. 2020-03-31 13:13:12 +03:00
Sergey Kandaurov 6749f64f7f HTTP/3: http3 variable. 2020-03-28 18:41:31 +03:00
Sergey Kandaurov 536810e48b HTTP/3: static table cleanup. 2020-03-28 18:02:20 +03:00
Roman Arutyunyan 48a1eeb5c2 Parsing HTTP/3 request body. 2020-03-27 19:41:06 +03:00
Roman Arutyunyan 732e383dd1 Fixed handling QUIC stream eof.
Set r->pending_eof flag for a new QUIC stream with the fin bit.  Also, keep
r->ready set when r->pending_eof is set and buffer is empty.
2020-03-27 10:02:45 +03:00
Roman Arutyunyan 6bc0ecd946 Push QUIC stream frames in send() and cleanup handler. 2020-03-27 19:08:24 +03:00
Roman Arutyunyan 50e32ed41d Chunked response body in HTTP/3. 2020-03-27 19:46:54 +03:00
Roman Arutyunyan 1903ad35b9 Fixed buffer overflow. 2020-03-27 15:50:42 +03:00
Sergey Kandaurov 20659b28cc Unbreak sending CONNECTION_CLOSE from the send_alert callback. 2020-03-27 12:52:08 +03:00
Vladimir Homutov dd88e287a5 Merged ngx_quic_send_packet() into ngx_quic_send_frames().
This allows to avoid extra allocation and use two static buffers instead.
Adjusted maximum paket size calculation: need to account a tag.
2020-03-26 18:29:38 +03:00
Vladimir Homutov 559e9b7f59 Got rid of memory allocation in decryption.
Static buffers are used instead in functions where decryption takes place.

The pkt->plaintext points to the beginning of a static buffer.
The pkt->payload.data points to decrypted data actual start.
2020-03-26 16:54:46 +03:00
Vladimir Homutov 6bad711183 Logging cleanup.
pool->log is replaced with pkt->log or explicit argument passing where
possible.
2020-03-26 13:54:49 +03:00
Roman Arutyunyan 5f6d337e47 QUIC frames reuse. 2020-03-25 23:40:50 +03:00
Vladimir Homutov 73fc0300aa Removed memory allocations from encryption code.
+ ngx_quic_encrypt():
     - no longer accepts pool as argument
     - pkt is 1st arg
     - payload is passed as pkt->payload
     - performs encryption to the specified static buffer

 + ngx_quic_create_long/short_packet() functions:
    - single buffer for everything, allocated by caller
    - buffer layout is: [ ad | payload | TAG ]
      the result is in the beginning of buffer with proper length
    - nonce is calculated on stack
    - log is passed explicitly, pkt is 1st arg
    - no more allocations inside

 + ngx_quic_create_long_header():
    - args changed: no need to pass str_t

 + added ngx_quic_create_short_header()
2020-03-26 12:11:50 +03:00
Roman Arutyunyan 8decfa3847 Fixed QUIC stream insert and find. 2020-03-25 14:05:40 +03:00
Roman Arutyunyan 5162a3da50 Simplifed handling HTTP/3 streams. 2020-03-25 12:14:24 +03:00
Roman Arutyunyan 897df08a00 Safe QUIC stream creation. 2020-03-25 12:56:21 +03:00
Roman Arutyunyan 372d6283c2 When closing a QUIC connection, wait for all streams to finish.
Additionally, streams are now removed from the tree in cleanup handler.
2020-03-24 18:05:45 +03:00
Roman Arutyunyan 22a1957f92 Removed ngx_quic_stream_node_t.
Now ngx_quic_stream_t is directly inserted into the tree.
2020-03-24 16:38:03 +03:00
Roman Arutyunyan f4b6701ab4 Implemented eof in QUIC streams. 2020-03-24 13:49:42 +03:00
Vladimir Homutov 34e20825bb Fixed log initialization.
Should be done after memzero.
2020-03-25 19:42:00 +03:00
Sergey Kandaurov 9dda9e51f3 Advertise our max_idle_timeout in transport parameters.
So we can easily tune how soon client would decide to close a connection.
2020-03-24 22:12:52 +03:00
Sergey Kandaurov c87e5a3a13 QUIC streams don't need filter_need_in_memory after 7f0981be07c4.
Now they inherit c->ssl always enabled from the main connection,
which makes r->main_filter_need_in_memory set for them.
2020-03-24 19:17:57 +03:00
Vladimir Homutov 6b8343d4cf Logging cleanup.
+ Client-related errors (i.e. parsing) are done at INFO level
 + c->log->action is updated through the process of receiving, parsing.
   handling packet/payload and generating frames/output.
2020-03-24 17:03:39 +03:00
Vladimir Homutov 55680af808 Added QUIC version check for sending HANDSHAKE_DONE frame. 2020-03-24 12:15:39 +03:00
Vladimir Homutov f38c75578c Implemented sending HANDSHAKE_DONE frame after handshake.
This makes it possible to switch to draft 27 by default.
2020-03-24 11:59:14 +03:00
Sergey Kandaurov ac4d386e29 Fixed client certificate verification.
For ngx_http_process_request() part to work, this required to set both
r->http_connection->ssl and c->ssl on a QUIC stream.  To avoid damaging
global SSL object, ngx_ssl_shutdown() is managed to ignore QUIC streams.
2020-03-23 20:48:34 +03:00
Roman Arutyunyan b20601811e Respect QUIC max_idle_timeout. 2020-03-23 21:20:20 +03:00
Roman Arutyunyan ca0bc7f0d7 Allow ngx_queue_frame() to insert frame in the front.
Previously a frame could only be inserted after the first element of the list.
2020-03-23 19:42:09 +03:00
Roman Arutyunyan 0d50d1718c Support for HTTP/3 ALPN.
This is required by Chrome.
2020-03-23 19:26:24 +03:00
Roman Arutyunyan ce532aa3e2 Put zero in 'First ACK Range' when acknowledging one packet.
This fixes Chrome CONNECTION_ID_LIMIT_ERROR with the reason:
"Underflow with first ack block length 2 largest acked is 1".
2020-03-23 15:32:24 +03:00
Roman Arutyunyan 25447805a2 Avoid using QUIC connection after CONNECTION_CLOSE. 2020-03-23 19:19:44 +03:00
Roman Arutyunyan aca8dcc624 Better flow control and buffering for QUIC streams. 2020-03-23 15:49:31 +03:00
Roman Arutyunyan d60818a0d3 Limit output QUIC packets with client max_packet_size.
Additionally, receive larger packets than 512 bytes.
2020-03-23 18:47:17 +03:00
Sergey Kandaurov 1afb9cd2be Fixed received ACK fields order in debug logging. 2020-03-23 18:20:42 +03:00
Vladimir Homutov b934f9289b Connection states code cleanup.
+ ngx_quic_init_ssl_methods() is no longer there, we setup methods on SSL
   connection directly.

 + the handshake_handler is actually a generic quic input handler

 + updated c->log->action and debug to reflect changes and be more informative

 + c->quic is always set in ngx_quic_input()

 + the quic connection state is set by the results of SSL_do_handshake();
2020-03-23 14:53:04 +03:00
Vladimir Homutov a707587883 Skip unknown transport parameters. 2020-03-23 12:57:24 +03:00
Vladimir Homutov f26700cc7f Add unsupported version into log.
This makes it easier to understand what client wants.
2020-03-23 10:57:28 +03:00
Vladimir Homutov b0972707a3 Added processing of client transport parameters.
note:
 + parameters are available in SSL connection since they are obtained by ssl
   stack

quote:
   During connection establishment, both endpoints make authenticated
   declarations of their transport parameters.  These declarations are
   made unilaterally by each endpoint.

and really, we send our parameters before we read client's.

no handling of incoming parameters is made by this patch.
2020-03-21 20:51:59 +03:00
Sergey Kandaurov 02a2cbf438 Fixed CRYPTO offset generation. 2020-03-22 12:15:54 +03:00
Sergey Kandaurov 457e579896 Closing connection on NGX_QUIC_FT_CONNECTION_CLOSE. 2020-03-22 11:35:15 +03:00
Vladimir Homutov 76db776d70 Implemented parsing of remaining frame types. 2020-03-21 20:49:55 +03:00
Sergey Kandaurov 9e02252c76 Fixed parsing NGX_QUIC_FT_CONNECTION_CLOSE. 2020-03-21 19:45:24 +03:00
Sergey Kandaurov d588f9da33 Fixed buffer overrun in create_transport_params() with -24.
It writes 16-bit prefix as designed, but length calculation assumed varint.
2020-03-21 19:22:39 +03:00
Sergey Kandaurov 5a823e8656 Fixed build with macOS's long long abomination. 2020-03-21 18:44:10 +03:00
Roman Arutyunyan 587adbda18 Removed unused variable. 2020-03-20 23:49:42 +03:00
Vladimir Homutov 8c69d52595 Removed unused variable. 2020-03-20 20:39:41 +03:00
Vladimir Homutov 9fe82b7379 Added checks for permitted frame types.
+ cleanup in macros for packet types
 + some style fixes in quic_transport.h (case, indentation)
2020-03-20 20:03:44 +03:00
Vladimir Homutov b5c3e7cc6d Fixed parsing of CONNECTION CLOSE2 frames.
The "frame_type" field is not passed in case of 0x1d frame.
2020-03-20 15:14:00 +03:00
Vladimir Homutov f9e8909725 Added parsing of CONNECTION_CLOSE2 frame (0x1D).
The difference is that error code refers to application namespace, i.e.
quic error names cannot be used to convert it to string.
2020-03-20 14:50:05 +03:00
Vladimir Homutov 4b97a37ef9 Adedd the http "quic" variable.
The value is literal "quic" for requests passed over HTTP/3, and empty string
otherwise.
2020-03-20 12:44:45 +03:00
Vladimir Homutov 239eab2f11 Configurable transport parameters.
- integer parameters can be configured using the following directives:

    quic_max_idle_timeout
    quic_max_ack_delay
    quic_max_packet_size
    quic_initial_max_data
    quic_initial_max_stream_data_bidi_local
    quic_initial_max_stream_data_bidi_remote
    quic_initial_max_stream_data_uni
    quic_initial_max_streams_bidi
    quic_initial_max_streams_uni
    quic_ack_delay_exponent
    quic_active_migration
    quic_active_connection_id_limit

 - only following parameters are actually sent:

    active_connection_id_limit
    initial_max_streams_uni
    initial_max_streams_bidi
    initial_max_stream_data_bidi_local
    initial_max_stream_data_bidi_remote
    initial_max_stream_data_uni

 (other parameters are to be added into ngx_quic_create_transport_params()
  function as needed, should be easy now)

 - draft 24 and draft 27 are now supported
   (at compile-time using quic_version macro)
2020-03-20 13:47:44 +03:00
Roman Arutyunyan e1c5be01a8 Reset QUIC timeout on every datagram. 2020-03-19 21:46:28 +03:00
Roman Arutyunyan cc82918be2 Double MAX_STREAMS on STREAMS_BLOCKED. 2020-03-20 10:14:58 +03:00
Roman Arutyunyan faffab6185 Fixed ACKs to packet numbers greater than 63. 2020-03-20 09:23:31 +03:00
Sergey Kandaurov ee9d09252b Fixed specifiers in "quic packet length" logging. 2020-03-19 17:33:36 +03:00
Sergey Kandaurov 961a0bd505 Fixed build. 2020-03-19 17:22:43 +03:00
Vladimir Homutov f950ce410a The ngx_quic_frame_len() function is not really needed. 2020-03-19 14:59:55 +03:00
Vladimir Homutov 5040cd1100 Added boundaries checks into frame parser.
The ngx_quic_parse_frame() functions now has new 'pkt' argument: the packet
header of a currently processed frame.  This allows to log errors/debug
closer to reasons and perform additional checks regarding possible frame
types.  The handler only performs processing of good frames.


A number of functions like read_uint32(), parse_int[_multi] probably should
be implemented as a macro, but currently it is better to have them as
functions for simpler debugging.
2020-03-19 17:07:12 +03:00
Roman Arutyunyan 2b325d5232 Send a FIN frame when QUIC stream is closed. 2020-03-19 15:34:35 +03:00
Roman Arutyunyan 2fbf07e5f9 Fixed header creation for header_only responses in HTTP/3. 2020-03-19 15:03:09 +03:00
Sergey Kandaurov 7280e53dc0 MAX_DATA frame parser/handler. 2020-03-18 23:26:26 +03:00
Vladimir Homutov 50dae403db Added parsing of STREAMS BLOCKED frames.
While there, added hex prefix for debug to avoid frame type confusion.
2020-03-19 11:15:43 +03:00
Sergey Kandaurov e86812b373 Implemented send_alert callback, CONNECTION_CLOSE writer.
The callback produces a CONNECTION_CLOSE frame, as per quic-tls-24#section-4.9.
2020-03-18 23:07:40 +03:00
Roman Arutyunyan e6013b7ceb Added copying addr_text to QUIC stream connections.
Now $remote_addr holds client address.
2020-03-18 20:28:28 +03:00
Roman Arutyunyan bcda520b67 HTTP/3 $request_line variable. 2020-03-18 20:22:16 +03:00
Roman Arutyunyan 622a45cedb Moved setting QUIC methods to runtime.
This allows listening to both https and http3 in the same server.
Also, the change eliminates the ssl_quic directive.
2020-03-18 16:37:16 +03:00
Vladimir Homutov aaaa18b4bb Added parsing of RESET_STREAM and STOP_SENDING frames 2020-03-18 16:35:11 +03:00
Roman Arutyunyan 1fd47a9563 Fixed pointer increment while parsing HTTP/3 header. 2020-03-18 15:28:20 +03:00
Vladimir Homutov 30c58cf40d Implemented creation of server unidirectional streams.
The ngx_quic_create_stream() function is a generic function extracted from
the ngx_quic_handle_stream_frame() function.
2020-03-18 13:49:39 +03:00
Roman Arutyunyan 1121c906b1 Fixed HTTP/3 server stream creation. 2020-03-18 14:10:44 +03:00
Roman Arutyunyan 9bd0187263 Removed comment. 2020-03-18 14:09:50 +03:00
Roman Arutyunyan 08a6458386 Refactored HTTP/3 parser. 2020-03-18 13:46:35 +03:00
Vladimir Homutov 50c8ba32ea Style and handlers.
Cleanup in ngx_event_quic.c:
    + reorderded functions, structures
    + added missing prototypes
    + added separate handlers for each frame type
    + numerous indentation/comments/TODO fixes
    + removed non-implemented qc->state and corresponding enum;
        this requires deep thinking, stub was unused.
    + streams inside quic connection are now in own structure
2020-03-18 13:02:19 +03:00
Vladimir Homutov a201153f69 Extracted transport part of the code into separate file.
All code dealing with serializing/deserializing
is moved int srv/event/ngx_event_quic_transport.c/h file.

All macros for dealing with data are internal to source file.

The header file exposes frame types and error codes.

The exported functions are currently packet header parsers and writers
and frames parser/writer.

The ngx_quic_header_t structure is updated with 'log' member. This avoids
passing extra argument to parsing functions that need to report errors.
2020-03-18 12:58:27 +03:00
Vladimir Homutov c628e1ef8b Firefox fixes.
+ support for more than one initial packet
 + workaround for trailing zeroes in packet
 + ignore application data packet if no keys yet (issue in draft 27/ff nightly)
 + fixed PING frame parser
 + STREAM frames need to be acknowledged

The following HTTP configuration is used for firefox (v74):

http {

    ssl_certificate_key localhost.key;
    ssl_certificate localhost.crt;
    ssl_protocols TLSv1.2 TLSv1.3;

    server {
        listen 127.0.0.1:10368 reuseport http3;
        ssl_quic on;
        server_name  localhost;

        location / {
            return 200 "This-is-QUICK\n";
        }
    }
    server {
        listen 127.0.0.1:5555 ssl; # point the browser here
        server_name  localhost;
        location / {
            add_header Alt-Svc 'h3-24=":10368";ma=100';
            return 200 "ALT-SVC";
        }
    }
}
2020-03-17 14:10:37 +03:00
Vladimir Homutov 715e0cc149 Fixed a typo with OpenSSL. 2020-03-16 19:42:57 +03:00
Vladimir Homutov aaa0d454bf Split transport and crypto parts into separate files.
New files:
    src/event/ngx_event_quic_protection.h
    src/event/ngx_event_quic_protection.c

The protection.h header provides interface to the crypto part of the QUIC:

2 functions to initialize corresponding secrets:

ngx_quic_set_initial_secret()
ngx_quic_set_encryption_secret()

and 2 functions to deal with packet processing:

ngx_quic_encrypt()
ngx_quic_decrypt()

Also, structures representing secrets are defined there.

All functions require SSL connection and a pool, only crypto operations
inside, no access to nginx connections or events.

Currently pool->log is used for the logging (instead of original c->log).
2020-03-16 19:00:47 +03:00
Vladimir Homutov 4c90b01897 Added processing of CONNECTION CLOSE frames.
Contents is parsed and debug is output. No actions are taken.
2020-03-16 13:06:43 +03:00
Roman Arutyunyan 469230a940 Temporary fix for header null-termination in HTTP/3. 2020-03-14 13:18:55 +03:00
Sergey Kandaurov 3326916378 Fixed header protection application with pn length > 1. 2020-03-14 03:15:09 +03:00
Roman Arutyunyan dfc75f89f6 Fixed sanitizer errors. 2020-03-13 20:44:32 +03:00
Vladimir Homutov 218417c5cf Added check for initialized c->ssl before calling SSL shutdown. 2020-03-13 18:55:58 +03:00
Roman Arutyunyan 0159e05a1e HTTP/3. 2020-03-13 19:36:33 +03:00
Roman Arutyunyan 5d91366f54 Fixed infinite loop in ngx_quic_stream_send_chain(). 2020-03-13 18:30:37 +03:00
Roman Arutyunyan ed7b99249c Implemented tracking offset in STREAM frames. 2020-03-13 18:29:50 +03:00
Roman Arutyunyan 67d3e0727f Implemented ngx_quic_stream_send_chain() method.
- just call send in a loop
2020-03-13 15:56:10 +03:00
Vladimir Homutov 1b1717d472 Stream "connection" read/write methods. 2020-03-13 14:39:23 +03:00
Ruslan Ermilov a52fc791ad Auth basic: explicitly zero out password buffer. 2020-03-13 02:12:10 +03:00
Ruslan Ermilov 837f53d436 Version bump. 2020-03-16 12:41:41 +03:00
Sergey Kandaurov 65a6ae1afc Fix build. 2020-03-12 18:08:26 +03:00
Vladimir Homutov 32a82b3af2 Removed hardcoded CRYPTO and ACK frame sizes. 2020-03-12 14:23:27 +03:00
Vladimir Homutov d311deed47 HTTP/QUIC interface reworked.
- events handling moved into src/event/ngx_event_quic.c
 - http invokes once ngx_quic_run() and passes stream callback
 (diff to original http_request.c is now minimal)

 - streams are stored in rbtree using ID as a key
 - when a new stream is registered, appropriate callback is called

 - ngx_quic_stream_t type represents STREAM and stored in c->qs
2020-03-12 16:54:43 +03:00
Vladimir Homutov 15d6485f1d Initial parsing of STREAM frames. 2020-03-11 15:41:35 +03:00
Vladimir Homutov 6fa68213c7 Added support of multiple QUIC packets in single datagram.
- now NEW_CONNECTION_ID frames can be received and parsed

The packet structure is created in ngx_quic_input() and passed
to all handlers (initial, handshake and application data).

The UDP datagram buffer is saved as pkt->raw;
The QUIC packet is stored as pkt->data and pkt->len (instead of pkt->buf)
(pkt->len is adjusted after parsing headers to actual length)

The pkt->pos is removed, pkt->raw->pos is used instead.
2020-03-12 14:43:24 +03:00
Vladimir Homutov 2425de1cee Added more transport parameters.
Needed for client to start sending streams.
2020-03-11 15:43:23 +03:00
Sergey Kandaurov 577f654b11 Compatibility with BoringSSL revised QUIC encryption secret APIs.
See for details: https://boringssl.googlesource.com/boringssl/+/1e85905%5E!/
2020-03-11 21:53:02 +03:00
Sergey Kandaurov 068f620567 Chacha20 header protection support with BoringSSL.
BoringSSL lacks EVP for Chacha20.  Here we use CRYPTO_chacha_20() instead.
2020-03-10 19:15:12 +03:00
Sergey Kandaurov 9cfb197dd6 ChaCha20 / Poly1305 initial support. 2020-03-10 19:13:09 +03:00
Sergey Kandaurov c321510f45 Using SSL cipher suite id to obtain cipher/digest, part 2.
Ciphers negotiation handling refactored into ngx_quic_ciphers().
2020-03-10 19:12:22 +03:00
Sergey Kandaurov 8d857000d9 Fixed nonce in short packet protection. 2020-03-10 18:40:18 +03:00
Vladimir Homutov 9bb1eba59e Generic payload handler for quic packets.
- added basic parsing of ACK, PING and PADDING frames on input
 - added preliminary parsing of SHORT headers

The ngx_quic_output() is now called after processing of each input packet.
Frames are added into output queue according to their level: inital packets
go ahead of handshake and application data, so they can be merged properly.

The payload handler is called from both new, handshake and applicataion data
handlers (latter is a stub).
2020-03-10 18:24:39 +03:00
Sergey Kandaurov f1d376e384 Fixed header protection with negotiated cipher suite. 2020-03-05 20:05:40 +03:00
Sergey Kandaurov fe5ad8267a Initial packets are protected with AEAD_AES_128_GCM. 2020-03-05 19:49:49 +03:00
Sergey Kandaurov 3a354b0ab3 Fixed write secret logging in set_encryption_secrets callback. 2020-03-05 18:01:18 +03:00
Vladimir Homutov 6f67c00f50 Fixed format specifiers. 2020-03-05 17:51:22 +03:00
Vladimir Homutov 0039105abd Style. 2020-03-05 17:24:04 +03:00
Vladimir Homutov a46e0377c1 Added functions to decrypt long packets. 2020-03-05 17:18:33 +03:00
Sergey Kandaurov 74b67ff2b2 Fixed ngx_quic_varint_len misuse in the previous change. 2020-03-05 15:26:15 +03:00
Vladimir Homutov f4a487ceaa Macro for calculating size of varint. 2020-03-04 23:24:51 +03:00
Sergey Kandaurov 9b4c52cab0 Fixed packet "input" debug log message. 2020-03-05 13:10:01 +03:00
Sergey Kandaurov 73fc9eba33 Using SSL cipher suite id to obtain cipher/digest, part 1.
While here, log the negotiated cipher just once, - after handshake.
2020-03-05 13:00:59 +03:00
Sergey Kandaurov 36412471e2 Using cached ssl_conn in ngx_quic_handshake_input(), NFC. 2020-03-05 12:51:49 +03:00
Sergey Kandaurov 1ffd2a5fe4 Adjusted transport parameters stub for active_connection_id_limit.
As was objserved with ngtcp2 client, Finished CRYPTO frame within Handshake
packet may not be sent for some reason if there's nothing to append on 1-RTT.
This results in unnecessary retransmit.  To avoid this edge case, a non-zero
active_connection_id_limit transport parameter is now used to append datagram
with NEW_CONNECTION_ID 1-RTT frames.
2020-03-04 16:05:39 +03:00
Vladimir Homutov 65772b9bd1 Implemented improved version of quic_output().
Now handshake generates frames, and they are queued in c->quic->frames.
The ngx_quic_output() is called from ngx_quic_flush_flight() or manually,
processes the queue and encrypts all frames according to required encryption
level.
2020-03-04 15:52:12 +03:00
Maxim Dounin 5f90cbb38b release-1.17.9 tag 2020-03-03 18:04:21 +03:00
Maxim Dounin d1047fff93 nginx-1.17.9-RELEASE 2020-03-03 18:04:21 +03:00
Maxim Dounin 58ee23f857 Updated PCRE used for win32 builds. 2020-03-03 18:03:28 +03:00
Sergey Kandaurov 131b2bb9bf QUIC handshake final bits.
Added handling of client Finished, both feeding and acknowledgement.
This includes sending NST in 1-RTT triggered by a handshake process.
2020-03-03 17:25:02 +03:00
Vladimir Homutov d7c0d2df7a Split frame and packet generation into separate steps.
While there, a number of QUIC constants from spec defined and magic numbers
were replaced.
2020-03-03 13:30:30 +03:00
Vladimir Homutov 11cd3e4683 Aded the "ngx_quic_hexdump" macro.
ngx_quic_hexdump0(log, format, buffer, buffer_size);
    - logs hexdump of buffer to specified error log

    ngx_quic_hexdump0(c->log, "this is foo:", foo.data, foo.len);

ngx_quic_hexdump(log, format, buffer, buffer_size, ...)
    - same as hexdump0, but more format/args possible:

    ngx_quic_hexdump(c->log, "a=%d b=%d, foo is:", foo.data, foo.len, a, b);
2020-03-02 21:38:03 +03:00
Roman Arutyunyan c189ca50a0 Simplified subrequest finalization.
Now it looks similar to what it was before background subrequests were
introduced in 9552758a786e.
2020-02-28 19:54:13 +03:00
Dmitry Volyntsev b27902e576 Fixed premature background subrequest finalization.
When "aio" or "aio threads" is used while processing the response body of an
in-memory background subrequest, the subrequest could be finalized with an aio
operation still in progress.  Upon aio completion either parent request is
woken or the old r->write_event_handler is called again.  The latter may result
in request errors.  In either case post_subrequest handler is never called with
the full response body, which is typically expected when using in-memory
subrequests.

Currently in nginx background subrequests are created by the upstream module
and the mirror module.  The issue does not manifest itself with these
subrequests because they are header-only.  But it can manifest itself with
third-party modules which create in-memory background subrequests.
2020-03-02 20:07:36 +03:00
Maxim Dounin 74f797024f Added default overwrite in error_page 494.
We used to have default error_page overwrite for 495, 496, and 497, so
a configuration like

    error_page 495 /error;

will result in error 400, much like without any error_page configured.

The 494 status code was introduced later (in 3848:de59ad6bf557, nginx 0.9.4),
and relevant changes to ngx_http_core_error_page() were missed, resulting
in inconsistent behaviour of "error_page 494" - with error_page configured
it results in 494 being returned instead of 400.

Reported by Frank Liu,
http://mailman.nginx.org/pipermail/nginx/2020-February/058957.html.
2020-02-28 17:21:18 +03:00
Vladimir Homutov 49049bdd1b Moved all QUIC code into ngx_event_quic.c
Introduced ngx_quic_input() and ngx_quic_output() as interface between
nginx and protocol.  They are the only functions that are exported.

While there, added copyrights.
2020-02-28 16:23:25 +03:00
Sergey Kandaurov fd70d48420 Introduced quic_version macro, uint16/uint32 routines ported. 2020-02-28 13:09:52 +03:00
Sergey Kandaurov c3aa2abe4e Cleanup. 2020-02-28 13:09:52 +03:00
Vladimir Homutov 9ae0d4089c Generic function for HKDF expansion. 2020-02-26 16:56:47 +03:00
Sergey Kandaurov eb36fdff02 QUIC header protection routines, introduced ngx_quic_tls_hp(). 2020-02-28 13:09:52 +03:00
Sergey Kandaurov 74c165c94e AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal(). 2020-02-28 13:09:52 +03:00
Sergey Kandaurov 81f1ccd4ee Transport parameters stub, to complete handshake. 2020-02-28 13:09:52 +03:00
Sergey Kandaurov 930c146505 Introduced ngx_quic_secret_t. 2020-02-28 13:09:52 +03:00
Sergey Kandaurov f1f2cac9e8 QUIC handshake handler, draft 24 bump. 2020-02-28 13:09:52 +03:00
Sergey Kandaurov 4ea79f7d02 Fixed indentation. 2020-02-28 13:09:52 +03:00
Sergey Kandaurov 6d32c6184e PN-aware AEAD nonce, feeding proper CRYPTO length. 2020-02-28 13:09:52 +03:00
Sergey Kandaurov 5ec316b631 OpenSSL compatibility. 2020-02-28 13:09:51 +03:00
Sergey Kandaurov dafa5d611a QUIC add_handshake_data callback, varint routines. 2020-02-28 13:09:51 +03:00
Sergey Kandaurov fdfc8d7bd1 QUIC set_encryption_secrets callback. 2020-02-28 13:09:51 +03:00
Sergey Kandaurov 67f8c85e40 Server Initial Keys. 2020-02-28 13:09:51 +03:00
Sergey Kandaurov f45ea7a822 Initial QUIC support in http. 2020-02-28 13:09:51 +03:00
Sergey Kandaurov 7860cca902 HTTP UDP layer, QUIC support autotest. 2020-02-28 13:09:51 +03:00
Vladimir Homutov a03810451f Created the "quic" branch. 2020-03-03 12:14:44 +03:00
Roman Arutyunyan 25c17b45fd Mp4: fixed possible chunk offset overflow.
In "co64" atom chunk start offset is a 64-bit unsigned integer.  When trimming
the "mdat" atom, chunk offsets are casted to off_t values which are typically
64-bit signed integers.  A specially crafted mp4 file with huge chunk offsets
may lead to off_t overflow and result in negative trim boundaries.

The consequences of the overflow are:
- Incorrect Content-Length header value in the response.
- Negative left boundary of the response file buffer holding the trimmed "mdat".
  This leads to pread()/sendfile() errors followed by closing the client
  connection.

On rare systems where off_t is a 32-bit integer, this scenario is also feasible
with the "stco" atom.

The fix is to add checks which make sure data chunks referenced by each track
are within the mp4 file boundaries.  Additionally a few more checks are added to
ensure mp4 file consistency and log errors.
2020-02-26 15:10:46 +03:00
Sergey Kandaurov 6585e29253 Disabled connection reuse while in SSL handshake.
During SSL handshake, the connection could be reused in the OCSP stapling
callback, if configured, which subsequently leads to a segmentation fault.
2020-02-27 19:03:21 +03:00
Maxim Dounin a3f2dac7f9 Disabled duplicate "Host" headers (ticket #1724).
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-20 16:51:07 +03:00
Maxim Dounin f14a3fc072 Removed "Transfer-Encoding: identity" support.
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-20 16:19:34 +03:00
Maxim Dounin 258ec44264 Disabled multiple Transfer-Encoding headers.
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-20 16:19:29 +03:00
Vladimir Homutov 14a35ea973 Made ngx_http_get_forwarded_addr_internal() non-recursive. 2020-02-11 13:22:44 +03:00
Sergey Kandaurov 813e53b23d HTTP/2: fixed socket leak with an incomplete HEADERS frame.
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-05 16:29:23 +03:00
Sergey Kandaurov 469054b2c9 Version bump. 2020-02-05 16:29:14 +03:00
Maxim Dounin c58eb1d482 release-1.17.8 tag 2020-01-21 16:39:42 +03:00
Maxim Dounin 081e2a2a2d nginx-1.17.8-RELEASE 2020-01-21 16:39:41 +03:00
Vladimir Homutov 2d553e20ba gRPC: variables support in the "grpc_pass" directive. 2020-01-17 12:13:02 +03:00
Daniil Bondarev c422418c65 HTTP/2: removed ngx_debug_point() call.
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.
2020-01-14 14:20:08 +03:00
Maxim Dounin 099cd8c9b6 SSL: reworked posted next events again.
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-27 19:43:01 +03:00
Maxim Dounin 1b2b074d15 Trailing space removed. 2019-12-27 17:20:25 +03:00
Maxim Dounin 0c801d1f7c Version bump. 2019-12-27 17:20:20 +03:00
Maxim Dounin 36eda0c5dc release-1.17.7 tag 2019-12-24 18:00:09 +03:00
Maxim Dounin 341dfe7503 nginx-1.17.7-RELEASE 2019-12-24 18:00:09 +03:00
Maxim Dounin 82766761b8 SSL: reworked posted next events.
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-24 17:24:59 +03:00
Maxim Dounin 9ca36e4086 HTTP/2: introduced separate handler to retry stream close.
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-23 21:25:21 +03:00
Maxim Dounin 47f728834c HTTP/2: fixed socket leak with queued frames (ticket #1689).
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-23 21:25:17 +03:00
Maxim Dounin 7d46a1e2c9 Dav: added checks for chunked to body presence conditions.
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-23 20:39:27 +03:00
Sergey A. Osokin bf3e0cf858 Update manpage, sort command line options. 2019-12-23 18:56:21 +03:00
Ruslan Ermilov 047760a4d2 Discard request body when redirecting to a URL via error_page.
Reported by Bert JW Regeer and Francisco Oca Gonzalez.
2019-12-23 15:45:46 +03:00
Ruslan Ermilov b26e64492b Rewrite: disallow empty replacements.
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-16 15:19:01 +03:00
Ruslan Ermilov b44253a3bc Tolerate '\0' in URI when mapping URI to path.
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-16 15:19:01 +03:00
Ruslan Ermilov b566189221 Rewrite: fixed segfault with rewritten URI and "alias".
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-16 15:19:01 +03:00
Ruslan Ermilov 2d03ee717e Fixed request finalization in ngx_http_index_handler().
Returning 500 instead of NGX_ERROR is preferable here because
header has not yet been sent to the client.
2019-12-16 15:19:01 +03:00
Ruslan Ermilov 57998d4a94 Saved some memory allocations.
In configurations when "root" has variables, some modules unnecessarily
allocated memory for the "Location" header value.
2019-12-16 15:19:01 +03:00
Ruslan Ermilov d6f82b6e12 Dav: fixed Location in successful MKCOL response.
Instead of reducing URI length to not include the terminating '\0'
character in 6ddaac3e0bf7, restore the terminating '/' character.
2019-12-16 15:19:01 +03:00
Maxim Dounin 06416c4042 Upstream keepalive: clearing of c->data in cached connections.
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-05 19:38:06 +03:00
Maxim Dounin c728b39955 Version bump. 2019-12-05 19:22:48 +03:00
Maxim Dounin e552668959 release-1.17.6 tag 2019-11-19 17:18:58 +03:00
Maxim Dounin 3ffa7f223e nginx-1.17.6-RELEASE 2019-11-19 17:18:58 +03:00
Roman Arutyunyan f6ad4d8410 Limit conn: added shared context.
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-18 19:50:59 +03:00
Roman Arutyunyan e64c522555 Limit conn: $limit_conn_status variable.
The variable takes one of the values: PASSED, REJECTED or REJECTED_DRY_RUN.
2019-11-18 17:48:32 +03:00
Roman Arutyunyan e3d3ab7779 Limit conn: limit_conn_dry_run directive.
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-19 11:30:41 +03:00
Roman Arutyunyan a14d6ecc8a Updated comment after 776d1bebdca2. 2019-11-18 17:46:52 +03:00
Roman Arutyunyan 49b988c73f Limit req: $limit_req_status variable.
The variable takes one of the values: PASSED, DELAYED, REJECTED,
DELAYED_DRY_RUN or REJECTED_DRY_RUN.
2019-11-06 19:03:18 +03:00
Roman Arutyunyan 02851faf3b Parsing server PROXY protocol address and port (ticket #1206).
New variables $proxy_protocol_server_addr and $proxy_protocol_server_port are
added both to HTTP and Stream.
2019-10-21 20:22:30 +03:00
Roman Arutyunyan 9af8677446 Core: moved PROXY protocol fields out of ngx_connection_t.
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-21 18:06:19 +03:00
Roman Arutyunyan 420e84f9bb Version bump. 2019-10-24 13:47:28 +03:00
Maxim Dounin beafb4e45d release-1.17.5 tag 2019-10-22 18:16:08 +03:00
Maxim Dounin 7f5d6f42b8 nginx-1.17.5-RELEASE 2019-10-22 18:16:08 +03:00
Maxim Dounin aaa707c500 Win32: silenced -Wcast-function-type GCC warning (ticket #1865).
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-21 19:07:03 +03:00
Maxim Dounin 2f5a070f9c Win32: improved fallback on FormatMessage() errors.
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-21 19:06:12 +03:00
Maxim Dounin 26ff563dfd SSL: available bytes handling (ticket #1431).
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-17 16:02:24 +03:00
Maxim Dounin 7b87731ce3 Events: available bytes calculation via ioctl(FIONREAD).
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-17 16:02:19 +03:00
Maxim Dounin 249da9d288 SSL: improved ngx_ssl_recv_chain() to stop if c->read->ready is 0.
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-17 16:02:13 +03:00
Maxim Dounin bca84cb725 Event pipe: disabled c->read->available checking for SSL.
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-17 16:02:03 +03:00
Ruslan Ermilov f1ce53ab61 Fixed header parsing with ignore_invalid_headers switched off.
The parsing was broken when the first character of the header name was invalid.

Based on a patch by Alan Kemp.
2019-10-15 14:46:10 +03:00
Maxim Dounin ecb964d46f Fixed URI normalization with merge_slashes switched off.
Previously, "/foo///../bar" was normalized into "/foo/bar"
instead of "/foo//bar".
2019-10-08 21:56:14 +03:00
Ruslan Ermilov 3cc9b52615 The "/." and "/.." at the end of URI should be normalized. 2019-10-08 21:56:14 +03:00
Ruslan Ermilov 164f949bfd Improved detection of broken percent encoding in URI. 2019-10-08 21:56:14 +03:00
Vladimir Homutov f3f0c4e76e Core: removed dead code in ngx_rbtree_delete().
The result of ngx_rbtree_min() is always a node with the left child equal to
sentinel, thus the check is unnecessary.
2019-09-30 16:39:20 +03:00
Vladimir Homutov 27fc42b3a3 Version bump. 2019-09-30 16:43:16 +03:00
Maxim Dounin dde2a3d1ee release-1.17.4 tag 2019-09-24 18:08:48 +03:00
Maxim Dounin 75c45aab4a nginx-1.17.4-RELEASE 2019-09-24 18:08:48 +03:00
Maxim Dounin 66e1921ebc Updated OpenSSL used for win32 builds. 2019-09-24 16:30:03 +03:00
Ruslan Ermilov 36a28c0baf HTTP/2: fixed worker_shutdown_timeout. 2019-09-23 15:45:36 +03:00
Ruslan Ermilov cf1bc32243 HTTP/2: fixed possible alert about left open socket on shutdown.
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.
2019-09-23 15:45:32 +03:00
Maxim Dounin 925ed3ed1e HTTP/2: traffic-based flood detection.
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.
2019-09-18 20:28:12 +03:00
Maxim Dounin f0f8a7507b HTTP/2: switched back to RST_STREAM with NO_ERROR.
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.
2019-09-18 20:28:09 +03:00
Sergey Kandaurov f406afdae4 SSL: fixed ssl_verify_client error message. 2019-09-16 19:26:42 +03:00
Sergey Kandaurov fda3b3bdda Resolver: fixed possible use-after-free while resolving PTR.
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.
2019-09-10 15:42:34 +03:00
Ruslan Ermilov 8c41e98dc4 HTTP/2: close connection on zero WINDOW_UPDATE.
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.
2019-09-10 15:33:38 +03:00
Ruslan Ermilov 342e74ca42 HTTP/2: close connection on frames with self-dependency.
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.
2019-09-10 15:33:37 +03:00
Sergey Kandaurov 55553d2e07 Fixed "return" with discarding invalid chunked body.
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.
2019-09-04 13:33:51 +03:00
Sergey Kandaurov b0f6fb078b Detect runaway chunks in ngx_http_parse_chunked().
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
2019-09-03 17:26:56 +03:00
Sergey Kandaurov 9cd21ae0cd HTTP/2: discard remaining request body after redirect.
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;
    }
2019-08-19 15:16:06 +03:00
Maxim Dounin ddade3df22 SSL: lowered log level for WSAECONNABORTED errors on Windows.
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.
2019-08-16 18:16:21 +03:00
Maxim Dounin f901d4b0cb Version bump. 2019-08-16 18:16:14 +03:00
Maxim Dounin b10ed3d88c release-1.17.3 tag 2019-08-13 15:45:57 +03:00
Maxim Dounin 2e46a4cf96 nginx-1.17.3-RELEASE 2019-08-13 15:45:56 +03:00
Ruslan Ermilov 85b43514b3 HTTP/2: limited number of PRIORITY frames.
Fixed excessive CPU usage caused by a peer that continuously shuffles
priority of streams.  Fix is to limit the number of PRIORITY frames.
2019-08-13 15:43:40 +03:00
Ruslan Ermilov 97dc3161b1 HTTP/2: limited number of DATA frames.
Fixed excessive memory growth and CPU usage if stream windows are
manipulated in a way that results in generating many small DATA frames.
Fix is to limit the number of simultaneously allocated DATA frames.
2019-08-13 15:43:36 +03:00
Sergey Kandaurov 840b44c522 HTTP/2: reject zero length headers with PROTOCOL_ERROR.
Fixed uncontrolled memory growth if peer sends a stream of
headers with a 0-length header name and 0-length header value.
Fix is to reject headers with zero name length.
2019-08-13 15:43:32 +03:00
Maxim Dounin 8c636fc214 Mail: fixed duplicate resolving.
When using SMTP with SSL and resolver, read events might be enabled
during address resolving, leading to duplicate ngx_mail_ssl_handshake_handler()
calls if something arrives from the client, and duplicate session
initialization - including starting another resolving.  This can lead
to a segmentation fault if the session is closed after first resolving
finished.  Fix is to block read events while resolving.

Reported by Robert Norris,
http://mailman.nginx.org/pipermail/nginx/2019-July/058204.html.
2019-08-01 13:50:07 +03:00
Maxim Dounin 1e506601bc Gzip: fixed "zero size buf" alerts after ac5a741d39cf.
After ac5a741d39cf it is now possible that after zstream.avail_out
reaches 0 and we allocate additional buffer, there will be no more data
to put into this buffer, triggering "zero size buf" alert.  Fix is to
reset b->temporary flag in this case.

Additionally, an optimization added to avoid allocating additional buffer
in this case, by checking if last deflate() call returned Z_STREAM_END.
Note that checking for Z_STREAM_END by itself is not enough to fix alerts,
as deflate() can return Z_STREAM_END without producing any output if the
buffer is smaller than gzip trailer.

Reported by Witold Filipczyk,
http://mailman.nginx.org/pipermail/nginx-devel/2019-July/012469.html.
2019-07-31 17:29:00 +03:00
Maxim Dounin 1f59c28eb2 Version bump. 2019-07-31 17:28:41 +03:00
Maxim Dounin f2c1582ef3 release-1.17.2 tag 2019-07-23 15:01:47 +03:00
Maxim Dounin 9cae8ac4b4 nginx-1.17.2-RELEASE 2019-07-23 15:01:47 +03:00
Maxim Dounin dafd1da221 Core: fixed memory leak on error, missed in c3f60d618c17.
Found by Coverity (CID 1451664).
2019-07-19 17:50:00 +03:00
Maxim Dounin d084acda51 Xslt: fixed potential buffer overflow with null character.
Due to shortcomings of the ccv->zero flag implementation in complex value
interface, length of the resulting string from ngx_http_complex_value()
might either not include terminating null character or include it,
so the only safe way to work with the result is to use it as a
null-terminated string.

Reported by Patrick Wollgast.
2019-07-18 18:27:54 +03:00
Maxim Dounin 28ff4274dd SSI: avoid potential buffer overflow.
When "-" follows a parameter of maximum length, a single byte buffer
overflow happens, since the error branch does not check parameter length.
Fix is to avoid saving "-" to the parameter key, and instead use an error
message with "-" explicitly written.  The message is mostly identical to
one used in similar cases in the preequal state.

Reported by Patrick Wollgast.
2019-07-18 18:27:53 +03:00
Maxim Dounin ac4aa62d03 Upstream: fixed EOF handling in unbuffered and upgraded modes.
With level-triggered event methods it is important to specify
the NGX_CLOSE_EVENT flag to ngx_handle_read_event(), otherwise
the event won't be removed, resulting in CPU hog.

Reported by Patrick Wollgast.
2019-07-18 18:27:52 +03:00
Maxim Dounin 78143589df HTTP/2: return error on output on closed stream.
Without this, an (incorrect) output on a closed stream could result in
a socket leak.
2019-07-18 18:27:50 +03:00
Maxim Dounin c8ceab6f30 Core: fixed segfault with too large bucket sizes (ticket #1806).
To save memory hash code uses u_short to store resulting bucket sizes,
so maximum bucket size is limited to 65536 minus ngx_cacheline_size (larger
values will be aligned to 65536 which will overflow u_short).  However,
there were no checks to enforce this, and using larger bucket sizes
resulted in overflows and segmentation faults.

Appropriate safety checks to enforce this added to ngx_hash_init().
2019-07-18 18:27:44 +03:00
Maxim Dounin a69c2ec20a Perl: removed unused variable, forgotten in 975d7ab37b39. 2019-07-17 17:00:57 +03:00
Ilya Leoshkevich 35545a0244 Gzip: use zlib to write header and trailer.
When nginx is used with zlib patched with [1], which provides
integration with the future IBM Z hardware deflate acceleration, it ends
up computing CRC32 twice: one time in hardware, which always does this,
and one time in software by explicitly calling crc32().

crc32() calls were added in changesets 133:b27548f540ad ("nginx-0.0.1-
2003-09-24-23:51:12 import") and 134:d57c6835225c ("nginx-0.0.1-
2003-09-26-09:45:21 import") as part of gzip wrapping feature - back
then zlib did not support it.

However, since then gzip wrapping was implemented in zlib v1.2.0.4,
and it's already being used by nginx for log compression.

This patch replaces hand-written gzip wrapping with the one provided by
zlib. It simplifies the code, and makes it avoid computing CRC32 twice
when using hardware acceleration.

[1] https://github.com/madler/zlib/pull/410
2019-07-12 12:43:08 +02:00
Maxim Dounin 60b3ffe750 Perl: named locations in $r->internal_redirect(). 2019-07-12 15:39:28 +03:00
Maxim Dounin dc8efe9ed3 Perl: expect escaped URIs in $r->internal_redirect().
Similarly to the change in 5491:74bfa803a5aa (1.5.9), we should accept
properly escaped URIs and unescape them as needed, else it is not possible
to handle URIs with question marks.
2019-07-12 15:39:26 +03:00
Maxim Dounin ff1e2fce0a Perl: additional ctx->header_sent checks.
As we now have ctx->header_sent flag, it is further used to prevent
duplicate $r->send_http_header() calls, prevent output before sending
header, and $r->internal_redirect() after sending header.

Further, $r->send_http_header() protected from calls after
$r->internal_redirect().
2019-07-12 15:39:25 +03:00
Maxim Dounin ab8faab805 Perl: avoid returning 500 if header was already sent.
Returning NGX_HTTP_INTERNAL_SERVER_ERROR if a perl code died after
sending header will lead to a "header already sent" alert.  To avoid
it, we now check if header was already sent, and return NGX_ERROR
instead if it was.
2019-07-12 15:39:25 +03:00
Maxim Dounin 37e208b5d1 Perl: avoid redirects on errors.
Previously, redirects scheduled with $r->internal_redirect() were followed
even if the code then died.  Now these are ignored and nginx will return
an error instead.
2019-07-12 15:38:27 +03:00
Maxim Dounin 7f544efb53 Perl: disabled unrelated calls from variable handlers.
Variable handlers are not expected to send anything to the client, cannot
sleep or read body, and are not expected to modify the request.  Added
appropriate protection to prevent accidental foot shooting.
2019-07-12 15:35:31 +03:00
Maxim Dounin 38ad3f8d3d Perl: protection against duplicate $r->sleep() calls.
Duplicate $r->sleep() and/or $r->has_request_body() calls result
in undefined behaviour (in practice, connection leaks were observed).
To prevent this, croak() added in appropriate places.
2019-07-12 15:34:37 +03:00
Maxim Dounin dd6daa9284 Perl: handling of allocation errors.
Previously, allocation errors in nginx.xs were more or less ignored,
potentially resulting in incorrect code execution in specific low-memory
conditions.  This is changed to use ctx->error bit and croak(), similarly
to how output errors are now handled.

Note that this is mostly a cosmetic change, as Perl itself exits on memory
allocation errors, and hence nginx with Perl is hardly usable in low-memory
conditions.
2019-07-12 13:56:23 +03:00
Maxim Dounin d421c4ecc4 Perl: propagate errors.
When an error happens, the ctx->error bit is now set, and croak()
is called to terminate further processing.  The ctx->error bit is
checked in ngx_http_perl_call_handler() to cancel further processing,
and is also checked in various output functions - to make sure these won't
be called if croak() was handled by an eval{} in perl code.

In particular, this ensures that output chain won't be called after
errors, as filters might not expect this to happen.  This fixes some
segmentation faults under low memory conditions.  Also this stops
request processing after filter finalization or request body reading
errors.

For cases where an HTTP error status can be additionally returned (for
example, 416 (Requested Range Not Satisfiable) from the range filter),
the ctx->status field is also added.
2019-07-12 13:56:21 +03:00
Maxim Dounin 1689e8a02a Perl: reworked perl module to pass ctx instead of request.
This ensures that correct ctx is always available, including after
filter finalization.  In particular, this fixes a segmentation fault
with the following configuration:

    location / {
        image_filter test;

        perl 'sub {
            my $r = shift;
            $r->send_http_header();
            $r->print("foo\n");
            $r->print("bar\n");
        }';
    }

This also seems to be the only way to correctly handle filter finalization
in various complex cases, for example, when embedded perl is used both
in the original handler and in an error page called after filter
finalization.
2019-07-12 11:29:22 +03:00
Maxim Dounin 792128b7f5 Perl: removed unneeded NGX_DONE test.
The NGX_DONE test in ngx_http_perl_handle_request() was introduced
in 1702:86bb52e28ce0, which also modified ngx_http_perl_call_handler()
to return NGX_DONE with c->destroyed.  The latter part was then
removed in 3050:f54b02dbb12b, so NGX_DONE test is no longer needed.
2019-07-11 23:20:08 +03:00
Gena Makhomed 16588dffcc Contrib: vim syntax, update core and 3rd party module directives. 2019-06-30 10:39:01 +03:00
Maxim Dounin a1e74376bd Typo. 2019-07-09 16:03:25 +03:00
Maxim Dounin 1ba10dc3f2 Version bump. 2019-07-09 16:01:32 +03:00
Maxim Dounin 79d14aff30 release-1.17.1 tag 2019-06-25 15:19:45 +03:00
Maxim Dounin 04d506331c nginx-1.17.1-RELEASE 2019-06-25 15:19:45 +03:00
Maxim Dounin aa9f8db729 Updated OpenSSL used for win32 builds. 2019-06-25 04:47:43 +03:00
Maxim Dounin 2af0152d0a Perl: disabled not_modified filter (ticket #1786).
Embedded perl does not set any request fields needed for conditional
requests processing.  Further, filter finalization in the not_modified
filter can cause segmentation faults due to cleared ctx as in
ticket #1786.

Before 5fb1e57c758a (1.7.3) the not_modified filter was implicitly disabled
for perl responses, as r->headers_out.last_modified_time was -1.  This
change restores this behaviour by using the explicit r->disable_not_modified
flag.

Note that this patch doesn't try to address perl module robustness against
filter finalization and other errors returned from filter chains.  It should
be eventually reworked to handle errors instead of ignoring them.
2019-06-17 19:48:56 +03:00
Roman Arutyunyan a43414f0b3 Limit req: limit_req_dry_run directive.
A new directive limit_req_dry_run allows enabling the dry run mode.  In this
mode requests are neither rejected nor delayed, but reject/delay status is
logged as usual.
2019-06-05 19:55:27 +03:00
Roman Arutyunyan b79ac4c1fd Upstream: background cache update before cache send (ticket #1782).
In case of filter finalization, essential request fields like r->uri,
r->args etc could be changed, which affected the cache update subrequest.
Also, after filter finalization r->cache could be set to NULL, leading to
null pointer dereference in ngx_http_upstream_cache_background_update().
The fix is to create background cache update subrequest before sending the
cached response.

Since initial introduction in 1aeaae6e9446 (1.11.10) background cache update
subrequest was created after sending the cached response because otherwise it
blocked the parent request output.  In 9552758a786e (1.13.1) background
subrequests were introduced to eliminate the delay before sending the final
part of the cached response.  This also made it possible to create the
background cache update subrequest before sending the response.

Note that creating the subrequest earlier does not change the fact that in case
of filter finalization the background cache update subrequest will likely not
have enough time to successfully update the cache entry.  Filter finalization
leads to the main request termination as soon the current iteration of request
processing is complete.
2019-06-03 20:33:26 +03:00
Niklas Keller 048e3ffe43 Upstream hash: fall back to round-robin if hash key is empty. 2019-05-23 16:49:22 +03:00
Roman Arutyunyan a44076c4cb Version bump. 2019-05-27 19:47:50 +03:00
Maxim Dounin 76c5c5401a release-1.17.0 tag 2019-05-21 17:23:57 +03:00
Maxim Dounin 56fac7fe0a nginx-1.17.0-RELEASE 2019-05-21 17:23:57 +03:00
Sergey Kandaurov 60a20c0a8b Cache: reset c->body_start when reading a variant on Vary mismatch.
Previously, a variant not present in shared memory and stored on disk using a
secondary key was read using c->body_start from a variant stored with a main
key.  This could result in critical errors "cache file .. has too long header".
2017-08-04 19:37:37 +03:00
Sergey Kandaurov 301f2ffb52 HTTP/2: rejecting invalid stream identifiers with PROTOCOL_ERROR.
Prodded by Xu Yang.
2020-09-02 23:13:36 +03:00
Roman Arutyunyan 9059332c35 Cache: ignore stale-if-error for 4xx and 5xx codes.
Previously the stale-if-error extension of the Cache-Control upstream header
triggered the return of a stale response for all error conditions that can be
specified in the proxy_cache_use_stale directive.  The list of these errors
includes both network/timeout/format errors, as well as some HTTP codes like
503, 504, 403, 429 etc.  The latter prevented a cache entry from being updated
by a response with any of these HTTP codes during the stale-if-error period.

Now stale-if-error only works for network/timeout/format errors and ignores
the upstream HTTP code.  The return of a stale response for certain HTTP codes
is still possible using the proxy_cache_use_stale directive.

This change also applies to the stale-while-revalidate extension of the
Cache-Control header, which triggers stale-if-error if it is missing.

Reported at
http://mailman.nginx.org/pipermail/nginx/2020-July/059723.html.
2020-07-29 13:28:04 +03:00
Roman Arutyunyan f95a4bf0e7 Version bump. 2020-08-14 12:45:52 +03:00
Sergey Kandaurov 851b33a4be SSL: removed OpenSSL 0.9.7 compatibility. 2016-04-11 15:46:36 +03:00
Maxim Dounin 35c2d164b4 Range filter: fixed duplicate last buffers.
In ngx_http_range_singlepart_body() special buffers where passed
unmodified, including ones after the end of the range.  As such,
if the last buffer of a response was sent separately as a special
buffer, two buffers with b->last_buf set were present in the response.

In particular, this might result in a duplicate final chunk when using
chunked transfer encoding (normally range filter and chunked transfer
encoding are not used together, but this may happen if there are trailers
in the response).  This also likely to cause problems in HTTP/2.

Fix is to skip all special buffers after we've sent the last part of
the range requested.  These special buffers are not meaningful anyway,
since we set b->last_buf in the buffer with the last part of the range,
and everything is expected to be flushed due to it.

Additionally, ngx_http_next_body_filter() is now called even
if no buffers are to be passed to it.  This ensures that various
write events are properly propagated through the filter chain.  In
particular, this fixes test failures observed with the above change
and aio enabled.
2019-05-13 22:44:49 +03:00
Maxim Dounin 430d0a6b4d Range filter: fixed loss of incoming chain links.
Filters are not allowed to change incoming chain links, and should allocate
their own links if any modifications are needed.  Nevertheless
ngx_http_range_singlepart_body() modified incoming chain links in some
cases, notably at the end of the requested range.

No problems caused by this are currently known, mostly because of
limited number of possible modifications and the position of the range
body filter in the filter chain.  Though this behaviour is clearly incorrect
and tests demonstrate that it can at least cause some proxy buffers being
lost when using proxy_force_ranges, leading to less effective handling
of responses.

Fix is to always allocate new chain links in ngx_http_range_singlepart_body().
Links are explicitly freed to ensure constant memory usage with long-lived
requests.
2019-05-13 22:44:02 +03:00
Roman Arutyunyan 3ebdb956f3 Unconditional compilation of the postpone filter.
Postpone filter is an essential part of subrequest functionality.  In absence
of it a subrequest response body is sent to the client out of order with
respect to the main request header and body, as well as other subrequests.
For in-memory subrequests the response is also sent to the client instead of
being stored in memory.

Currently the postpone filter is automatically enabled if one of the following
standard modules which are known to create subrequests is enabled: ssi, slice,
addition.  However a third-party module that creates subrequests can still be
built without the postpone filter or be dynamically loaded in nginx built
without it.
2019-05-08 19:22:13 +03:00
Ruslan Ermilov 97fa3682f3 Variables support in proxy_upload_rate and proxy_download_rate. 2019-04-24 16:38:56 +03:00
Ruslan Ermilov 4ffc4179aa Variables support in limit_rate and limit_rate_after (ticket #293). 2019-04-24 16:38:54 +03:00
Ruslan Ermilov 50eb3b587d Added ngx_http_set_complex_value_size_slot().
If a complex value is expected to be of type size_t, and the compiled
value is constant, the constant size_t value is remembered at compile
time.

The value is accessed through ngx_http_complex_value_size() which
either returns the remembered constant or evaluates the expression
and parses it as size_t.
2019-04-24 16:38:51 +03:00
Vladimir Homutov 6b3ad4e3b7 Core: enabled "include" in any context (ticket #1615). 2019-04-09 11:40:20 +03:00
Vladimir Homutov bff8754df1 Version bump. 2019-04-24 13:41:29 +03:00
Maxim Dounin 2c068898bb release-1.15.12 tag 2019-04-16 17:54:59 +03:00
Maxim Dounin 778a776ca9 nginx-1.15.12-RELEASE 2019-04-16 17:54:58 +03:00
Maxim Dounin b521e1286a Updated PCRE used for win32 builds. 2019-04-16 16:32:44 +03:00
Maxim Dounin 45efb24b74 Fixed incorrect length handling in ngx_utf8_length().
Previously, ngx_utf8_decode() was called from ngx_utf8_length() with
incorrect length, potentially resulting in out-of-bounds read when
handling invalid UTF-8 strings.

In practice out-of-bounds reads are not possible though, as autoindex, the
only user of ngx_utf8_length(), provides null-terminated strings, and
ngx_utf8_decode() anyway returns an errors when it sees a null in the
middle of an UTF-8 sequence.

Reported by Yunbin Liu.
2019-04-15 20:14:07 +03:00
Maxim Dounin fc123480f5 OCSP stapling: fixed segfault with dynamic certificate loading.
If OCSP stapling was enabled with dynamic certificate loading, with some
OpenSSL versions (1.0.2o and older, 1.1.0h and older; fixed in 1.0.2p,
1.1.0i, 1.1.1) a segmentation fault might happen.

The reason is that during an abbreviated handshake the certificate
callback is not called, but the certificate status callback was called
(https://github.com/openssl/openssl/issues/1662), leading to NULL being
returned from SSL_get_certificate().

Fix is to explicitly check SSL_get_certificate() result.
2019-04-15 19:13:09 +03:00
Maxim Dounin 8876b03e45 Version bump. 2019-04-15 19:13:06 +03:00
Maxim Dounin 59bf883b17 release-1.15.11 tag 2019-04-09 16:00:30 +03:00
Maxim Dounin a27b28fbf3 nginx-1.15.11-RELEASE 2019-04-09 16:00:30 +03:00
Maxim Dounin e42dcaefa4 Win32: avoid using CFLAGS, just add define instead.
With CFLAGS set as in 7da71a7b141a, OpenSSL compilation drops various
non-important compiler options.  To avoid this, a define is added
instead - OpenSSL is smart enough to recognize -D... in Configure
arguments.
2019-04-04 22:56:41 +03:00
Maxim Dounin 416007f036 Win32: defined pdb path.
By default, MSVC uses vc<version>.pdb in the current directory.
With the "-Fd" switch it is directed to be in the objs directory instead.
2019-04-04 19:30:47 +03:00
Sergey Kandaurov d517113d2d Win32: preserving binary compatibility with Windows XP - Vista.
OpenSSL 1.1.0 and above uses BCrypt if available (Windows 7 or higher).
This results in an unusable binary on older Windows versions, when building
with newer Windows SDK (such as 7.0A).  Using CFLAGS to define _WIN32_WINNT
allows to set a desired ABI and make sure the binary works with Windows XP.

To not mix with other potential CFLAGS uses, it is set in GNUmakefile.
2019-04-04 16:26:56 +03:00
Sergey Kandaurov 60b01a499d Win32: skip building OpenSSL tests to conserve time and space.
When building OpenSSL 1.1.1b, as used for win32 builds, with tests
it takes about twice as long and near ~1GB of additional disk space.
Using "no-tests" OpenSSL configuration option allows to skip them.
Since such an option is supported since OpenSSL 1.1.1 only, it is
residing here and not in configure.
2019-04-04 16:22:03 +03:00
Sergey Kandaurov 564dbfa37d OCSP stapling: open ssl_stapling_file in binary-mode.
OCSP response uses the DER format and as such needs to be opened in binary-mode.
This only has any effect under Win32.
2019-04-03 15:35:39 +03:00
Nikolay Morozov f9af4d7567 SSL: missing free calls in $ssl_client_s_dn and $ssl_client_i_dn.
If X509_get_issuer_name() or X509_get_subject_name() returned NULL,
this could lead to a certificate reference leak.  It cannot happen
in practice though, since each function returns an internal pointer
to a mandatory subfield of the certificate successfully decoded by
d2i_X509() during certificate message processing (closes #1751).
2019-03-26 09:33:57 +03:00
Sergey Kandaurov 5d6e6b3e70 Version bump. 2019-03-26 18:25:08 +03:00
Maxim Dounin 2388e7ceee release-1.15.10 tag 2019-03-26 17:06:55 +03:00
Maxim Dounin fce6cbf017 nginx-1.15.10-RELEASE 2019-03-26 17:06:54 +03:00
Roman Arutyunyan c21827b836 Listen port ranges.
A range is specified with a dash.  For each port in a range a separate listen
socket is created.

Examples:

    listen 8080-9000;
    listen example.com:80-88;
2019-03-06 20:46:09 +03:00
Roman Arutyunyan b21ebd95e1 Removed sorting of getaddrinfo() results.
Previously the ngx_inet_resolve_host() function sorted addresses in a way that
IPv4 addresses came before IPv6 addresses.  This was implemented in eaf95350d75c
(1.3.10) along with the introduction of getaddrinfo() which could resolve host
names to IPv6 addresses.  Since the "listen" directive only used the first
address, sorting allowed to preserve "listen" compatibility with the previous
behavior and with the behavior of nginx built without IPv6 support.  Now
"listen" uses all resolved addresses which makes sorting pointless.
2019-03-20 20:31:59 +03:00
Roman Arutyunyan 35d3e3f15e Multiple addresses in "listen".
Previously only one address was used by the listen directive handler even if
host name resolved to multiple addresses.  Now a separate listening socket is
created for each address.
2019-03-15 15:45:56 +03:00
Maxim Dounin 29dfc49c4e SSL: support for parsing PEM certificates from memory.
This makes it possible to provide certificates directly via variables
in ssl_certificate / ssl_certificate_key directives, without using
intermediate files.
2019-03-09 03:03:56 +03:00
Maxim Dounin e92797ea2d SSL: removed redundant "pkey" variable.
It was accidentally introduced in 77436d9951a1 (1.15.9).  In MSVC 2015
and more recent MSVC versions it triggers warning C4456 (declaration of
'pkey' hides previous local declaration).  Previously, all such warnings
were resolved in 2a621245f4cf.

Reported by Steve Stevenson.
2019-03-09 02:55:43 +03:00
Maxim Dounin aaa324721b SSL: moved c->ssl->handshaked check in server name callback.
Server name callback is always called by OpenSSL, even
if server_name extension is not present in ClientHello.  As such,
checking c->ssl->handshaked before the SSL_get_servername() result
should help to more effectively prevent renegotiation in
OpenSSL 1.1.0 - 1.1.0g, where neither SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS
nor SSL_OP_NO_RENEGOTIATION is available.
2019-03-05 16:34:19 +03:00
Maxim Dounin bd540dd974 SSL: use of the SSL_OP_NO_CLIENT_RENEGOTIATION option.
The SSL_OP_NO_CLIENT_RENEGOTIATION option was introduced in LibreSSL 2.5.1.
Unlike OpenSSL's SSL_OP_NO_RENEGOTIATION, it only disables client-initiated
renegotiation, and hence can be safely used on all SSL contexts.
2019-03-03 16:49:02 +03:00
Maxim Dounin b7553b6b05 SSL: fixed potential leak on memory allocation errors.
If ngx_pool_cleanup_add() fails, we have to clean just created SSL context
manually, thus appropriate call added.

Additionally, ngx_pool_cleanup_add() moved closer to ngx_ssl_create() in
the ngx_http_ssl_module, to make sure there are no leaks due to intermediate
code.
2019-03-03 16:48:39 +03:00
Maxim Dounin bcbe5636ee SSL: server name callback changed to return fatal errors.
Notably this affects various allocation errors, and should generally
improve things if an allocation error actually happens during a callback.

Depending on the OpenSSL version, returning an error can result in
either SSL_R_CALLBACK_FAILED or SSL_R_CLIENTHELLO_TLSEXT error from
SSL_do_handshake(), so both errors were switched to the "info" level.
2019-03-03 16:48:06 +03:00
Maxim Dounin 30f6237400 SSL: server name callback changed to return SSL_TLSEXT_ERR_OK.
OpenSSL 1.1.1 does not save server name to the session if server name
callback returns anything but SSL_TLSEXT_ERR_OK, thus breaking
the $ssl_server_name variable in resumed sessions.

Since $ssl_server_name can be used even if we've selected the default
server and there are no other servers, it looks like the only viable
solution is to always return SSL_TLSEXT_ERR_OK regardless of the actual
result.

To fix things in the stream module as well, added a dummy server name
callback which always returns SSL_TLSEXT_ERR_OK.
2019-03-03 16:47:44 +03:00
Maxim Dounin e85f9628e8 Version bump. 2019-03-03 16:47:41 +03:00
Maxim Dounin a3aad26b5c release-1.15.9 tag 2019-02-26 18:29:22 +03:00
Maxim Dounin 1f1254b0df nginx-1.15.9-RELEASE 2019-02-26 18:29:22 +03:00
Maxim Dounin 6d4b461434 Updated OpenSSL used for win32 builds. 2019-02-26 18:01:30 +03:00
Maxim Dounin a64457e860 SSL: fixed possible segfault with dynamic certificates.
A virtual server may have no SSL context if it does not have certificates
defined, so we have to use config of the ngx_http_ssl_module from the
SSL context in the certificate callback.  To do so, it is now passed as
the argument of the callback.

The stream module doesn't really need any changes, but was modified as
well to match http code.
2019-02-25 21:16:26 +03:00
Maxim Dounin 974fc671fc SSL: adjusted session id context with dynamic certificates.
Dynamic certificates re-introduce problem with incorrect session
reuse (AKA "virtual host confusion", CVE-2014-3616), since there are
no server certificates to generate session id context from.

To prevent this, session id context is now generated from ssl_certificate
directives as specified in the configuration.  This approach prevents
incorrect session reuse in most cases, while still allowing sharing
sessions across multiple machines with ssl_session_ticket_key set as
long as configurations are identical.
2019-02-25 16:42:54 +03:00
Maxim Dounin 4b2d0782a1 SSL: dynamic certificate loading in the stream module. 2019-02-25 16:42:43 +03:00
Maxim Dounin da83ef86d7 SSL: passwords support for dynamic certificate loading.
Passwords have to be copied to the configuration pool to be used
at runtime.  Also, to prevent blocking on stdin (with "daemon off;")
an empty password list is provided.

To make things simpler, password handling was modified to allow
an empty array (with 0 elements and elts set to NULL) as an equivalent
of an array with 1 empty password.
2019-02-25 16:42:23 +03:00
Maxim Dounin 780278cc91 SSL: variables support in ssl_certificate and ssl_certificate_key.
To evaluate variables, a request is created in the certificate callback,
and then freed.  To do this without side effects on the stub_status
counters and connection state, an additional function was introduced,
ngx_http_alloc_request().

Only works with OpenSSL 1.0.2+, since there is no SSL_CTX_set_cert_cb()
in older versions.
2019-02-25 16:42:05 +03:00
Maxim Dounin f995562ba5 SSL: loading of connection-specific certificates. 2019-02-25 16:41:44 +03:00
Maxim Dounin 94b6a7751b SSL: reworked ngx_ssl_certificate().
This makes it possible to reuse certificate loading at runtime,
as introduced in the following patches.

Additionally, this improves error logging, so nginx will now log
human-friendly messages "cannot load certificate" instead of only
referring to sometimes cryptic names of OpenSSL functions.
2019-02-25 16:41:28 +03:00
Maxim Dounin f9420c6d6c SSL: removed logging of empty "(SSL:)" in ngx_ssl_error().
The "(SSL:)" snippet currently appears in logs when nginx code uses
ngx_ssl_error() to log an error, but OpenSSL's error queue is empty.
This can happen either because the error wasn't in fact from OpenSSL,
or because OpenSSL did not indicate the error in the error queue
for some reason.

In particular, currently "(SSL:)" can be seen in errors at least in
the following cases:

- When SSL_write() fails due to a syscall error,
  "[info] ... SSL_write() failed (SSL:) (32: Broken pipe)...".

- When loading a certificate with no data in it,
  "[emerg] PEM_read_bio_X509_AUX(...) failed (SSL:)".
  This can easily happen due to an additional empty line before
  the end line, so all lines of the certificate are interpreted
  as header lines.

- When trying to configure an unknown curve,
  "[emerg] SSL_CTX_set1_curves_list("foo") failed (SSL:)".

Likely there are other cases as well.

With this change, "(SSL:...)" will be only added to the error message
if there is something in the error queue.  This is expected to make
logs more readable in the above cases.  Additionally, with this change
it is now possible to use ngx_ssl_error() to log errors when some
of the possible errors are not from OpenSSL and not expected to have
anything in the error queue.
2019-02-25 16:41:15 +03:00
Maxim Dounin 40bb21f8c6 Style. 2019-02-25 16:41:08 +03:00
Maxim Dounin 4eab5fa3bc Slab: removed redundant page calculation (ticket #1721). 2019-02-12 21:51:15 +03:00
Chanhun Jeong 7b25da68e8 Upstream: fixed logging of required buffer size (ticket #1722). 2019-02-11 13:36:53 +09:00
Sergey Kandaurov d9ced2ac18 SSL: fixed EVP_DigestFinal_ex() error message. 2019-02-07 19:39:35 +03:00
Maxim Dounin a39f08a7f6 SSL: separate checks for errors in ngx_ssl_read_password_file().
Checking multiple errors at once is a bad practice, as in general
it is not guaranteed that an object can be used after the error.
In this particular case, checking errors after multiple allocations
can result in excessive errors being logged when there is no memory
available.
2019-01-31 19:36:51 +03:00
Ruslan Ermilov 8af47e3138 SSL: explicitly zero out session ticket keys. 2019-01-31 19:28:07 +03:00
Roman Arutyunyan 67b0aa25bb Modules compatibility: down flag in ngx_peer_connection_t. 2019-01-31 17:25:03 +03:00
Ruslan Ermilov b63baf324b Use %s for errors returned from configuration parsing handlers. 2018-12-25 15:26:58 +03:00
Sergey Kandaurov ffcdcfa9b1 Configure: added explicit ngx_binext to the linker output argument.
Unlike with GCC or MSVC, Clang linker doesn't auto-append ".exe" to the name
of the output binary when building on win32.
2019-01-30 19:28:27 +03:00
Sergey Kandaurov d5d63640f8 Removed --test-build-eventport workaround for old FreeBSD versions. 2019-01-28 14:34:02 +00:00
Sergey Kandaurov cf10de1801 Fixed portability issues with union sigval.
AIO support in nginx was originally developed against FreeBSD versions 4-6,
where the sival_ptr field was named as sigval_ptr (seemingly by mistake[1]),
which made nginx use the only name available then.  The standard-complaint
name was restored in 2005 (first appeared in FreeBSD 7.0, 2008), retaining
compatibility with previous versions[2][3].  In DragonFly, similar changes
were committed in 2009[4], with backward compatibility recently removed[5].

The change switches to the standard name, retaining compatibility with old
FreeBSD versions.

[1] https://svnweb.freebsd.org/changeset/base/48621
[2] https://svnweb.freebsd.org/changeset/base/152029
[3] https://svnweb.freebsd.org/changeset/base/174003
[4] https://gitweb.dragonflybsd.org/dragonfly.git/commit/3693401
[5] https://gitweb.dragonflybsd.org/dragonfly.git/commit/7875042
2019-01-28 14:33:31 +00:00
Maxim Konovalov 72d40e7fe7 Year 2019. 2019-01-28 13:23:37 +03:00
Maxim Dounin 1051ab0483 Win32: detection of connect() errors in select().
On Windows, connect() errors are only reported via exceptfds descriptor set
from select().  Previously exceptfds was set to NULL, and connect() errors
were not detected at all, so connects to closed ports were waiting till
a timeout occurred.

Since ongoing connect() means that there will be a write event active,
except descriptor set is copied from the write one.  While it is possible
to construct except descriptor set as a concatenation of both read and write
descriptor sets, this looks unneeded.

With this change, connect() errors are properly detected now when using
select().  Note well that it is not possible to detect connect() errors with
WSAPoll() (see https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/).
2019-01-24 22:00:44 +03:00
Maxim Dounin 82612b2635 Win32: enabled both select and poll on Windows by default.
Since we now have both select and poll on Windows, it is enough to
do not set EVENT_FOUND, auto/modules will enable both automatically.
2019-01-24 22:00:13 +03:00
Maxim Dounin b8dd2ddff6 Win32: added WSAPoll() support.
WSAPoll() is only available with Windows Vista and newer (and only
available during compilation if _WIN32_WINNT >= 0x0600).  To make
sure the code works with Windows XP, we do not redefine _WIN32_WINNT,
but instead load WSAPoll() dynamically if it is not available during
compilation.

Also, sockets are not guaranteed to be small integers on Windows.
So an index array is used instead of NGX_USE_FD_EVENT to map
events to connections.
2019-01-24 21:51:21 +03:00
Maxim Dounin 95e1c4e8cf Win32: properly enabled select on Windows.
Previously, select was compiled in by default, but the NGX_HAVE_SELECT
macro was not set, resulting in iocp being used by default unless
the "--with-select_module" configure option was explicitly specified.
Since the iocp module is not finished and does not work properly, this
effectively meant that the "--with-select_module" option was mandatory.

With the change NGX_HAVE_SELECT is properly set, making "--with-select_module"
optional.  Accordingly, it is removed from misc/GNUmakefile win32 target.
2019-01-24 21:51:00 +03:00
Maxim Dounin 299f677cd7 Events: fixed copying of old events in poll init.
Previously, the code incorrectly assumed "ngx_event_t *" elements
instead of "struct pollfd".

This is mostly cosmetic change, as this code is never called now.
2019-01-24 21:50:37 +03:00
Roman Arutyunyan 7618eefb58 Stream: do not split datagrams when limiting proxy rate.
Previously, when using proxy_upload_rate and proxy_download_rate, the buffer
size for reading from a socket could be reduced as a result of rate limiting.
For connection-oriented protocols this behavior is normal since unread data will
normally be read at the next iteration.  But for datagram-oriented protocols
this is not the case, and unread part of the datagram is lost.

Now buffer size is not limited for datagrams.  Rate limiting still works in this
case by delaying the next reading event.
2018-12-27 19:37:34 +03:00
Roman Arutyunyan 8a9615771f Prevented scheduling events on a shared connection.
A shared connection does not own its file descriptor, which means that
ngx_handle_read_event/ngx_handle_write_event calls should do nothing for it.
Currently the c->shared flag is checked in several places in the stream proxy
module prior to calling these functions.  However it was not done everywhere.
Missing checks could lead to calling
ngx_handle_read_event/ngx_handle_write_event on shared connections.

The problem manifested itself when using proxy_upload_rate and resulted in
either duplicate file descriptor error (e.g. with epoll) or incorrect further
udp packet processing (e.g. with kqueue).

The fix is to set and reset the event active flag in a way that prevents
ngx_handle_read_event/ngx_handle_write_event from scheduling socket events.
2019-01-14 20:36:23 +03:00
Vladimir Homutov 33a22c1cfa Added the ngx_http_test_required_predicates() function.
In contrast to ngx_http_test_predicates(), it requires all values to be
non-empty and not equal to "0".
2019-01-17 14:31:04 +03:00
Vladimir Homutov 22b7c3d174 Version bump. 2019-01-17 14:31:01 +03:00
Maxim Dounin 66b4aba566 release-1.15.8 tag 2018-12-25 17:53:03 +03:00
Maxim Dounin a1ef8b9c05 nginx-1.15.8-RELEASE 2018-12-25 17:53:03 +03:00
Vladimir Homutov 2f8c01b2e3 Autoindex: fixed possible integer overflow on 32-bit systems. 2018-12-25 12:59:24 +03:00
Gena Makhomed d4f6bf35cb Contrib: vim syntax, update core and 3rd party module directives. 2018-12-24 16:30:10 +02:00
Maxim Dounin 9d7d919697 Win32: removed NGX_DIR_MASK concept.
Previous interface of ngx_open_dir() assumed that passed directory name
has a room for NGX_DIR_MASK at the end (NGX_DIR_MASK_LEN bytes).  While all
direct users of ngx_dir_open() followed this interface, this also implied
similar requirements for indirect uses - in particular, via ngx_walk_tree().

Currently none of ngx_walk_tree() uses provides appropriate space, and
fixing this does not look like a right way to go.  Instead, ngx_dir_open()
interface was changed to not require any additional space and use
appropriate allocations instead.
2018-12-24 21:07:05 +03:00
Sergey Kandaurov cb539b46a4 Userid: using stub for AF_UNIX addresses.
Previously, AF_UNIX addresses misbehaved as AF_INET, which typically resulted
in $uid_set composed from the middle of sun_path.
2018-12-24 19:55:00 +03:00
Sergey Kandaurov 1c27bfd85e SSL: avoid reading on pending SSL_write_early_data().
If SSL_write_early_data() returned SSL_ERROR_WANT_WRITE, stop further reading
using a newly introduced c->ssl->write_blocked flag, as otherwise this would
result in SSL error "ssl3_write_bytes:bad length".  Eventually, normal reading
will be restored by read event posted from successful SSL_write_early_data().

While here, place "SSL_write_early_data: want write" debug on the path.
2018-12-18 15:15:15 +03:00
Maxim Dounin 90fa22cb44 Geo: fixed handling of AF_UNIX client addresses (ticket #1684).
Previously, AF_UNIX client addresses were handled as AF_INET, leading
to unexpected results.
2018-12-14 18:11:06 +03:00
Ruslan Ermilov 6a66ebfda3 Upstream: implemented $upstream_bytes_sent. 2018-12-13 17:23:07 +03:00
Roman Arutyunyan 8ad77cc254 Resolver: report SRV resolve failure if all A resolves failed.
Previously, if an SRV record was successfully resolved, but all of its A
records failed to resolve, NXDOMAIN was returned to the caller, which is
considered a successful resolve rather than an error.  This could result in
losing the result of a previous successful resolve by the caller.

Now NXDOMAIN is only returned if at least one A resolve completed with this
code.  Otherwise the error state of the first A resolve is returned.
2018-12-11 19:41:22 +03:00
Roman Arutyunyan a9c10e9571 Copy regex unnamed captures to cloned subrequests.
Previously, unnamed regex captures matched in the parent request, were not
available in a cloned subrequest.  Now 3 fields related to unnamed captures
are copied to a cloned subrequest: r->ncaptures, r->captures and
r->captures_data.  Since r->captures cannot be changed by either request after
creating a clone, a new flag r->realloc_captures is introduced to force
reallocation of r->captures.

The issue was reported as a proxy_cache_background_update misbehavior in
http://mailman.nginx.org/pipermail/nginx/2018-December/057251.html.
2018-12-11 13:09:00 +03:00
Roman Arutyunyan 33fd6c222a Version bump. 2018-12-11 13:12:35 +03:00
Maxim Dounin 7c70c30027 release-1.15.7 tag 2018-11-27 17:40:21 +03:00
Maxim Dounin 347e47ed16 nginx-1.15.7-RELEASE 2018-11-27 17:40:20 +03:00
Maxim Dounin ba9b0f3f29 Updated OpenSSL used for win32 builds. 2018-11-27 17:02:56 +03:00
Maxim Dounin f9cb4cb6cb Negative size buffers detection.
In the past, there were several security issues which resulted in
worker process memory disclosure due to buffers with negative size.
It looks reasonable to check for such buffers in various places,
much like we already check for zero size buffers.

While here, removed "#if 1 / #endif" around zero size buffer checks.
It looks highly unlikely that we'll disable these checks anytime soon.
2018-11-26 18:29:56 +03:00
Maxim Dounin 3272b66121 Mp4: fixed possible pointer overflow on 32-bit platforms.
On 32-bit platforms mp4->buffer_pos might overflow when a large
enough (close to 4 gigabytes) atom is being skipped, resulting in
incorrect memory addesses being read further in the code.  In most
cases this results in harmless errors being logged, though may also
result in a segmentation fault if hitting unmapped pages.

To address this, ngx_mp4_atom_next() now only increments mp4->buffer_pos
up to mp4->buffer_end.  This ensures that overflow cannot happen.
2018-11-21 20:23:16 +03:00
Maxim Dounin 6123ec0dd1 Limit req: "delay=" parameter.
This parameter specifies an additional "soft" burst limit at which requests
become delayed (but not yet rejected as it happens if "burst=" limit is
exceeded).  Defaults to 0, i.e., all excess requests are delayed.

Originally inspired by Vladislav Shabanov
(http://mailman.nginx.org/pipermail/nginx-devel/2016-April/008126.html).
Further improved based on a patch by Peter Shchuchkin
(http://mailman.nginx.org/pipermail/nginx-devel/2018-October/011522.html).
2018-11-21 18:56:50 +03:00
Maxim Dounin a703fca82c Limit req: fixed error message wording. 2018-11-21 18:56:44 +03:00
Vladimir Homutov 4f05b2b687 Upstream: revised upstream response time variables.
Variables now do not depend on presence of the HTTP status code in response.
If the corresponding event occurred, variables contain time between request
creation and the event, and "-" otherwise.

Previously, intermediate value of the $upstream_response_time variable held
unix timestamp.
2018-11-21 13:40:40 +03:00
Vladimir Homutov 14a5fc247e Upstream: removed unused ngx_http_upstream_t.timeout field. 2018-11-21 13:40:36 +03:00
Maxim Dounin 8aa80bbf93 Core: ngx_explicit_memzero(). 2018-11-15 21:28:02 +03:00
Ruslan Ermilov 9b3272537f Core: free shared memory on cycle initialization failure. 2018-11-15 15:28:54 +03:00
Vladimir Homutov 7f83ab29f9 Stream: proxy_requests directive.
The directive allows to drop binding between a client and existing UDP stream
session after receiving a specified number of packets.  First packet from the
same client address and port will start a new session.  Old session continues
to exist and will terminate at moment defined by configuration: either after
receiving the expected number of responses, or after timeout, as specified by
the "proxy_responses" and/or "proxy_timeout" directives.

By default, proxy_requests is zero (disabled).
2018-11-12 16:29:30 +03:00
Vladimir Homutov 7d1cc21003 Stream: session completion check code moved to a separate function.
The code refactored to simplify the ngx_stream_proxy_process() function
and facilitate adding new session termination conditions.
2018-11-12 12:05:03 +03:00
Vladimir Homutov 89d29aba13 Stream: fixed possible use of a freed connection.
The session handler may result in session termination, thus a connection
pool (from which c->udp was allocated) may be destroyed.
2018-11-07 13:22:14 +03:00
Vladimir Homutov f4572c2e32 Version bump. 2018-11-13 14:42:47 +03:00
Maxim Dounin 5af37b261d release-1.15.6 tag 2018-11-06 16:32:09 +03:00
Maxim Dounin 82bdfe5c07 nginx-1.15.6-RELEASE 2018-11-06 16:32:08 +03:00
Maxim Dounin 5aaad3b54b gRPC: limited allocations due to ping and settings frames. 2018-11-06 16:29:59 +03:00
Ruslan Ermilov 81c59db62e HTTP/2: limit the number of idle state switches.
An attack that continuously switches HTTP/2 connection between
idle and active states can result in excessive CPU usage.
This is because when a connection switches to the idle state,
all of its memory pool caches are freed.

This change limits the maximum allowed number of idle state
switches to 10 * http2_max_requests (i.e., 10000 by default).
This limits possible CPU usage in one connection, and also
imposes a limit on the maximum lifetime of a connection.

Initially reported by Gal Goldshtein from F5 Networks.
2018-11-06 16:29:49 +03:00
Ruslan Ermilov b864af3342 HTTP/2: flood detection.
Fixed uncontrolled memory growth in case peer is flooding us with
some frames (e.g., SETTINGS and PING) and doesn't read data.  Fix
is to limit the number of allocated control frames.
2018-11-06 16:29:35 +03:00
Roman Arutyunyan 0cbcdb3423 Mp4: fixed reading 64-bit atoms.
Previously there was no validation for the size of a 64-bit atom
in an mp4 file.  This could lead to a CPU hog when the size is 0,
or various other problems due to integer underflow when calculating
atom data size, including segmentation fault or worker process
memory disclosure.
2018-11-06 16:29:18 +03:00
Maxim Dounin c18c4970c3 Cache: improved keys zone size error reporting.
After this change, too small keys zones are explicitly reported as such,
much like in the other modules which use shared memory.
2018-10-31 16:49:40 +03:00
Maxim Dounin e63f0258b7 Cache: fixed minimum cache keys zone size limit.
Size of a shared memory zones must be at least two pages - one page
for slab allocator internal data, and another page for actual allocations.
Using 8192 instead is wrong, as there are systems with page sizes other
than 4096.

Note well that two pages is usually too low as well.  In particular, cache
is likely to use two allocations of different sizes for global structures,
and at least four pages will be needed to properly allocate cache nodes.
Except in a few very special cases, with keys zone of just two pages nginx
won't be able to start.  Other uses of shared memory impose a limit
of 8 pages, which provides some room for global allocations.  This patch
doesn't try to address this though.

Inspired by ticket #1665.
2018-10-31 16:49:39 +03:00
chronolaw f2baff308d A minor code clean for macro ngx_event_get_conf in ngx_event.h. 2018-10-19 13:50:36 +08:00
Maxim Dounin 0e1c908577 SSL: explicitly set maximum version (ticket #1654).
With maximum version explicitly set, TLSv1.3 will not be unexpectedly
enabled if nginx compiled with OpenSSL 1.1.0 (without TLSv1.3 support)
will be run with OpenSSL 1.1.1 (with TLSv1.3 support).
2018-10-23 22:11:48 +03:00
Vladimir Homutov a74dfd3ad8 Upstream: proxy_socket_keepalive and friends.
The directives enable the use of the SO_KEEPALIVE option on
upstream connections.  By default, the value is left unchanged.
2018-10-03 14:08:51 +03:00
Vladimir Homutov 2a14738076 Version bump. 2018-10-03 17:02:44 +03:00
Maxim Dounin b5094a3411 release-1.15.5 tag 2018-10-02 18:13:52 +03:00
Maxim Dounin 84fee2220c nginx-1.15.5-RELEASE 2018-10-02 18:13:51 +03:00
Maxim Dounin 836236474f SSL: fixed segfault on renegotiation (ticket #1646).
In e3ba4026c02d (1.15.4) nginx own renegotiation checks were disabled
if SSL_OP_NO_RENEGOTIATION is available.  But since SSL_OP_NO_RENEGOTIATION
is only set on a connection, not in an SSL context, SSL_clear_option()
removed it as long as a matching virtual server was found.  This resulted
in a segmentation fault similar to the one fixed in a6902a941279 (1.9.8),
affecting nginx built with OpenSSL 1.1.0h or higher.

To fix this, SSL_OP_NO_RENEGOTIATION is now explicitly set in
ngx_http_ssl_servername() after adjusting options.  Additionally, instead
of c->ssl->renegotiation we now check c->ssl->handshaked, which seems
to be a more correct flag to test, and will prevent the segmentation fault
from happening even if SSL_OP_NO_RENEGOTIATION is not working.
2018-10-02 17:46:18 +03:00
Ruslan Ermilov 318d5841be Fixed off-by-one error in shared zone initialization.
On systems without atomic ops, not enough space was allocated
for mutex's file name during shared zone initialization.
2018-10-02 13:32:52 +03:00
Ruslan Ermilov 7d49e3424e SSL: fixed unlocked access to sess_id->len. 2018-09-25 14:07:59 +03:00
Ruslan Ermilov de4f4f1a28 Version bump. 2018-09-27 13:05:39 +03:00
Maxim Dounin 44102dd8f2 release-1.15.4 tag 2018-09-25 18:11:39 +03:00
Maxim Dounin 125e757015 nginx-1.15.4-RELEASE 2018-09-25 18:11:39 +03:00
Maxim Dounin d7d05dbf8d SSL: logging level of "no suitable signature algorithm".
The "no suitable signature algorithm" errors are reported by OpenSSL 1.1.1
when using TLSv1.3 if there are no shared signature algorithms.  In
particular, this can happen if the client limits available signature
algorithms to something we don't have a certificate for, or to an empty
list.  For example, the following command:

    openssl s_client -connect 127.0.0.1:8443 -sigalgs rsa_pkcs1_sha1

will always result in the "no suitable signature algorithm" error
as the "rsa_pkcs1_sha1" algorithm refers solely to signatures which
appear in certificates and not defined for use in TLS 1.3 handshake
messages.

The SSL_R_NO_COMMON_SIGNATURE_ALGORITHMS error is what BoringSSL returns
in the same situation.
2018-09-25 14:00:04 +03:00
Maxim Dounin ba334845b3 SSL: logging level of "no suitable key share".
The "no suitable key share" errors are reported by OpenSSL 1.1.1 when
using TLSv1.3 if there are no shared groups (that is, elliptic curves).
In particular, it is easy enough to trigger by using only a single
curve in ssl_ecdh_curve:

    ssl_ecdh_curve secp384r1;

and using a different curve in the client:

    openssl s_client -connect 127.0.0.1:443 -curves prime256v1

On the client side it is seen as "sslv3 alert handshake failure",
"SSL alert number 40":

0:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:ssl/record/rec_layer_s3.c:1528:SSL alert number 40

It can be also triggered with default ssl_ecdh_curve by using a curve
which is not in the default list (X25519, prime256v1, X448, secp521r1,
secp384r1):

    openssl s_client -connect 127.0.0.1:8443 -curves brainpoolP512r1

Given that many clients hardcode prime256v1, these errors might become
a common problem with TLSv1.3 if ssl_ecdh_curve is redefined.  Previously
this resulted in not using ECDH with such clients, but with TLSv1.3 it
is no longer possible and will result in a handshake failure.

The SSL_R_NO_SHARED_GROUP error is what BoringSSL returns in the same
situation.

Seen at:

https://serverfault.com/questions/932102/nginx-ssl-handshake-error-no-suitable-key-share
2018-09-25 13:59:53 +03:00
Gena Makhomed 4d11867c9d Cache: status must be less then 599 in *_cache_valid directives.
Previously, configurations with typo, for example

    fastcgi_cache_valid 200301 302 5m;

successfully pass configuration test. Adding check for status
codes > 599, and such configurations are now properly rejected.
2018-09-24 20:26:46 +03:00
Nova DasSarma 7aef07b1cf Removed bgcolor attribute on body in error pages and autoindex.
The bgcolor attribute overrides compatibility settings in browsers
and leads to undesirable behavior when the default font color is set
to white in the browser, since font-color is not also overridden.
2018-09-19 09:26:47 -05:00
Sergey Kandaurov 854dcfd6e7 SSL: support for TLSv1.3 early data with OpenSSL.
In collaboration with Maxim Dounin.
2018-09-21 20:49:12 +03:00
Maxim Dounin 353f9d3054 SSL: disabled renegotiation checks with SSL_OP_NO_RENEGOTIATION.
Following 7319:dcab86115261, as long as SSL_OP_NO_RENEGOTIATION is
defined, it is OpenSSL library responsibility to prevent renegotiation,
so the checks are meaningless.

Additionally, with TLSv1.3 OpenSSL tends to report SSL_CB_HANDSHAKE_START
at various unexpected moments - notably, on KeyUpdate messages and
when sending tickets.  This change prevents unexpected connection
close on KeyUpdate messages and when finishing handshake with upcoming
early data changes.
2018-09-21 20:31:32 +03:00
Maxim Dounin 8e8957c81a Rewrite: removed r->err_status special handling (ticket #1634).
Trying to look into r->err_status in the "return" directive
makes it behave differently than real errors generated in other
parts of the code, and is an endless source of various problems.
This behaviour was introduced in 726:7b71936d5299 (0.4.4) with
the comment "fix: "return" always overrode "error_page" response code".
It is not clear if there were any real cases this was expected to fix,
but there are several cases which are broken due to this change, some
previously fixed (4147:7f64de1cc2c0).

In ticket #1634, the problem is that when r->err_status is set to
a non-special status code, it is not possible to return a response
by simply returning r->err_status.  If this is the case, the only
option is to return script's e->status instead.  An example
configuration:

    location / {
        error_page 404 =200 /err502;
        return 404;
    }

    location = /err502 {
        return 502;
    }

After the change, such a configuration will properly return
standard 502 error, much like it happens when a 502 error is
generated by proxy_pass.

This also fixes the following configuration to properly close
connection as clearly requested by "return 444":

    location / {
        error_page 404 /close;
        return 404;
    }

    location = /close {
        return 444;
    }

Previously, this required "error_page 404 = /close;" to work
as intended.
2018-09-21 15:59:33 +03:00
Maxim Dounin 4f17183665 Fixed socket leak with "return 444" in error_page (ticket #274).
Socket leak was observed in the following configuration:

    error_page 400 = /close;

    location = /close {
        return 444;
    }

The problem is that "return 444" triggers termination of the request,
and due to error_page termination thinks that it needs to use a posted
request to clear stack.  But at the early request processing where 400
errors are generated there are no ngx_http_run_posted_requests() calls,
so the request is only terminated after an external event.

Variants of the problem include "error_page 497" instead (ticket #695)
and various other errors generated during early request processing
(405, 414, 421, 494, 495, 496, 501, 505).

The same problem can be also triggered with "return 499" and "return 408"
as both codes trigger ngx_http_terminate_request(), much like "return 444".

To fix this, the patch adds ngx_http_run_posted_requests() calls to
ngx_http_process_request_line() and ngx_http_process_request_headers()
functions, and to ngx_http_v2_run_request() and ngx_http_v2_push_stream()
functions in HTTP/2.

Since the ngx_http_process_request() function is now only called via
other functions which call ngx_http_run_posted_requests(), the call
there is no longer needed and was removed.
2018-09-21 15:59:30 +03:00
Maxim Dounin 77e27e6c06 SSL: restore handlers after blocking.
It is possible that after SSL_read() will return SSL_ERROR_WANT_WRITE,
further calls will return SSL_ERROR_WANT_READ without reading any
application data.  We have to call ngx_handle_write_event() and
switch back to normal write handling much like we do if there are some
application data, or the write there will be reported again and again.

Similarly, we have to switch back to normal read handling if there
is saved read handler and SSL_write() returns SSL_ERROR_WANT_WRITE.
2018-09-10 18:57:39 +03:00
Maxim Dounin 8bf3259964 SSL: corrected SSL_ERROR_WANT_WRITE / SSL_ERROR_WANT_READ logging.
While SSL_read() most likely to return SSL_ERROR_WANT_WRITE (and SSL_write()
accordingly SSL_ERROR_WANT_READ) during an SSL renegotiation, it is
not necessary mean that a renegotiation was started.  In particular,
it can never happen during a renegotiation or can happen multiple times
during a renegotiation.

Because of the above, misleading "peer started SSL renegotiation" info
messages were replaced with "SSL_read: want write" and "SSL_write: want read"
debug ones.

Additionally, "SSL write handler" and "SSL read handler" are now logged
by the SSL write and read handlers, to make it easier to understand that
temporary SSL handlers are called instead of normal handlers.
2018-09-10 18:57:19 +03:00
Maxim Dounin 6ea243af77 Lingering close changed to handle NGX_AGAIN.
The "do { c->recv() } while (c->read->ready)" form used in the
ngx_http_lingering_close_handler() is not really correct, as for
example with SSL c->read->ready may be still set when returning NGX_AGAIN
due to SSL_ERROR_WANT_WRITE.  Therefore the above might be an infinite loop.

This doesn't really matter in lingering close, as we shutdown write side
of the socket anyway and also disable renegotiation (and even without shutdown
and with renegotiation it requires using very large certificate chain and
tuning socket buffers to trigger SSL_ERROR_WANT_WRITE).  But for the sake of
correctness added an NGX_AGAIN check.
2018-09-10 18:57:13 +03:00
Maxim Dounin 7edb3f47d7 gRPC: disabled keepalive when sending control frames was blocked.
If sending request body was not completed (u->request_body_sent is not set),
the upstream keepalive module won't save such a connection.  However, it
is theoretically possible (though highly unlikely) that sending of some
control frames can be blocked after the request body was sent.  The
ctx->output_blocked flag introduced to disable keepalive in such cases.
2018-09-03 19:34:02 +03:00
Maxim Dounin 9b42143b65 gRPC: improved keepalive handling.
The code is now able to parse additional control frames after
the response is received, and can send control frames as well.
This fixes keepalive problems as observed with grpc-c, which can
send window update and ping frames after the response, see
http://mailman.nginx.org/pipermail/nginx/2018-August/056620.html.
2018-09-03 19:34:01 +03:00
Maxim Dounin 6a2e5ed387 Uwsgi: added a check on maximum uwsgi request size.
Requested by Chris Caputo.
2018-09-03 19:17:06 +03:00
Maxim Dounin 8106d0e8c0 Uwsgi: style. 2018-09-03 19:17:01 +03:00
Roman Arutyunyan d7620b29c4 Version bump. 2018-08-30 14:42:15 +03:00
Roman Arutyunyan 4235a19595 Stream: avoid potential infinite loop at preread phase.
Previously the preread phase code ignored NGX_AGAIN value returned from
c->recv() and relied only on c->read->ready.  But this flag is not reliable and
should only be checked for optimization purposes.  For example, when using
SSL, c->read->ready may be set when no input is available.  This can lead to
calling preread handler infinitely in a loop.
2018-08-29 15:56:42 +03:00
Maxim Dounin dd982bcc73 release-1.15.3 tag 2018-08-28 18:36:00 +03:00
Maxim Dounin 684e9efce4 nginx-1.15.3-RELEASE 2018-08-28 18:36:00 +03:00
Maxim Dounin 1da9787693 Updated OpenSSL used for win32 builds. 2018-08-28 15:05:41 +03:00
Vladimir Homutov c3a6f570db Upstream: fixed request chain traversal (ticket #1618).
The problem does not manifest itself currently, because in case of
non-buffered reading, chain link created by u->create_request method
consists of a single element.

Found by PVS-Studio.
2018-08-24 12:19:37 +03:00
Maxim Dounin f2de0e800b Upstream keepalive: keepalive_requests directive.
The directive configures maximum number of requests allowed on
a connection kept in the cache.  Once a connection reaches the number
of requests configured, it is no longer saved to the cache.
The default is 100.

Much like keepalive_requests for client connections, this is mostly
a safeguard to make sure connections are closed periodically and the
memory allocated from the connection pool is freed.
2018-08-10 21:54:46 +03:00
Maxim Dounin 8cdab53533 Upstream keepalive: keepalive_timeout directive.
The directive configures maximum time a connection can be kept in the
cache.  By configuring a time which is smaller than the corresponding
timeout on the backend side one can avoid the race between closing
a connection by the backend and nginx trying to use the same connection
to send a request at the same time.
2018-08-10 21:54:23 +03:00
Maxim Dounin 864bf18325 Upstream keepalive: comment added. 2018-08-10 21:54:17 +03:00
Maxim Dounin d96a4439e2 SSL: fixed build with LibreSSL 2.8.0 (ticket #1605).
LibreSSL 2.8.0 "added const annotations to many existing APIs from OpenSSL,
making interoperability easier for downstream applications".  This includes
the const change in the SSL_CTX_sess_set_get_cb() callback function (see
9dd43f4ef67e), which breaks compilation.

To fix this, added a condition on how we redefine OPENSSL_VERSION_NUMBER
when working with LibreSSL (see 382fc7069e3a).  With LibreSSL 2.8.0,
we now set OPENSSL_VERSION_NUMBER to 0x1010000fL (OpenSSL 1.1.0), so the
appropriate conditions in the code will use "const" as it happens with
OpenSSL 1.1.0 and later versions.
2018-08-10 20:49:06 +03:00
Maxim Konovalov b307fc3cf6 A link to the error_log directive on nginx.org removed.
It makes more harm than good for users and nginx.org
infrastructure.
2018-08-10 14:15:05 +03:00
Maxim Dounin 35fa0a2388 HTTP/2: workaround for clients which fail on table size updates.
There are clients which cannot handle HPACK's dynamic table size updates
as added in 12cadc4669a7 (1.13.6).  Notably, old versions of OkHttp library
are known to fail on it (ticket #1397).

This change makes it possible to work with such clients by only sending
dynamic table size updates in response to SETTINGS_HEADER_TABLE_SIZE.  As
a downside, clients which do not use SETTINGS_HEADER_TABLE_SIZE will
continue to maintain default 4k table.
2018-08-09 20:12:17 +03:00
Maxim Dounin 49ff26bbd4 Skipping spaces in configuration files (ticket #1557).
Previously, a chunk of spaces larger than NGX_CONF_BUFFER (4096 bytes)
resulted in the "too long parameter" error during parsing such a
configuration.  This was because the code only set start and start_line
on non-whitespace characters, and hence adjacent whitespace characters
were preserved when reading additional data from the configuration file.
Fix is to always move start and start_line if the last character was
a space.
2018-08-09 12:15:42 +03:00
Maxim Dounin b1dd3db270 SSL: support for TLSv1.3 early data with BoringSSL.
Early data AKA 0-RTT mode is enabled as long as "ssl_early_data on" is
specified in the configuration (default is off).

The $ssl_early_data variable evaluates to "1" if the SSL handshake
isn't yet completed, and can be used to set the Early-Data header as
per draft-ietf-httpbis-replay-04.
2018-08-07 02:16:07 +03:00
Maxim Dounin e49f6fb71d SSL: enabled TLSv1.3 with BoringSSL.
BoringSSL currently requires SSL_CTX_set_max_proto_version(TLS1_3_VERSION)
to be able to enable TLS 1.3.  This is because by default max protocol
version is set to TLS 1.2, and the SSL_OP_NO_* options are merely used
as a blacklist within the version range specified using the
SSL_CTX_set_min_proto_version() and SSL_CTX_set_max_proto_version()
functions.

With this change, we now call SSL_CTX_set_max_proto_version() with an
explicit maximum version set.  This enables TLS 1.3 with BoringSSL.
As a side effect, this change also limits maximum protocol version to
the newest protocol we know about, TLS 1.3.  This seems to be a good
change, as enabling unknown protocols might have unexpected results.

Additionally, we now explicitly call SSL_CTX_set_min_proto_version()
with 0.  This is expected to help with Debian system-wide default
of MinProtocol set to TLSv1.2, see
http://mailman.nginx.org/pipermail/nginx-ru/2017-October/060411.html.

Note that there is no SSL_CTX_set_min_proto_version macro in BoringSSL,
so we call SSL_CTX_set_min_proto_version() and SSL_CTX_set_max_proto_version()
as long as the TLS1_3_VERSION macro is defined.
2018-08-07 02:15:28 +03:00
Sergey Kandaurov c3bd6d8b4e Dav: removed dead store after 8e7a5de61664.
Found by Clang Static Analyzer.
2018-08-02 13:19:48 +03:00
Maxim Dounin 933ef2effe Dav: changed COPY of a file to preserve access mask.
The behaviour is now in line with COPY of a directory with contents,
which preserves access masks on individual files, as well as the "cp"
command.

Requested by Roman Arutyunyan.
2018-08-01 02:12:21 +03:00
Maxim Dounin 8c2b0c5396 Dav: changed ngx_copy_file() to preserve access and mtime.
This fixes wrong permissions and file time after cross-device MOVE
in the DAV module (ticket #1577).  Broken in 8101d9101ed8 (0.8.9) when
cross-device copying was introduced in ngx_ext_rename_file().

With this change, ngx_copy_file() always calls ngx_set_file_time(),
either with the time provided, or with the time from the original file.
This is considered acceptable given that copying the file is costly anyway,
and optimizing cases when we do not need to preserve time will require
interface changes.
2018-08-01 02:12:11 +03:00
Maxim Dounin 0b3acfc308 Dav: fixed ngx_copy_file() to truncate destination file.
Previously, ngx_open_file(NGX_FILE_CREATE_OR_OPEN) was used, resulting
in destination file being partially rewritten if exists.  Notably,
this affected WebDAV COPY command (ticket #1576).
2018-08-01 02:11:58 +03:00
Sergey Kandaurov 3f5c3dc960 Configure: fixed compiler warnings with "-Wall -Wextra". 2018-07-24 18:46:54 +03:00
Sergey Kandaurov cd3555e298 Version bump. 2018-07-24 18:46:18 +03:00
Maxim Dounin 0aa0999398 release-1.15.2 tag 2018-07-24 16:11:00 +03:00
Maxim Dounin e5685762e5 nginx-1.15.2-RELEASE 2018-07-24 16:10:59 +03:00
Maxim Dounin 93d2cfb648 Fixed NGX_TID_T_FMT format specification for uint64_t.
Previously, "%uA" was used, which corresponds to ngx_atomic_uint_t.
Size of ngx_atomic_uint_t can be easily different from uint64_t,
leading to undefined results.
2018-07-22 04:03:40 +03:00
Sergey Kandaurov 2ceab20da7 Stream ssl_preread: added SSLv2 Client Hello support.
In particular, it was not possible to obtain SSLv2 protocol version.
2018-07-18 18:51:25 +03:00
Ruslan Ermilov 425a296769 Fixed invalid access to location defined as an empty string. 2018-07-17 15:30:43 +03:00
Sergey Kandaurov bc8843e64d SSL: save sessions for upstream peers using a callback function.
In TLSv1.3, NewSessionTicket messages arrive after the handshake and
can come at any time.  Therefore we use a callback to save the session
when we know about it.  This approach works for < TLSv1.3 as well.
The callback function is set once per location on merge phase.

Since SSL_get_session() in BoringSSL returns an unresumable session for
TLSv1.3, peer save_session() methods have been updated as well to use a
session supplied within the callback.  To preserve API, the session is
cached in c->ssl->session.  It is preferably accessed in save_session()
methods by ngx_ssl_get_session() and ngx_ssl_get0_session() wrappers.
2018-07-17 12:53:23 +03:00
Maxim Dounin 0d89e57550 SSL: use of the SSL_OP_NO_RENEGOTIATION option (ticket #1376).
The SSL_OP_NO_RENEGOTIATION option is available in OpenSSL 1.1.0h+ and can
save some CPU cycles on renegotiation attempts.
2018-07-16 17:47:48 +03:00
Maxim Dounin 920d2613ae SSL: fixed SSL_clear_options() usage with OpenSSL 1.1.0+.
In OpenSSL 1.1.0 the SSL_CTRL_CLEAR_OPTIONS macro was removed, so
conditional compilation test on it results in SSL_clear_options()
and SSL_CTX_clear_options() not being used.  Notably, this caused
"ssl_prefer_server_ciphers off" to not work in SNI-based virtual
servers if server preference was switched on in the default server.

It looks like the only possible fix is to test OPENSSL_VERSION_NUMBER
explicitly.
2018-07-16 17:47:20 +03:00
Maxim Dounin 3cd3c48e6b SSL: logging levels of "unsupported protocol", "version too low".
Starting with OpenSSL 1.1.0, SSL_R_UNSUPPORTED_PROTOCOL instead of
SSL_R_UNKNOWN_PROTOCOL is reported when a protocol is disabled via
an SSL_OP_NO_* option.

Additionally, SSL_R_VERSION_TOO_LOW is reported when using MinProtocol
or when seclevel checks (as set by @SECLEVEL=n in the cipher string)
rejects a protocol, and this is what happens with SSLv3 and @SECLEVEL=1,
which is the default.

There is also the SSL_R_VERSION_TOO_HIGH error code, but it looks like
it is not possible to trigger it.
2018-07-16 17:47:18 +03:00
Maxim Dounin 3ca9fa2aa7 Events: added configuration check on the number of connections.
There should be at least one worker connection for each listening socket,
plus an additional connection for channel between worker and master,
or starting worker processes will fail.
2018-07-12 19:50:07 +03:00
Maxim Dounin a098d79ec7 Events: moved sockets cloning to ngx_event_init_conf().
Previously, listenings sockets were not cloned if the worker_processes
directive was specified after "listen ... reuseport".

This also simplifies upcoming configuration check on the number
of worker connections, as it needs to know the number of listening
sockets before cloning.
2018-07-12 19:50:02 +03:00
Roman Arutyunyan 1f8fefa0d0 Stream ssl_preread: $ssl_preread_protocol variable.
The variable keeps the latest SSL protocol version supported by the client.
The variable has the same format as $ssl_protocol.

The version is read from the client_version field of ClientHello.  If the
supported_versions extension is present in the ClientHello, then the version
is set to TLSv1.3.
2018-07-11 17:56:51 +03:00
Ruslan Ermilov 7382a39d4c Allow resetting connections closed by "return 444" (ticket #905).
If reset_timedout_connection is on, TCP connections closed by
"return 444" will be reset instead of a normal close.
2018-07-12 12:50:20 +03:00
Maxim Dounin a90a6b2700 Resolver: retry sending queries on errors (ticket #1511).
Errors when sending UDP datagrams can happen, e.g., when local IP address
changes (see fa0e093b64d7), or an unavailable DNS server on the LAN can cause
send() to fail with EHOSTDOWN on BSD systems.  If this happens during
initial query, retry sending immediately, to a different DNS server when
possible.  If this is not enough, allow normal resend to happen by ignoring
the return code of the second ngx_resolver_send_query() call, much like we
do in ngx_resolver_resend().
2018-07-05 22:21:14 +03:00
Maxim Dounin cfea51df12 SSL: logging level of "https proxy request" errors.
The "http request" and "https proxy request" errors cannot happen
with HTTP due to pre-handshake checks in ngx_http_ssl_handshake(),
but can happen when SSL is used in stream and mail modules.
2018-07-05 20:45:29 +03:00
Maxim Dounin e5442a70d2 Version bump. 2018-07-05 20:44:58 +03:00
Maxim Dounin 3385d4afb4 release-1.15.1 tag 2018-07-03 18:07:44 +03:00
Maxim Dounin eb1e0942e9 nginx-1.15.1-RELEASE 2018-07-03 18:07:43 +03:00
Maxim Dounin 7c914fc876 Upstream: fixed tcp_nopush with gRPC.
With gRPC it is possible that a request sending is blocked due to flow
control.  Moreover, further sending might be only allowed once the
backend sees all the data we've already sent.  With such a backend
it is required to clear the TCP_NOPUSH socket option to make sure all
the data we've sent are actually delivered to the backend.

As such, we now clear TCP_NOPUSH in ngx_http_upstream_send_request()
also on NGX_AGAIN if c->write->ready is set.  This fixes a test (which
waits for all the 64k bytes as per initial window before allowing more
bytes) with sendfile enabled when the body was written to a file
in a different context.
2018-07-02 19:03:04 +03:00
Maxim Dounin 5701a94610 Upstream: fixed unexpected tcp_nopush usage on peer connections.
Now tcp_nopush on peer connections is disabled if it is disabled on
the client connection, similar to how we handle c->sendfile.  Previously,
tcp_nopush was always used on upstream connections, regardless of
the "tcp_nopush" directive.
2018-07-02 19:02:31 +03:00
Maxim Dounin 4e7cd12a3b gRPC: clearing buffers in ngx_http_grpc_get_buf().
We copy input buffers to our buffers, so various flags might be
unexpectedly set in buffers returned by ngx_chain_get_free_buf().

In particular, the b->in_file flag might be set when the body was
written to a file in a different context.  With sendfile enabled this
in turn might result in protocol corruption if such a buffer was reused
for a control frame.

Make sure to clear buffers and set only fields we really need to be set.
2018-07-02 19:02:08 +03:00
Ruslan Ermilov 8384665372 Added FreeBSD support for "listen ... reuseport". 2018-07-02 13:54:33 +03:00
Valentin Bartenev a47bac1f5c MIME: added font/woff2 type (ticket #1243). 2018-06-15 17:29:55 +03:00
Valentin Bartenev 8258e437aa MIME: changed type for woff to font/woff (ticket #1243).
According to RFC 8081 the previously used application/font-woff
type is deprecated.
2018-06-15 17:29:55 +03:00
Vladimir Homutov 650c76378f Upstream: ngx_http_upstream_random module.
The module implements random load-balancing algorithm with optional second
choice.  In the latter case, the best of two servers is chosen, accounting
number of connections and server weight.

Example:

upstream u {
    random [two [least_conn]];

    server 127.0.0.1:8080;
    server 127.0.0.1:8081;
    server 127.0.0.1:8082;
    server 127.0.0.1:8083;
}
2018-06-15 11:46:14 +03:00
Ruslan Ermilov 07acefe528 Upstream: improved peer selection concurrency for hash and ip_hash. 2018-06-14 07:03:50 +03:00
Ruslan Ermilov 08d372a566 Resolver: require name servers. 2018-06-13 22:37:49 +03:00
Ruslan Ermilov 1f5b38eff9 Resolver: allocate resolver from configuration pool.
Before 4a8c9139e579, ngx_resolver_create() didn't use configuration
pool, and allocations were done using malloc().

In 016352c19049, when resolver gained support of several servers,
new allocations were done from the pool.
2018-06-13 22:37:42 +03:00
Maxim Dounin 0553c81ea1 Upstream: disable body cleanup with preserve_output (ticket #1565).
With u->conf->preserve_output set the request body file might be used
after the response header is sent, so avoid cleaning it.  (Normally
this is not a problem as u->conf->preserve_output is only set with
r->request_body_no_buffering, but the request body might be already
written to a file in a different context.)
2018-06-13 15:28:11 +03:00
Ruslan Ermilov ede1748ce2 HTTP/2: use scheme from original request for pushes (closes #1549).
Instead of the connection scheme, use scheme from the original request.
This fixes pushes when SSL is terminated by a proxy server in front of
nginx.
2018-06-07 20:04:22 +03:00
Ruslan Ermilov 26871ff4c3 Added r->schema.
For HTTP/1, it keeps scheme from the absolute form of URI.
For HTTP/2, the :scheme request pseudo-header field value.
2018-06-07 20:01:41 +03:00
Ruslan Ermilov 63a7c015c1 Removed extraneous check while processing request line. 2018-06-07 19:53:43 +03:00
Ruslan Ermilov c8191bf45a HTTP/2: validate client request scheme.
The scheme is validated as per RFC 3986, Section 3.1.
2018-06-07 11:47:10 +03:00
Ruslan Ermilov 1ca7701b33 Allowed digits, '+', '-', and '.' in scheme names as per RFC 3986. 2018-05-24 12:06:35 +03:00
Sergey Kandaurov 03bb0f2cf9 SSL: removed extra prototype. 2018-06-06 13:31:05 +03:00
Maxim Dounin 1ca461e75e Added missing space after ngx_close_socket_n. 2018-06-05 17:41:34 +03:00
Maxim Dounin a088824a29 Version bump. 2018-06-05 17:13:17 +03:00
Maxim Dounin 986c648913 release-1.15.0 tag 2018-06-05 16:47:25 +03:00
Maxim Dounin 5b96c377b9 nginx-1.15.0-RELEASE 2018-06-05 16:47:25 +03:00
Roman Arutyunyan a469072eee Stream: udp streams.
Previously, only one client packet could be processed in a udp stream session
even though multiple response packets were supported.  Now multiple packets
coming from the same client address and port are delivered to the same stream
session.

If it's required to maintain a single stream of data, nginx should be
configured in a way that all packets from a client are delivered to the same
worker.  On Linux and DragonFly BSD the "reuseport" parameter should be
specified for this.  Other systems do not currently provide appropriate
mechanisms.  For these systems a single stream of udp packets is only
guaranteed in single-worker configurations.

The proxy_response directive now specifies how many packets are expected in
response to a single client packet.
2018-06-04 19:50:00 +03:00
Roman Arutyunyan 07270ff0ca Events: moved ngx_recvmsg() to new file src/event/ngx_event_udp.c. 2018-06-01 16:55:49 +03:00
Roman Arutyunyan 0f1051a8f4 Events: get remote addresses before creating udp connection.
Previously, ngx_event_recvmsg() got remote socket addresses after creating
the connection object.  In preparation to handling multiple UDP packets in a
single session, this code was moved up.
2018-06-01 13:12:57 +03:00
Roman Arutyunyan 3660177696 Events: fixed handling zero-length client address.
On Linux recvmsg() syscall may return a zero-length client address when
receiving a datagram from an unbound unix datagram socket.  It is usually
assumed that socket address has at least the sa_family member.  Zero-length
socket address caused buffer over-read in functions which receive socket
address, for example ngx_sock_ntop().  Typically the over-read resulted in
unexpected socket family followed by session close.  Now a fake socket address
is allocated instead of a zero-length client address.
2018-06-01 16:53:02 +03:00
Sergey Kandaurov 6da95a2b3a Leave chain in ngx_chain_add_copy() in consistent state on errors. 2018-06-04 18:47:54 +03:00
Maxim Dounin 95679ba70b Limit req: improved handling of negative times.
Negative times can appear since workers only update time on an event
loop iteration start.  If a worker was blocked for a long time during
an event loop iteration, it is possible that another worker already
updated the time stored in the node.  As such, time since last update
of the node (ms) will be negative.

Previous code used ngx_abs(ms) in the calculations.  That is, negative
times were effectively treated as positive ones.  As a result, it was
not possible to maintain high request rates, where the same node can be
updated multiple times from during an event loop iteration.
In particular, this affected setups with many SSL handshakes, see
http://mailman.nginx.org/pipermail/nginx/2018-May/056291.html.

Fix is to only update the last update time stored in the node if the
new time is larger than previously stored one.  If a future time is
stored in the node, we preserve this time as is.

To prevent breaking things on platforms without monotonic time available
if system time is updated backwards, a safety limit of 60 seconds is
used.  If the time stored in the node is more than 60 seconds in the future,
we assume that the time was changed backwards and update lr->last
to the current time.
2018-05-30 15:40:34 +03:00
Ruslan Ermilov bab6840be9 Core: fixed comment about ngx_current_msec after 81fae70d6cb8.
The value is no longer guaranteed to be based on milliseconds
elapsed since Epoch.
2018-05-29 16:15:19 +03:00
Ruslan Ermilov ee7071e7e7 Win32: fixed comment in ngx_gettimeofday() calculations. 2018-05-29 11:47:32 +03:00
Maxim Dounin 85d0522248 Removed glibc crypt_r() bug workaround (ticket #1469).
The bug in question was fixed in glibc 2.3.2 and is no longer expected
to manifest itself on real servers.  On the other hand, the workaround
causes compilation problems on various systems.  Previously, we've
already fixed the code to compile with musl libc (fd6fd02f6a4d), and
now it is broken on Fedora 28 where glibc's crypt library was replaced
by libxcrypt.  So the workaround was removed.
2018-05-23 16:38:16 +03:00
Vladimir Homutov 67265e5810 Syslog: install cleanup handler only once.
If a socket was re-opened due to an error (02c2352d5b01 and fa0e093b64d7),
additional cleanup handler was installed each time.
2018-05-14 22:50:57 +03:00
Ruslan Ermilov 0248f5ec43 Resolver: close UDP socket on error or incomplete send. 2018-05-23 10:41:38 +03:00
Ruslan Ermilov 6d8ea3e577 Resolver: style. 2018-05-23 10:41:29 +03:00
Maxim Dounin b160f96ec2 Core: silenced getsockopt(TCP_FASTOPEN) messages on FreeBSD.
FreeBSD returns EINVAL when getsockopt(TCP_FASTOPEN) is called on a unix
domain socket, resulting in "getsockopt(TCP_FASTOPEN) ... failed" messages
during binary upgrade when unix domain listen sockets are present in
the configuration.  Added EINVAL to the list of ignored error codes.
2018-05-21 23:11:27 +03:00
Ruslan Ermilov 9841e24637 Configure: fixed clang version detection (closes #1539).
While 325b3042edd6 fixed it on MINIX, it broke it on systems
that output the word "version" on several lines with "cc -v".
The fix is to only consider "clang version" or "LLVM version"
as clang version, but this time only using sed(1).
2018-04-24 14:04:59 +03:00
Vladimir Homutov 2c82d95706 Syslog: re-open syslog udp socket on send error (ticket #1477).
Previously, only unix domain sockets were reopened to tolerate cases when
local syslog server was restarted.  It makes sense to treat other cases
(for example, local IP address changes) similarly.
2018-05-08 19:35:56 +03:00
Sergey Kandaurov 9cfab9a327 Silenced -Wcast-function-type warnings (closes #1546).
Cast to intermediate "void *" to lose compiler knowledge about the original
type and pass the warning.  This is not a real fix but rather a workaround.

Found by gcc8.
2018-05-07 09:54:37 +00:00
Ruslan Ermilov 2282376037 SSL: deprecated the "ssl" directive. 2018-04-25 14:57:24 +03:00
Maxim Dounin 294e16c34a SSL: detect "listen ... ssl" without certificates (ticket #178).
In mail and stream modules, no certificate provided is a fatal condition,
much like with the "ssl" and "starttls" directives.

In http, "listen ... ssl" can be used in a non-default server without
certificates as long as there is a certificate in the default one, so
missing certificate is only fatal for default servers.
2018-04-24 15:29:01 +03:00
Maxim Dounin 7b197ba357 Mail: fixed error message about missing ssl_certificate_key.
In 51e1f047d15d, the "ssl" directive name was incorrectly hardcoded
in the error message shown when there are some SSL keys defined, but
not for all certificates.  Right approach is to use the "mode" variable,
which can be either "ssl" or "starttls".
2018-04-24 15:28:58 +03:00
Maxim Dounin 2cef238503 Cache: fixed cache valid slot to reject incorrect statuses.
Previously, result of ngx_atoi() was assigned to an ngx_uint_t variable,
and errors reported by ngx_atoi() became positive, so the following check
in "status < 100" failed to catch them.  This resulted in the configurations
like "proxy_cache_valid 2xx 30s" being accepted as correct, while they
in fact do nothing.  Changing type to ngx_int_t fixes this, and such
configurations are now properly rejected.
2018-04-18 16:11:41 +03:00
Maxim Dounin 4470deb563 Version bump. 2018-04-18 16:09:08 +03:00
Maxim Dounin 5cfc5a21a3 release-1.13.12 tag 2018-04-10 17:11:10 +03:00
Maxim Dounin 505720540f nginx-1.13.12-RELEASE 2018-04-10 17:11:09 +03:00
Maxim Dounin b563b1daab Upstream: fixed u->conf->preserve_output (ticket #1519).
Previously, ngx_http_upstream_process_header() might be called after
we've finished reading response headers and switched to a different read
event handler, leading to errors with gRPC proxying.  Additionally,
the u->conf->read_timeout timer might be re-armed during reading response
headers (while this is expected to be a single timeout on reading
the whole response header).
2018-04-05 16:56:12 +03:00
Maxim Dounin 88cc70e68d Version bump. 2018-04-05 16:53:27 +03:00
Maxim Dounin b20d510105 release-1.13.11 tag 2018-04-03 17:38:10 +03:00
Maxim Dounin b5f69b937e nginx-1.13.11-RELEASE 2018-04-03 17:38:09 +03:00
Maxim Dounin cbceaec9f8 Updated OpenSSL and PCRE used for win32 builds. 2018-04-03 03:54:09 +03:00
Maxim Dounin 163f863302 Upstream: fixed ngx_http_upstream_test_next() conditions.
Previously, ngx_http_upstream_test_next() used an outdated condition on
whether it will be possible to switch to a different server or not.  It
did not take into account restrictions on non-idempotent requests, requests
with non-buffered request body, and the next upstream timeout.

For such requests, switching to the next upstream server was rejected
later in ngx_http_upstream_next(), resulting in nginx own error page
being returned instead of the original upstream response.
2018-04-03 02:43:18 +03:00
Vladimir Homutov 48ef470957 Core: fixed build, broken by 63e91f263a49.
Both Solaris and Windows define "s_addr" as a macro.
2018-04-02 20:38:43 +03:00
Ruslan Ermilov 2db26a4890 Core: revised the PROXY protocol v2 code.
- use normal prefixes for types and macros
- removed some macros and types
- revised debug messages
- removed useless check of ngx_sock_ntop() returning 0
- removed special processing of AF_UNSPEC
2018-04-02 18:40:04 +03:00
Vladimir Homutov bf17359a44 Core: style. 2018-03-27 18:39:38 +03:00
Vladimir Homutov 1fa9f762ab Core: added processing of version 2 of the PROXY protocol.
The protocol used on inbound connection is auto-detected and corresponding
parser is used to extract passed addresses.  TLV parameters are ignored.

The maximum supported size of PROXY protocol header is 107 bytes
(similar to version 1).
2018-03-22 15:55:28 +03:00
Roman Arutyunyan 475808cf9a Stream: set action before each recv/send while proxying.
Now it's clear from log error message if the error occurred on client or
upstream side.
2018-03-22 18:43:49 +03:00
Maxim Dounin 24b2d25cba gRPC: fixed possible sign extension of error and setting_value.
All cases are harmless and should not happen on valid values, though can
result in bad values being shown incorrectly in logs.

Found by Coverity (CID 1430311, 1430312, 1430313).
2018-03-22 19:26:25 +03:00
Ruslan Ermilov 60c24eef64 Improved code readability (closes #1512). 2018-03-22 18:13:33 +03:00
Maxim Dounin b051c9ec68 Configure: restored "no-threads" in OpenSSL builds.
This was previously used, but was incorrectly removed in 83d54192e97b
while removing old threads remnants.  Instead of using it conditionally
when threads are not used, we now set in unconditionally, as even with
thread pools enabled we never call OpenSSL functions in threads.

This fixes resulting binary when using --with-openssl with OpenSSL 1.1.0+
and without -lpthread linked (notably on FreeBSD without PCRE).
2018-03-22 15:56:07 +03:00
Maxim Dounin 519c1a1a9f Configure: fixed static compilation with OpenSSL 1.1.1.
OpenSSL now uses pthread_atfork(), and this requires -lpthread on Linux
to compile.  Introduced NGX_LIBPTHREAD to add it as appropriate, similar
to existing NGX_LIBDL.
2018-03-22 15:55:57 +03:00
Maxim Dounin ebb90893f9 Version bump. 2018-03-22 15:55:52 +03:00
Maxim Dounin 89c328c616 release-1.13.10 tag 2018-03-20 18:58:30 +03:00
Maxim Dounin 9affcc7951 nginx-1.13.10-RELEASE 2018-03-20 18:58:30 +03:00
Sergey Kandaurov cfddac55a6 gRPC: fixed missing state save in frame header parsing.
Previously, frame state wasn't saved if HEADERS frame payload
that begins with header fragment was not received at once.
2018-03-20 15:58:11 +03:00
Ruslan Ermilov ffa9aaf302 HTTP/2: improved frame info debugging. 2018-03-19 21:32:15 +03:00
Sergey Kandaurov 7eeb77c1c1 gRPC: fixed parsing response headers split on CONTINUATION frames. 2018-03-19 16:42:56 +03:00
Ruslan Ermilov e86caf91a4 Fixed checking ngx_tcp_push() and ngx_tcp_nopush() return values.
No functional changes.
2018-03-19 16:28:23 +03:00
Ruslan Ermilov 31dce1600a Upstream: fixed comments after 13f8dec720b5.
The fields "uri", "location", and "url" from ngx_http_upstream_conf_t
moved to ngx_http_proxy_loc_conf_t and ngx_http_proxy_vars_t, reflect
this change in create_loc_conf comments.
2018-03-19 16:22:09 +03:00
Sergey Kandaurov 46a35176bf Configure: added gRPC module help message. 2018-03-19 12:41:36 +03:00
Gena Makhomed 34d1fdec57 Contrib: vim syntax, update core and 3rd party module directives. 2018-03-18 11:11:14 +02:00
Maxim Dounin 11ed8de94e gRPC: special handling of "trailer only" responses.
The gRPC protocol makes a distinction between HEADERS frame with
the END_STREAM flag set, and a HEADERS frame followed by an empty
DATA frame with the END_STREAM flag.  The latter is not permitted,
and results in errors not being propagated through nginx.  Instead,
gRPC clients complain that "server closed the stream without sending
trailers" (seen in grpc-go) or "13: Received RST_STREAM with error
code 2" (seen in grpc-c).

To fix this, nginx now returns HEADERS with the END_STREAM flag if
the response length is known to be 0, and we are not expecting
any trailer headers to be added.  And the response length is
explicitly set to 0 in the gRPC proxy if we see initial HEADERS frame
with the END_STREAM flag set.
2018-03-17 23:04:26 +03:00
Maxim Dounin 78ab3cd8dc gRPC: special handling of the TE request header.
According to the gRPC protocol specification, the "TE" header is used
to detect incompatible proxies, and at least grpc-c server rejects
requests without "TE: trailers".

To preserve the logic, we have to pass "TE: trailers" to the backend if
and only if the original request contains "trailers" in the "TE" header.
Note that no other TE values are allowed in HTTP/2, so we have to remove
anything else.
2018-03-17 23:04:25 +03:00
Maxim Dounin 5a9c426ddb The gRPC proxy module.
The module allows passing requests to upstream gRPC servers.
The module is built by default as long as HTTP/2 support is compiled in.
Example configuration:

    grpc_pass 127.0.0.1:9000;

Alternatively, the "grpc://" scheme can be used:

    grpc_pass grpc://127.0.0.1:9000;

Keepalive support is available via the upstream keepalive module.  Note
that keepalive connections won't currently work with grpc-go as it fails
to handle SETTINGS_HEADER_TABLE_SIZE.

To use with SSL:

    grpc_pass grpcs://127.0.0.1:9000;

SSL connections use ALPN "h2" when available.  At least grpc-go works fine
without ALPN, so if ALPN is not available we just establish a connection
without it.

Tested with grpc-c++ and grpc-go.
2018-03-17 23:04:24 +03:00
Maxim Dounin 90b6ad4e38 Upstream: u->conf->preserve_output flag.
The flag can be used to continue sending request body even after we've
got a response from the backend.  In particular, this is needed for gRPC
proxying of bidirectional streaming RPCs, and also to send control frames
in other forms of RPCs.
2018-03-17 23:04:23 +03:00
Maxim Dounin c33d109582 Upstream: u->request_body_blocked flag.
The flag indicates whether last ngx_output_chain() returned NGX_AGAIN
or not.  If the flag is set, we arm the u->conf->send_timeout timer.
The flag complements c->write->ready test, and allows to stop sending
the request body in an output filter due to protocol-specific flow
control.
2018-03-17 23:04:22 +03:00
Maxim Dounin e680ffc21e Upstream: trailers support, u->conf->pass_trailers flag.
Basic trailer headers support allows one to access response trailers
via the $upstream_trailer_* variables.

Additionally, the u->conf->pass_trailers flag was introduced.  When the
flag is set, trailer headers from the upstream response are passed to
the client.  Like normal headers, trailer headers will be hidden
if present in u->conf->hide_headers_hash.
2018-03-17 23:04:21 +03:00
Maxim Dounin 5863caea8e HTTP/2: externalized various constants and interfaces. 2018-03-17 23:04:20 +03:00
Roman Arutyunyan 7933a1fe11 Style. 2018-03-12 18:38:53 +03:00
Roman Arutyunyan 0dba07d385 Stream ssl_preread: $ssl_preread_alpn_protocols variable.
The variable keeps a comma-separated list of protocol names from ALPN TLS
extension defined by RFC 7301.
2018-03-12 16:03:08 +03:00
Ruslan Ermilov 6790c6c775 Improved code readablity.
No functional changes.
2018-03-07 18:28:12 +03:00
Maxim Dounin 6acd29502d HTTP/2: unknown frames now logged at info level. 2018-03-05 21:35:13 +03:00
Maxim Dounin 40e0220725 Style. 2018-03-05 21:35:08 +03:00
Vladimir Homutov 0815799869 Access log: support for disabling escaping (ticket #1450).
Based on patches by Johannes Baiter <johannes.baiter@bsb-muenchen.de>
and Calin Don.
2018-03-01 11:42:55 +03:00
Maxim Dounin a515dc3fe4 Core: ngx_current_msec now uses monotonic time if available.
When clock_gettime(CLOCK_MONOTONIC) (or faster variants, _FAST on FreeBSD,
and _COARSE on Linux) is available, we now use it for ngx_current_msec.
This should improve handling of timers if system time changes (ticket #189).
2018-03-01 20:25:50 +03:00
Roman Arutyunyan 1d0b83a9e3 Postpone filter: prevented uninitialized r->out.
The r->out chain link could be left uninitialized in case of error.
A segfault could happen if the subrequest handler accessed it.
The issue was introduced in commit 20f139e9ffa8.
2018-03-01 18:38:39 +03:00
Roman Arutyunyan 7d74b74e7f Generic subrequests in memory.
Previously, only the upstream response body could be accessed with the
NGX_HTTP_SUBREQUEST_IN_MEMORY feature.  Now any response body from a subrequest
can be saved in a memory buffer.  It is available as a single buffer in r->out
and the buffer size is configured by the subrequest_output_buffer_size
directive.

Upstream, proxy and fastcgi code used to handle the old-style feature is
removed.
2018-02-28 16:56:58 +03:00
Vladimir Homutov 463840b6da Modules compatibility: additional upstream metrics. 2018-02-22 17:25:43 +03:00
Vadim Filimonov e867cc4b60 Auth basic: prevent null character in error log (ticket #1494). 2018-02-26 16:52:20 +02:00
Roman Arutyunyan 8561f368ee Generate error for unsupported IPv6 transparent proxy.
On some platforms (for example, Linux with glibc 2.12-2.25) IPv4 transparent
proxying is available, but IPv6 transparent proxying is not.  The entire feature
is enabled in this case and NGX_HAVE_TRANSPARENT_PROXY macro is set to 1.
Previously, an attempt to enable transparency for an IPv6 socket was silently
ignored in this case and was usually followed by a bind(2) EADDRNOTAVAIL error
(ticket #1487).  Now the error is generated for unavailable IPv6 transparent
proxy.
2018-02-22 13:16:21 +03:00
Ruslan Ermilov 58dc11c1b3 HTTP/2: style.
Unified the style of validity checks in ngx_http_v2_validate_header().
2018-02-22 12:42:29 +03:00
Sergey Kandaurov c29b47dafc Geo: fixed indentation. 2018-02-21 17:26:00 +03:00
Ruslan Ermilov 8ac1bc56a3 Geo: optimized configuration parser.
If the geo block parser has failed, doing more things is pointless.
2018-02-21 15:50:43 +03:00
Ruslan Ermilov 5a66446f47 Geo: fixed memory allocation error handling (closes #1482).
If during configuration parsing of the geo directive the memory
allocation has failed, pool used to parse configuration inside
the block, and sometimes the temporary pool were not destroyed.
2018-02-21 15:50:42 +03:00
Ruslan Ermilov 04a8100262 Version bump. 2018-02-21 15:50:35 +03:00
Maxim Dounin 4a144d23fc release-1.13.9 tag 2018-02-20 17:08:49 +03:00
Maxim Dounin d526b2bd84 nginx-1.13.9-RELEASE 2018-02-20 17:08:48 +03:00
Maxim Dounin ed3b83086d HTTP/2: precalculate hash for "Cookie".
There is no need to calculate hashes of static strings at runtime.  The
ngx_hash() macro can be used to do it during compilation instead, similarly
to how it is done in ngx_http_proxy_module.c for "Server" and "Date" headers.
2018-02-15 19:06:22 +03:00
Ruslan Ermilov b09d3ba7c8 HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.
In particular, if a stream object allocation failed, and a client sent
the PRIORITY frame for this stream, ngx_http_v2_set_dependency() could
dereference a null pointer while trying to re-parent a dependency node.
2018-02-15 17:51:37 +03:00
Ruslan Ermilov 7976f31675 HTTP/2: push additional request headers (closes #1478).
The Accept-Encoding, Accept-Language, and User-Agent header fields
are now copied from the original request to pushed requests.
2018-02-15 17:51:32 +03:00
Ruslan Ermilov d712b1c9d5 Expose more headers with NGX_HTTP_HEADERS. 2018-02-15 17:51:26 +03:00
Vladimir Homutov 5aa53fee05 Core: added a stub for additional zone configuration. 2018-02-15 16:08:05 +03:00
Sergey Kandaurov 049126725c HTTP/2: style. 2018-02-15 02:34:16 +03:00
Ruslan Ermilov 4b6fe1255a HTTP/2: fixed null pointer dereference with server push.
r->headers_in.host can be NULL in ngx_http_v2_push_resource().

This happens when a request is terminated with 400 before the :authority
or Host header is parsed, and either pushing is enabled on the server{}
level or error_page 400 redirects to a location with pushes configured.

Found by Coverity (CID 1429156).
2018-02-09 23:20:08 +03:00
Ruslan Ermilov df1c7e7f79 HTTP/2: fixed build with -Werror=unused-but-set-variable. 2018-02-08 12:11:30 +03:00
Ruslan Ermilov 3b0785ea4b HTTP/2: server push.
Resources to be pushed are configured with the "http2_push" directive.

Also, preload links from the Link response headers, as described in
https://www.w3.org/TR/preload/#server-push-http-2, can be pushed, if
enabled with the "http2_push_preload" directive.

Only relative URIs with absolute paths can be pushed.

The number of concurrent pushes is normally limited by a client, but
cannot exceed a hard limit set by the "http2_max_concurrent_pushes"
directive.
2018-02-08 09:55:03 +03:00
Ruslan Ermilov 2d381f5efb HTTP/2: changed prototypes of request pseudo-headers parsers.
No functional changes.
2018-02-08 09:54:49 +03:00
Ruslan Ermilov bf3f89c060 Basic support of the Link response header. 2018-02-08 09:54:18 +03:00
Roman Arutyunyan 553ade2b42 Dav: added error logging.
Previously, when request body was not available or was previously read in
memory rather than a file, client received HTTP 500 error, but no explanation
was logged in error log.  This could happen, for example, if request body was
read or discarded prior to error_page redirect, or if mirroring was enabled
along with dav.
2018-02-07 16:44:29 +03:00
Sergey Kandaurov bf7b95d475 HTTP/2: removed unused field from ngx_http_v2_stream_t. 2018-02-06 20:02:59 +03:00
Gena Makhomed 5130add5b4 Contrib: vim syntax, update 3rd party module directives.
Add new directives for 3rd party modules.
2018-02-01 11:15:14 +02:00
Gena Makhomed 004ab5c3a6 Contrib: vim syntax, update core module directives.
"match" is block directive, "upstream_conf" is deprecated
by patch http://hg.nginx.org/nginx.org/rev/27c53e1cb4b6
2018-02-01 11:09:35 +02:00
Ruslan Ermilov 68034fe085 Upstream: removed X-Powered-By from the list of special headers.
After 1e720b0be7ec, it's neither specially processed nor copied
when redirecting with X-Accel-Redirect.
2018-01-30 22:23:58 +03:00
Sergey Kandaurov 4cc53b092e SSL: using default server context in session remove (closes #1464).
This fixes segfault in configurations with multiple virtual servers sharing
the same port, where a non-default virtual server block misses certificate.
2018-01-30 17:46:31 +03:00
Ruslan Ermilov 590dad7177 HTTP/2: finalize request as bad if parsing of pseudo-headers fails.
This is in line when the required pseudo-headers are missing, and
avoids spurious zero statuses in access.log.
2018-01-30 14:44:31 +03:00
Ruslan Ermilov 41951dcad4 HTTP/2: more style, comments, and debugging. 2018-01-29 16:06:33 +03:00
Ruslan Ermilov ab486d3427 HTTP/2: handle duplicate INITIAL_WINDOW_SIZE settings. 2018-01-29 15:54:36 +03:00
Ruslan Ermilov 5993c56ca2 Fixed --test-build-eventport on macOS 10.12 and later.
In macOS 10.12, CLOCK_REALTIME and clockid_t were added, but not timer_t.
2018-01-16 13:52:03 +03:00
Maxim Dounin 5106306a17 Upstream: fixed "header already sent" alerts on backend errors.
Following ad3f342f14ba046c (1.9.13), it is possible that a request where
header was already sent will be finalized with NGX_HTTP_BAD_GATEWAY,
triggering an attempt to return additional error response and the
"header already sent" alert as a result.

In particular, it is trivial to reproduce the problem with a HEAD request
and caching enabled.  With caching enabled nginx will change HEAD to GET
and will set u->pipe->downstream_error to suppress sending the response
body to the client.  When a backend-related error occurs (for example,
proxy_read_timeout expires), ngx_http_finalize_upstream_request() will
be called with NGX_HTTP_BAD_GATEWAY.  After ad3f342f14ba046c this will
result in ngx_http_finalize_request(NGX_HTTP_BAD_GATEWAY).

Fix is to move u->pipe->downstream_error handling to a later point,
where all special response codes are changed to NGX_ERROR.

Reported by Jan Prachar,
http://mailman.nginx.org/pipermail/nginx-devel/2018-January/010737.html.
2018-01-11 21:43:49 +03:00
Maxim Dounin 1136600043 Year 2018. 2018-01-11 21:43:24 +03:00
Gena Makhomed e27cda4047 Contrib: vim syntax, update core module directives.
Removed non-existent directives and directive redefinitions.
2017-12-28 12:01:05 +02:00
Gena Makhomed 9330f43a72 Contrib: vim syntax, update 3rd party module directives.
3rd party modules list synchronized with FreeBSD nginx-devel port.
2017-12-28 11:49:44 +02:00
Maxim Dounin c75b2f7602 Version bump. 2017-12-30 00:15:07 +03:00
Maxim Dounin 926b176e7b release-1.13.8 tag 2017-12-26 19:01:12 +03:00
Maxim Dounin cc9cd15ab2 nginx-1.13.8-RELEASE 2017-12-26 19:01:11 +03:00
Maxim Dounin d0f85a77ac Updated OpenSSL used for win32 builds. 2017-12-26 17:48:49 +03:00
Gena Makhomed e2a1e9d99f Contrib: vim syntax, listen options. 2017-12-25 18:30:01 +02:00
Gena Makhomed baa0fb6ce9 Contrib: vim syntax, update core module directives. 2017-12-25 17:57:01 +02:00
Maxim Dounin 3d2b7b25a8 Contrib: updated vim syntax rules for variables.
Non-quoted parameters are allowed to contain variables in curly brackets
(see d91a8c4ac6bb), so vim syntax rules were adjusted accordingly.
2017-12-25 19:41:00 +03:00
Roman Arutyunyan 77111f1bfc Allowed configuration token to start with a variable.
Specifically, it is now allowed to start with a variable expression with braces:
${name}.  The opening curly bracket in such a token was previously considered
the start of a new block.  Variables located anywhere else in a token worked
fine: foo${name}.
2017-12-21 13:29:40 +03:00
Roman Arutyunyan 6ebe5e7ed4 Fixed capabilities version.
Previously, capset(2) was called with the 64-bit capabilities version
_LINUX_CAPABILITY_VERSION_3.  With this version Linux kernel expected two
copies of struct __user_cap_data_struct, while only one was submitted.  As a
result, random stack memory was accessed and random capabilities were requested
by the worker.  This sometimes caused capset() errors.  Now the 32-bit version
_LINUX_CAPABILITY_VERSION_1 is used instead.  This is OK since CAP_NET_RAW is
a 32-bit capability (CAP_NET_RAW = 13).
2017-12-19 19:00:27 +03:00
Roman Arutyunyan ac2d9a2413 Improved the capabilities feature detection.
Previously included file sys/capability.h mentioned in capset(2) man page,
belongs to the libcap-dev package, which may not be installed on some Linux
systems when compiling nginx.  This prevented the capabilities feature from
being detected and compiled on that systems.

Now linux/capability.h system header is included instead.  Since capset()
declaration is located in sys/capability.h, now capset() syscall is defined
explicitly in code using the SYS_capset constant, similarly to other
Linux-specific features in nginx.
2017-12-18 21:09:39 +03:00
Roman Arutyunyan 695a8267c9 Retain CAP_NET_RAW capability for transparent proxying.
The capability is retained automatically in unprivileged worker processes after
changing UID if transparent proxying is enabled at least once in nginx
configuration.

The feature is only available in Linux.
2017-12-13 20:40:53 +03:00
Debayan Ghosh c4fe79eb6e Use sysconf to determine cacheline size at runtime.
Determine cacheline size at runtime if supported
using sysconf(_SC_LEVEL1_DCACHE_LINESIZE). In case not supported,
fallback to compile time defaults.
2017-12-11 16:28:11 +00:00
Debayan Ghosh f91a2640b9 Configure: set default cacheline size to 64 for aarch64 platforms. 2017-12-11 15:05:35 +00:00
Maxim Dounin fdeb813124 Configure: fixed SO_BINDANY comment. 2017-12-07 17:09:36 +03:00
Maxim Dounin 51c6a8a90f Configure: moved IP_BIND_ADDRESS_NO_PORT test.
In 2c7b488a61fb, IP_BIND_ADDRESS_NO_PORT test was accidentally placed
between SO_BINDANY, IP_TRANSPARENT, and IP_BINDANY tests.  Moved it after
these tests.
2017-12-07 17:09:33 +03:00
Roman Arutyunyan a1e8720122 Proxy: escape explicit space in URI in default cache key.
If the flag space_in_uri is set, the URI in HTTP upstream request is escaped to
convert space to %20.  However this flag is not checked while creating the
default cache key.  This leads to different cache keys for requests
'/foo bar' and '/foo%20bar', while the upstream requests are identical.

Additionally, the change fixes background cache updates when the client URI
contains unescaped space.  Default cache key in a subrequest is always based on
escaped URI, while the main request may not escape it.  As a result, background
cache update subrequest may update a different cache entry.
2017-11-20 20:50:35 +03:00
Roman Arutyunyan 9d9c9ef199 Inherit valid_unparsed_uri in cloned subrequests (ticket #1430).
Inheriting this flag will make the cloned subrequest behave consistently with
the parent.  Specifically, the upstream HTTP request and cache key created by
the proxy module may depend directly on unparsed_uri if valid_unparsed_uri flag
is set.  Previously, the flag was zero for cloned requests, which could make
background update proxy a request different than its parent and cache the result
with a different key.  For example, if client URI contained the escaped slash
character %2F, it was used as is by the proxy module in the main request, but
was unescaped in the subrequests.

Similar problems exist in the slice module.
2017-11-20 21:11:19 +03:00
Roman Arutyunyan bfbe9b103c Proxy: simplified conditions of using unparsed uri.
Previously, the unparsed uri was explicitly allowed to be used only by the main
request.  However the valid_unparsed_uri flag is nonzero only in the main
request, which makes the main request check pointless.
2017-11-20 13:47:17 +03:00
Patryk Lesiewicz ea5d2d520d Upstream: flush low-level buffers on write retry.
If the data to write is bigger than what the socket can send, and the
reminder is smaller than NGX_SSL_BUFSIZE, then SSL_write() fails with
SSL_ERROR_WANT_WRITE. The reminder of payload however is successfully
copied to the low-level buffer and all the output chain buffers are
flushed. This means that retry logic doesn't work because
ngx_http_upstream_process_non_buffered_request() checks only if there's
anything in the output chain buffers and ignores the fact that something
may be buffered in low-level parts of the stack.

Signed-off-by: Patryk Lesiewicz <patryk@google.com>
2017-12-01 15:59:14 -08:00
Roman Arutyunyan d5a87e3394 Upstream keepalive: clean read delayed flag in stored connections.
If a connection with the read delayed flag set was stored in the keepalive
cache, and after picking it from the cache a read timer was set on that
connection, this timer was considered a delay timer rather than a socket read
event timer as expected.  The latter timeout is usually much longer than the
former, which caused a significant delay in request processing.

The issue manifested itself with proxy_limit_rate and upstream keepalive
enabled and exists since 973ee2276300 (1.7.7) when proxy_limit_rate was
introduced.
2017-11-28 14:00:00 +03:00
Maxim Dounin 3cdd70d9f5 Autoindex: discard request body (ticket #1439). 2017-12-04 17:30:02 +03:00
Sergey Kandaurov 18fdb9ae02 Removed unused FreeBSD-specific definitions in ngx_posix_config.h. 2017-11-28 13:09:54 +03:00
Ruslan Ermilov 3066ce7eec Fixed "changing binary" when reaper is not init.
On some systems, it's possible that reaper of orphaned processes is
set to something other than "init" process.  On such systems, the
changing binary procedure did not work.

The fix is to check if PPID has changed, instead of assuming it's
always 1 for orphaned processes.
2017-11-28 12:00:24 +03:00
Maxim Dounin 0172d71f96 Configure: fixed clang detection on MINIX.
As per POSIX, basic regular expressions have no alternations, and the
interpretation of the "\|" construct is undefined.  At least on MINIX
and Solaris grep interprets "\|" as literal "|", and not as an alternation
as GNU grep does.  Removed such constructs introduced in f1daa0356a1d.
This fixes clang detection on MINIX.
2017-11-23 16:33:40 +03:00
Maxim Dounin beb5e7c920 Version bump. 2017-11-23 16:32:58 +03:00
Maxim Dounin c2473f309b release-1.13.7 tag 2017-11-21 18:09:44 +03:00
Maxim Dounin b7c75ed7a7 nginx-1.13.7-RELEASE 2017-11-21 18:09:43 +03:00
Maxim Dounin c8b0d45eeb Updated OpenSSL used for win32 builds. 2017-11-21 17:32:12 +03:00
Maxim Dounin edc9f594a8 Fixed worker_shutdown_timeout in various cases.
The ngx_http_upstream_process_upgraded() did not handle c->close request,
and upgraded connections do not use the write filter.  As a result,
worker_shutdown_timeout did not affect upgraded connections (ticket #1419).
Fix is to handle c->close in the ngx_http_request_handler() function, thus
covering most of the possible cases in http handling.

Additionally, mail proxying did not handle neither c->close nor c->error,
and thus worker_shutdown_timeout did not work for mail connections.  Fix is
to add c->close handling to ngx_mail_proxy_handler().

Also, added explicit handling of c->close to stream proxy,
ngx_stream_proxy_process_connection().  This improves worker_shutdown_timeout
handling in stream, it will no longer wait for some data being transferred
in a connection before closing it, and will also provide appropriate
logging at the "info" level.
2017-11-20 16:31:07 +03:00
Maxim Dounin d0d1354da3 Gzip: support for a zlib variant from Intel.
A zlib variant from Intel as available from https://github.com/jtkukunas/zlib
uses 64K hash instead of scaling it from the specified memory level, and
also uses 16-byte padding in one of the window-sized memory buffers, and can
force window bits to 13 if compression level is set to 1 and appropriate
compile options are used.  As a result, nginx complained with "gzip filter
failed to use preallocated memory" alerts.

This change improves deflate_state allocation detection by testing that
items is 1 (deflate_state is the only allocation where items is 1).
Additionally, on first failure to use preallocated memory we now assume
that we are working with the Intel's modified zlib, and switch to using
appropriate preallocations.  If this does not help, we complain with the
usual alerts.

Previous version of this patch was published at
http://mailman.nginx.org/pipermail/nginx/2014-July/044568.html.
The zlib variant in question is used by default in ClearLinux from Intel,
see http://mailman.nginx.org/pipermail/nginx-ru/2017-October/060421.html,
http://mailman.nginx.org/pipermail/nginx-ru/2017-November/060544.html.
2017-11-18 04:03:27 +03:00
Ruslan Ermilov a500dbafed Xslt: fixed parameters parsing (ticket #1416).
If parameters were specified in xslt_stylesheet without variables,
any request except the first would cause an internal server error.
2017-11-16 13:20:47 +03:00
hucongcong 8cb1404c8c SSI: fixed type. 2017-10-27 00:30:38 +08:00
Maxim Dounin 821488fac9 FastCGI: adjust buffer position when parsing incomplete records.
Previously, nginx failed to move buffer position when parsing an incomplete
record header, and due to this wasn't be able to continue parsing once
remaining bytes of the record header were received.

This can affect response header parsing, potentially generating spurious errors
like "upstream sent unexpected FastCGI request id high byte: 1 while reading
response header from upstream".  While this is very unlikely, since usually
record headers are written in a single buffer, this still can happen in real
life, for example, if a record header will be split across two TCP packets
and the second packet will be delayed.

This does not affect non-buffered response body proxying, due to "buf->pos =
buf->last;" at the start of the ngx_http_fastcgi_non_buffered_filter()
function.  Also this does not affect buffered response body proxying, as
each input buffer is only passed to the filter once.
2017-11-09 15:35:20 +03:00
Maxim Dounin 4499b86e92 Core: free shared memory zones only after reconfiguration.
This is what usually happens for zones no longer used in the new
configuration, but zones where size or tag were changed were freed
when creating new memory zones.  If reconfiguration failed (for
example, due to a conflicting listening socket), this resulted in a
segmentation fault in the master process.

Reported by Zhihua Cao,
http://mailman.nginx.org/pipermail/nginx-devel/2017-October/010536.html.
2017-10-17 19:52:16 +03:00
Sergey Kandaurov 8495a85ae8 Postpone filter: handled ngx_http_postpone_filter_add() failures.
In particular, if ngx_http_postpone_filter_add() fails in ngx_chain_add_copy(),
the output chain of the postponed request was left in an invalid state.
2017-10-16 13:13:25 +03:00
Ruslan Ermilov bcd3e0b52a Fixed type of ngx_conf_t.handler_conf.
The type should have been changed in c9b243802a17 along with
changing ngx_conf_handler_pt.
2017-10-13 00:32:26 +03:00
Alessandro Ghedini f20dd563be SSL: include <openssl/hmac.h>.
This header carries the definition of HMAC_Init_ex(). In OpenSSL this
header is included by <openssl/ssl.h>, but it's not so in BoringSSL.

It's probably a good idea to explicitly include this header anyway,
regardless of whether it's included by other headers or not.
2017-10-11 15:43:50 -07:00
Roman Arutyunyan 01e200c434 Upstream: disabled upgrading in subrequests.
Upgrading an upstream connection is usually followed by reading from the client
which a subrequest is not allowed to do.  Moreover, accessing the header_in
request field while processing upgraded connection ends up with a null pointer
dereference since the header_in buffer is only created for the the main request.
2017-10-11 17:38:21 +03:00
Ruslan Ermilov 189f550ea3 Upstream: fixed $upstream_status when upstream returns 503/504.
If proxy_next_upstream includes http_503/http_504, and upstream
returns 503/504, $upstream_status converted this to 502 for any
values except the last one.
2017-10-11 22:04:28 +03:00
Ruslan Ermilov a3bb2e1885 Version bump. 2017-10-11 22:04:11 +03:00
Maxim Dounin 91a5b5129a release-1.13.6 tag 2017-10-10 18:22:51 +03:00
Maxim Dounin eb3addbcf4 nginx-1.13.6-RELEASE 2017-10-10 18:22:50 +03:00
Sergey Kandaurov bc73c0f694 Upstream: fixed error handling of stale and revalidated cache send.
The NGX_DONE value returned from ngx_http_upstream_cache_send() indicates
that upstream was already finalized in ngx_http_upstream_process_headers().
It was treated as a generic error which resulted in duplicate finalization.

Handled NGX_HTTP_UPSTREAM_INVALID_HEADER from ngx_http_upstream_cache_send().
Previously, it could return within ngx_http_upstream_finalize_request(), and
since it's below NGX_HTTP_SPECIAL_RESPONSE, a client connection could stuck.
2017-10-10 01:04:54 +03:00
Maxim Dounin 0e8a7c5b99 Upstream: even better handling of invalid headers in cache files.
When parsing of headers in a cache file fails, already parsed headers
need to be cleared, and protocol state needs to be reinitialized.  To do
so, u->request_sent is now set to ensure ngx_http_upstream_reinit() will
be called.

This change complements improvements in 46ddff109e72.
2017-10-09 15:59:10 +03:00
Maxim Dounin 89d424fd82 Upstream hash: reordered peer checks.
This slightly reduces cost of selecting a peer if all or almost all peers
failed, see ticket #1030.  There should be no measureable difference with
other workloads.
2017-10-05 17:43:05 +03:00
Maxim Dounin bd75c6d082 Upstream hash: limited number of tries in consistent case.
While this may result in non-ideal distribution of requests if nginx
won't be able to select a server in a reasonable number of attempts,
this still looks better than severe performance degradation observed
if there is no limit and there are many points configured (ticket #1030).
This is also in line with what we do for other hash balancing methods.
2017-10-05 17:42:59 +03:00
Maxim Dounin ebd65aa6f0 Fixed build without IPv6, broken by 874171c3c71a. 2017-10-05 16:50:35 +03:00
Maxim Dounin 71cf73141e Fixed handling of unix sockets in $binary_remote_addr.
Previously, unix sockets were treated as AF_INET ones, and this may
result in buffer overread on Linux, where unbound unix sockets have
2-byte addresses.

Note that it is not correct to use just sun_path as a binary representation
for unix sockets.  This will result in an empty string for unbound unix
sockets, and thus behaviour of limit_req and limit_conn will change when
switching from $remote_addr to $binary_remote_addr.  As such, normal text
representation is used.

Reported by Stephan Dollberg.
2017-10-04 21:19:42 +03:00
Maxim Dounin 5b1d286f59 Fixed handling of non-null-terminated unix sockets.
At least FreeBSD, macOS, NetBSD, and OpenBSD can return unix sockets
with non-null-terminated sun_path.  Additionally, the address may become
non-null-terminated if it does not fit into the buffer provided and was
truncated (may happen on macOS, NetBSD, and Solaris, which allow unix socket
addresess larger than struct sockaddr_un).  As such, ngx_sock_ntop() might
overread the sockaddr provided, as it used "%s" format and thus assumed
null-terminated string.

To fix this, the ngx_strnlen() function was introduced, and it is now used
to calculate correct length of sun_path.
2017-10-04 21:19:38 +03:00
Maxim Dounin 965bb87f61 Fixed buffer overread with unix sockets after accept().
Some OSes (notably macOS, NetBSD, and Solaris) allow unix socket addresses
larger than struct sockaddr_un.  Moreover, some of them (macOS, Solaris)
return socklen of the socket address before it was truncated to fit the
buffer provided.  As such, on these systems socklen must not be used without
additional check that it is within the buffer provided.

Appropriate checks added to ngx_event_accept() (after accept()),
ngx_event_recvmsg() (after recvmsg()), and ngx_set_inherited_sockets()
(after getsockname()).

We also obtain socket addresses via getsockname() in
ngx_connection_local_sockaddr(), but it does not need any checks as
it is only used for INET and INET6 sockets (as there can be no
wildcard unix sockets).
2017-10-04 21:19:33 +03:00
Valentin Bartenev d38339882b HTTP/2: enforce writing the sync request body buffer to file.
The sync flag of HTTP/2 request body buffer is used when the size of request
body is unknown or bigger than configured "client_body_buffer_size".  In this
case the buffer points to body data inside the global receive buffer that is
used for reading all HTTP/2 connections in the worker process.  Thus, when the
sync flag is set, the buffer must be flushed to a temporary file, otherwise
the request body data can be overwritten.

Previously, the sync buffer wasn't flushed to a temporary file if the whole
body was received in one DATA frame with the END_STREAM flag and wasn't
copied into the HTTP/2 body preread buffer.  As a result, the request body
might be corrupted (ticket #1384).

Now, setting r->request_body_in_file_only enforces writing the sync buffer
to a temporary file in all cases.
2017-10-04 21:15:15 +03:00
Maxim Dounin ba13bb7ba1 Cache: fixed caching of intercepted errors (ticket #1382).
When caching intercepted errors, previous behaviour was to use
proxy_cache_valid times specified, regardless of various cache control
headers present in the response.  Fix is to check u->cacheable and
use u->cache->valid_sec as set by various cache control response headers,
similar to how we do this in the normal caching code path.
2017-10-03 18:19:27 +03:00
Maxim Dounin e483a1acc7 Upstream: better handling of invalid headers in cache files.
If cache file is truncated, it is possible that u->process_header()
will return NGX_AGAIN.  Added appropriate handling of this case by
changing the error to NGX_HTTP_UPSTREAM_INVALID_HEADER.

Also, added appropriate logging of this and NGX_HTTP_UPSTREAM_INVALID_HEADER
cases at the "crit" level.  Note that this will result in duplicate logging
in case of NGX_HTTP_UPSTREAM_INVALID_HEADER.  While this is something better
to avoid, it is considered to be an overkill to implement cache-specific
error logging in u->process_header().

Additionally, u->buffer.start is now reset to be able to receive a new
response, and u->cache_status set to MISS to provide the value in the
$upstream_cache_status variable, much like it happens on other cache file
errors detected by ngx_http_file_cache_read(), instead of HIT, which is
believed to be misleading.
2017-10-02 19:10:20 +03:00
Maxim Dounin 0873219263 MIME: added most common OpenDocument types.
Requested by Michiel Leenaars.
2017-10-02 19:07:01 +03:00
Maxim Dounin f6255f2d8a MIME: style.
Restored alphabetical order within groups, OOXML types placed to
the application/ group and wrapped to avoid lines longer than 80 chars.
2017-10-02 19:06:51 +03:00
Ruslan Ermilov 4f0e1da995 Fixed the NGX_UNIX_ADDRSTRLEN macro. 2017-09-25 15:19:24 +03:00
Ruslan Ermilov 88c871b569 Modules compatibility: down flag promoted to a bitmask.
It is to be used as a bitmask with various bits set/reset when appropriate.
63b8b157b776 made a similar change to ngx_http_upstream_rr_peer_t.down and
ngx_stream_upstream_rr_peer_t.down.
2017-09-22 22:49:42 +03:00
Ruslan Ermilov 798fa67da5 Style. 2017-09-22 18:37:49 +03:00
Ruslan Ermilov 0ca820ba6c Do not use the obsolete NGX_SOCKADDRLEN macro.
The change in ac120e797d28 re-used the macro which was made obsolete
in adf25b8d0431.
2017-09-22 13:10:49 +03:00
Ruslan Ermilov 773cee610c Removed more remnants of the old pthread implementation.
After e284f3ff6831, ngx_crypt() can no longer return NGX_AGAIN.
2017-09-18 11:09:41 +03:00
Maxim Dounin 7ea82c3168 HTTP/2: shortened some debug log messages.
This ensures slightly more readable debug logs on 80-character-wide
terminals.
2017-09-14 19:06:06 +03:00
Maxim Dounin 259b643eb1 HTTP/2: fixed debug log about indexed headers.
Previously, "get indexed header" message was logged when in fact only
header name was obtained using an index, and "get indexed header name"
was logged when full header representation (name and value) was obtained
using an index.  Fixed version logs "get indexed name" and "get indexed
header" respectively.
2017-09-14 19:06:05 +03:00
Maxim Dounin 879e320565 HTTP/2: added logging of 400 (Bad Request) reasons. 2017-09-14 19:06:03 +03:00
Roman Arutyunyan 859759d7d3 Stream: fixed logging UDP upstream timeout.
Previously, when the first UDP response packet was not received from the
proxied server within proxy_timeout, no error message was logged before
switching to the next upstream.  Additionally, when one of succeeding response
packets was not received within the timeout, the timeout error had low severity
because it was logged as a client connection error as opposed to upstream
connection error.
2017-09-12 13:44:04 +03:00
Maxim Dounin 615f3d6a99 Introduced time truncation to December 31, 9999 (ticket #1368).
Various buffers are allocated in an assumption that there would be
no more than 4 year digits.  This might not be true on platforms
with 64-bit time_t, as 64-bit time_t is able to represent more than that.
Such dates with more than 4 year digits hardly make sense though, as
various date formats in use do not allow them anyway.

As such, all dates are now truncated by ngx_gmtime() to December 31, 9999.
This should have no effect on valid dates, though will prevent potential
buffer overflows on invalid ones.
2017-09-13 15:53:19 +03:00
Maxim Dounin d3f9924959 Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
In ngx_gmtime(), instead of casting to ngx_uint_t we now work with
time_t directly.  This allows using dates after 2038 on 32-bit platforms
which use 64-bit time_t, notably NetBSD and OpenBSD.

As the code is not able to work with negative time_t values, argument
is now set to 0 for negative values.  As a positive side effect, this
results in Epoch being used for such values instead of a date in distant
future.
2017-09-13 15:52:01 +03:00
Maxim Dounin 1f24c8d701 Fixed reference to time parsing code after 8b6fa4842133. 2017-09-13 15:51:58 +03:00
Maxim Dounin e666c4ff67 Style. 2017-09-13 15:51:52 +03:00
Piotr Sikora 16cde140ff HTTP/2: signal 0-byte HPACK's dynamic table size.
This change lets NGINX talk to clients with SETTINGS_HEADER_TABLE_SIZE
smaller than the default 4KB. Previously, NGINX would ACK the SETTINGS
frame with a small dynamic table size, but it would never send dynamic
table size update, leading to a connection-level COMPRESSION_ERROR.

Also, it allows clients to release 4KB of memory per connection, since
NGINX doesn't use HPACK's dynamic table when encoding headers, however
clients had to maintain it, since NGINX never signaled that it doesn't
use it.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-08-30 14:52:11 -07:00
Maxim Dounin e830586214 Trailing space removed. 2017-09-11 16:41:39 +03:00
Roman Arutyunyan 9ed1fdcbe1 Stream: relaxed next upstream condition (ticket #1317).
When switching to a next upstream, some buffers could be stuck in the middle
of the filter chain.  A condition existed that raised an error when this
happened.  As it turned out, this condition prevented switching to a next
upstream if ssl preread was used with the TCP protocol (see the ticket).

In fact, the condition does not make sense for TCP, since after successful
connection to an upstream switching to another upstream never happens.  As for
UDP, the issue with stuck buffers is unlikely to happen, but is still possible.
Specifically, if a filter delays sending data to upstream.

The condition can be relaxed to only check the "buffered" bitmask of the
upstream connection.  The new condition is simpler and fixes the ticket issue
as well.  Additionally, the upstream_out chain is now reset for UDP prior to
connecting to a new upstream to prevent repeating the client data twice.
2017-09-11 15:32:31 +03:00
Roman Arutyunyan a45b628b7d Version bump. 2017-09-11 15:46:23 +03:00
Maxim Dounin d6ece498df release-1.13.5 tag 2017-09-05 17:59:31 +03:00
Maxim Dounin 198a293ba5 nginx-1.13.5-RELEASE 2017-09-05 17:59:31 +03:00
Roman Arutyunyan a1ef866c23 Secure link: fixed stack buffer overflow.
When secure link checksum has length of 23 or 24 bytes, decoded base64 value
could occupy 17 or 18 bytes which is more than 16 bytes previously allocated
for it on stack.  The buffer overflow does not have any security implications
since only one local variable was corrupted and this variable was not used in
this case.

The fix is to increase buffer size up to 18 bytes.  Useless buffer size
initialization is removed as well.
2017-08-22 21:22:59 +03:00
Maxim Dounin 3758244250 Upstream: unconditional parsing of last_modified_time.
This fixes at least the following cases, where no last_modified_time
(assuming caching is not enabled) resulted in incorrect behaviour:

- slice filter and If-Range requests (ticket #1357);
- If-Range requests with proxy_force_ranges;
- expires modified.
2017-08-23 19:20:06 +03:00
Maxim Dounin 3abd1c3ec2 SSL: fixed possible use-after-free in $ssl_server_name.
The $ssl_server_name variable used SSL_get_servername() result directly,
but this is not safe: it references a memory allocation in an SSL
session, and this memory might be freed at any time due to renegotiation.
Instead, copy the name to memory allocated from the pool.
2017-08-22 17:36:12 +03:00
Maxim Dounin 46e34edfbe SSL: the $ssl_client_escaped_cert variable (ticket #857).
This variable contains URL-encoded client SSL certificate.  In contrast
to $ssl_client_cert, it doesn't depend on deprecated header continuation.
The NGX_ESCAPE_URI_COMPONENT variant of encoding is used, so the resulting
variable can be safely used not only in headers, but also as a request
argument.

The $ssl_client_cert variable should be considered deprecated now.
The $ssl_client_raw_cert variable will be eventually renambed back
to $ssl_client_cert.
2017-08-22 15:18:10 +03:00
Maxim Dounin dd63c2fb00 Range filter: changed type for total length to off_t.
Total length of a response with multiple ranges can be larger than a size_t
variable can hold, so type changed to off_t.  Previously, an incorrect
Content-Length was returned when requesting more than 4G of ranges from
a large enough file on a 32-bit system.

An additional size_t variable introduced to calculate size of the boundary
header buffer, as off_t is not needed here and will require type casts on
win32.

Reported by Shuxin Yang,
http://mailman.nginx.org/pipermail/nginx/2017-July/054384.html.
2017-08-10 22:21:23 +03:00
Maxim Dounin 5e4da0374f Restored ngx_event_aio_t layout for debug logging.
The "fd" field should be after 3 pointers for ngx_event_ident() to use it.
This was broken by ccad84a174e0.  While it does not seem to be currently used
for aio-related events, it should be a good idea to preserve the correct
layout nevertheless.
2017-08-10 22:21:22 +03:00
Maxim Dounin 4686e5744b Style. 2017-08-10 22:21:20 +03:00
Sergey Kandaurov bfe5f8da15 Fixed calls to ngx_open_file() in certain places.
Pass NGX_FILE_OPEN to ngx_open_file() to fix "The parameter is incorrect"
error on win32 when using the ssl_session_ticket_key directive or loading
a binary geo base.  On UNIX, this change is a no-op.
2017-08-09 15:03:27 +03:00
Sergey Kandaurov f34354a6a0 Style. 2017-08-09 14:59:46 +03:00
Sergey Kandaurov 9dde20c870 Version bump. 2017-08-09 14:59:44 +03:00
Maxim Dounin e03f7876b0 release-1.13.4 tag 2017-08-08 18:00:11 +03:00
Maxim Dounin d3bdff22ef nginx-1.13.4-RELEASE 2017-08-08 18:00:11 +03:00
Maxim Dounin 6b1cdd8e35 Updated PCRE used for win32 builds. 2017-08-08 15:21:10 +03:00
Ruslan Ermilov 60a85fc416 Slab: fixed initialization on win32.
On Windows, a worker process does not call ngx_slab_init() from
ngx_init_zone_pool(), so ngx_slab_max_size, ngx_slab_exact_size,
and ngx_slab_exact_shift were left uninitialized.
2017-08-08 15:16:01 +03:00
Ruslan Ermilov e6ee489fa5 Upstream: copy peer data in shared memory.
This, in addition to 1eb753aa8e5e, fixes "upstream zone" on Windows.
2017-08-04 17:03:10 +03:00
Ruslan Ermilov 70d0f6f143 Referer: fixed $invalid_referer.
The variable was considered non-existent in the absence of any
valid_referers directives.

Given the following config snippet,

    location / {
        return 200 $invalid_referer;
    }

    location /referer {
        valid_referers server_names;
    }

"location /" should work identically and independently on other
"location /referer".

The fix is to always add the $invalid_referer variable as long
as the module is compiled in, as is done by other modules.
2017-08-04 08:01:55 +03:00
Ruslan Ermilov c00905bc2c Upstream zone: store peers->name and its data in shared memory.
The shared objects should generally be allocated from shared memory.
While peers->name and the data it points to allocated from cf->pool
happened to work on UNIX, it broke on Windows.  On UNIX this worked
only because the shared memory zone for upstreams is re-created for
every new configuration.

But on Windows, a worker process does not inherit the address space
of the master process, so the peers->name pointed to data allocated
from cf->pool by the master process, and was invalid.
2017-08-01 19:12:10 +03:00
Ruslan Ermilov 4c27abe805 Variables: macros for null variables.
No functional changes.
2017-08-01 14:28:33 +03:00
Ruslan Ermilov 3db426def9 Browser: style.
Removed custom variable type and renamed function that adds variables.
2017-08-01 14:27:23 +03:00
Ruslan Ermilov 344331f1b7 Cache: fixed max_size on win32. 2017-07-26 13:13:51 +03:00
Sergey Kandaurov 89cac3ca13 SSL: fixed typo in the error message. 2017-07-25 17:21:59 +03:00
Roman Arutyunyan e79069b24a Mirror: "off" paramater of the "mirror" directive. 2017-07-21 19:47:56 +03:00
Roman Arutyunyan 9a38b55183 Mirror module. 2017-07-20 08:50:49 +03:00
Roman Arutyunyan 8060419690 Precontent phase.
The phase is added instead of the try_files phase.  Unlike the old phase, the
new one supports registering multiple handlers.  The try_files implementation is
moved to a separate ngx_http_try_files_module, which now registers a precontent
phase handler.
2017-07-20 15:51:11 +03:00
Roman Arutyunyan b157e3390c Upstream: keep request body file from removal if requested.
The new request flag "preserve_body" indicates that the request body file should
not be removed by the upstream module because it may be used later by a
subrequest.  The flag is set by the SSI (ticket #585), addition and slice
modules.  Additionally, it is also set by the upstream module when a background
cache update subrequest is started to prevent the request body file removal
after an internal redirect.  Only the main request is now allowed to remove the
file.
2017-07-19 20:38:17 +03:00
Alex Zhang 05a6068809 Style.
Signed-off-by: Alex Zhang <zchao1995@gmail.com>
2017-07-19 21:39:40 +08:00
Samuel Martin f142bef403 Configure: fixed PCRE requirement check by ngx_http_rewrite_module.
The http_rewrite module cannot be selected when http is disabled.
Fixed the PCRE check condition to avoid irrelevant check failure.
This is a regression from 4d874b4d82ed.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
2017-07-19 12:05:50 +03:00
Valentin Bartenev 237c947170 Parenthesized ASCII-related calculations.
This also fixes potential undefined behaviour in the range and slice filter
modules, caused by local overflows of signed integers in expressions.
2017-07-17 17:23:51 +03:00
Ruslan Ermilov 43c9ebab25 Style: aligned ngx_null_command. 2017-07-12 11:34:04 +03:00
Maxim Dounin cf8a162779 Core: fixed error message on setsockopt(SO_REUSEPORT) failure.
The error is fatal when configuring a new socket, so the ", ignored" part
is not appropriate and was removed.
2017-07-11 20:06:52 +03:00
Maxim Dounin e1cb53068f Core: disabled SO_REUSEPORT when testing config (ticket #1300).
When closing a socket with SO_REUSEPORT, Linux drops all connections waiting
in this socket's listen queue.  Previously, it was believed to only result
in connection resets when reconfiguring nginx to use smaller number of worker
processes.  It also results in connection resets during configuration
testing though.

Workaround is to avoid using SO_REUSEPORT when testing configuration.  It
should prevent listening sockets from being created if a conflicting socket
already exists, while still preserving detection of other possible errors.
It should also cover UDP sockets.

The only downside of this approach seems to be that a configuration testing
won't be able to properly report the case when nginx was compiled with
SO_REUSEPORT, but the kernel is not able to set it.  Such errors will be
reported on a real start instead.
2017-07-11 19:59:56 +03:00
Maxim Dounin a8d325a2c8 Version bump. 2017-07-11 19:59:16 +03:00
Maxim Dounin 524f42262f release-1.13.3 tag 2017-07-11 16:18:31 +03:00
Maxim Dounin 0113888cfb nginx-1.13.3-RELEASE 2017-07-11 16:18:30 +03:00
Maxim Dounin 630b233303 Range filter: avoid negative range start.
Suffix ranges no longer allowed to set negative start values, to prevent
ranges with negative start from appearing even if total size protection
will be removed.
2017-07-11 16:06:26 +03:00
Maxim Dounin 5aaae6ba32 Range filter: protect from total size overflows.
The overflow can be used to circumvent the restriction on total size of
ranges introduced in c2a91088b0c0 (1.1.2).  Additionally, overflow
allows producing ranges with negative start (such ranges can be created
by using a suffix, "bytes=-100"; normally this results in 200 due to
the total size check).  These can result in the following errors in logs:

[crit] ... pread() ... failed (22: Invalid argument)
[alert] ... sendfile() failed (22: Invalid argument)

When using cache, it can be also used to reveal cache file header.
It is believed that there are no other negative effects, at least with
standard nginx modules.

In theory, this can also result in memory disclosure and/or segmentation
faults if multiple ranges are allowed, and the response is returned in a
single in-memory buffer.  This never happens with standard nginx modules
though, as well as known 3rd party modules.

Fix is to properly protect from possible overflow when incrementing size.
2017-07-11 16:06:23 +03:00
Ruslan Ermilov f87c316017 Variables: use ngx_http_variable_null_value where appropriate. 2017-07-07 14:34:21 +03:00
Ruslan Ermilov 98c44ba30c Resolver: cancelable resend timer event.
It is safe because re-sending still works during graceful shutdown as
long as resolving takes place (and resolve tasks set their own timeouts
that are not cancelable).

Also, the new ctx->cancelable flag can be set to make resolve task's
timeout event cancelable.
2017-07-04 18:50:41 +03:00
Sergey Kandaurov 0192b8a06e Resolver: factored out setting a timer for resolver timeout.
No functional changes.
2017-07-04 18:46:30 +03:00
Ruslan Ermilov c94c9823ef Slab: fixed small allocations on systems with large pagesize.
Notably, on ppc64 with 64k pagesize, slab 0 (of size 8) requires
128 64-bit elements for bitmasks.  The code bogusly assumed that
one uintptr_t is enough for bitmasks plus at least one free slot.
2017-07-04 18:32:30 +03:00
Ruslan Ermilov c5a4a769fb Slab: style. 2017-07-04 18:32:28 +03:00
Roman Arutyunyan aeee657275 Resolver: fixed possible use-after-free while resolving SRV.
Resolving an SRV record includes resolving its host names in subrequests.
Previously, if memory allocation failed while reporting a subrequest result
after receiving a response from a DNS server, the SRV resolve handler was
called immediately with the NGX_ERROR state.  However, if the SRV record
included another copy of the resolved name, it was reported once again.
This could trigger the use-after-free memory access after SRV resolve
handler freed the resolve context by calling ngx_resolve_name_done().

Now the SRV resolve handler is called only when all its subrequests are
completed.
2017-07-04 18:07:29 +03:00
Piotr Sikora 6341882305 Proxy: split configured header names and values.
Previously, each configured header was represented in one of two ways,
depending on whether or not its value included any variables.

If the value didn't include any variables, then it would be represented
as as a single script that contained complete header line with HTTP/1.1
delimiters, i.e.:

     "Header: value\r\n"

But if the value included any variables, then it would be represented
as a series of three scripts: first contained header name and the ": "
delimiter, second evaluated to header value, and third contained only
"\r\n", i.e.:

     "Header: "
     "$value"
     "\r\n"

This commit changes that, so that each configured header is represented
as a series of two scripts: first contains only header name, and second
contains (or evaluates to) only header value, i.e.:

    "Header"
    "$value"

or

    "Header"
    "value"

This not only makes things more consistent, but also allows header name
and value to be accessed separately.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-15 15:55:35 -07:00
Maxim Dounin 9b2fe56a2a Version bump. 2017-07-03 16:58:08 +03:00
Maxim Dounin b8b83bc1de release-1.13.2 tag 2017-06-27 17:44:18 +03:00
Maxim Dounin 0da4cd4c60 nginx-1.13.2-RELEASE 2017-06-27 17:44:17 +03:00
Maxim Dounin 6648f45861 Range filter: allowed ranges on empty files (ticket #1031).
As per RFC 2616 / RFC 7233, any range request to an empty file
is expected to result in 416 Range Not Satisfiable response, as
there cannot be a "byte-range-spec whose first-byte-pos is less
than the current length of the entity-body".  On the other hand,
this makes use of byte-range requests inconvenient in some cases,
as reported for the slice module here:

http://mailman.nginx.org/pipermail/nginx-devel/2017-June/010177.html

This commit changes range filter to instead return 200 if the file
is empty and the range requested starts at 0.
2017-06-27 00:53:46 +03:00
Maxim Dounin d5f43360f4 Upstream: introduced ngx_http_upstream_ssl_handshake_handler().
This change reworks 13a5f4765887 to only run posted requests once,
with nothing on stack.  Running posted requests with other request
functions on stack may result in use-after-free in case of errors,
similar to the one reported in #788.

To only run posted request once, a separate function was introduced
to be used as ssl handshake handler in c->ssl->handler,
ngx_http_upstream_ssl_handshake_handler().  The ngx_http_run_posted_requests()
is only called in this function, and not in ngx_http_upstream_ssl_handshake()
which may be called directly on stack.

Additionaly, ngx_http_upstream_ssl_handshake_handler() now does appropriate
debug logging of the current subrequest, similar to what is done in other
event handlers.
2017-06-22 21:09:06 +03:00
Roman Arutyunyan 8ce9d66e54 Upstream: fixed running posted requests (ticket #788).
Previously, the upstream resolve handler always called
ngx_http_run_posted_requests() to run posted requests after processing the
resolver response.  However, if the handler was called directly from the
ngx_resolve_name() function (for example, if the resolver response was cached),
running posted requests from the handler could lead to the following errors:

- If the request was scheduled for termination, it could actually be terminated
in the resolve handler.  Upper stack frames could reference the freed request
object in this case.

- If a significant number of requests were posted, and for each of them the
resolve handler was called directly from the ngx_resolve_name() function,
posted requests could be run recursively and lead to stack overflow.

Now ngx_http_run_posted_requests() is only called from asynchronously invoked
resolve handlers.
2017-06-14 20:13:41 +03:00
Roman Arutyunyan 624299b864 Resolver: added the "async" flag to resolver context.
The flag indicates that the resolve handler is called asynchronously after the
resolve function ngx_resolve_name()/ngx_resolve_addr() exited.
2017-06-14 18:13:31 +03:00
Bart Warmerdam 4f3956f62d Resolver: fixed allocation error handling while resolving SRV. 2017-06-19 14:25:42 +03:00
Ruslan Ermilov e6ac1b7f6b Introduced ngx_rwlock_downgrade(). 2017-06-16 18:15:58 +03:00
Ruslan Ermilov 2ecb29b5c7 Added memory barrier semantics to ngx_rwlock_unlock(). 2017-06-16 18:15:53 +03:00
Piotr Sikora 275afe8e8d Headers filter: added "add_trailer" directive.
Trailers added using this directive are evaluated after response body
is processed by output filters (but before it's written to the wire),
so it's possible to use variables calculated from the response body
as the trailer value.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-24 03:37:34 -07:00
Piotr Sikora 0a5e335a1b HTTP/2: added support for trailers in HTTP responses.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-24 03:37:34 -07:00
Piotr Sikora 64b19dc297 Added support for trailers in HTTP responses.
Example:

   ngx_table_elt_t  *h;

   h = ngx_list_push(&r->headers_out.trailers);
   if (h == NULL) {
       return NGX_ERROR;
   }

   ngx_str_set(&h->key, "Fun");
   ngx_str_set(&h->value, "with trailers");
   h->hash = ngx_hash_key_lc(h->key.data, h->key.len);

The code above adds "Fun: with trailers" trailer to the response.

Modules that want to emit trailers must set r->expect_trailers = 1
in header filter, otherwise they might not be emitted for HTTP/1.1
responses that aren't already chunked.

This change also adds $sent_trailer_* variables.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-24 03:37:34 -07:00
Ruslan Ermilov 2e06ce59e1 Gzip: fixed style in $gzip_ratio variable handler.
The current style in variable handlers returning NGX_OK is to either set
v->not_found to 1, or to initialize the entire ngx_http_variable_value_t
structure.

In theory, always setting v->valid = 1 for NGX_OK would be useful, which
would mean that the value was computed and is thus valid, including the
special case of v->not_found = 1.  But currently that's not the case and
causes the (v->valid || v->not_found) check to access an uninitialized
v->valid value, which is safe only because its value doesn't matter when
v->not_found is set.
2017-06-14 12:49:20 +03:00
Ruslan Ermilov c0290b81c4 Removed excessive casts for ngx_file_info(). 2017-06-14 12:29:52 +03:00
Orgad Shaneh e6d91784f4 Configure: use .exe for binaries for all win32 compilers. 2017-06-06 19:37:34 +03:00
Orgad Shaneh 21dc601a19 Configure: fix compilation on MSYS2 / MinGW64. 2017-06-06 18:13:39 +03:00
Piotr Sikora 6e8f26dc7e HTTP/2: reject HTTP/2 requests without ":scheme" pseudo-header.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-06-13 17:01:08 +03:00
Sergey Kandaurov b0e6b85fc7 Userid: ngx_http_get_indexed_variable() error handling.
When evaluating a mapped $reset_uid variable in the userid filter,
if get_handler set to ngx_http_map_variable() returned an error,
this previously resulted in a NULL pointer dereference.
2017-06-07 18:46:36 +03:00
Sergey Kandaurov d4fbff63ab Fixed segfault in try_files with nested location.
If memory allocation of a new r->uri.data storage failed, reset its length as
well.  Request URI is used in ngx_http_finalize_request() for debug logging.
2017-06-07 18:46:35 +03:00
Sergey Kandaurov 25cb1b88b7 SSI: return NGX_ERROR when timefmt memory allocation failed.
Previously, when using NGX_HTTP_SSI_ERROR, error was ignored in ssi processing,
thus timefmt could be accessed later in ngx_http_ssi_date_gmt_local_variable()
as part of "set" handler, or NULL format pointer could be passed to strftime().
2017-06-07 15:21:42 +03:00
Piotr Sikora 4c5cc9b733 HTTP/2: don't send SETTINGS ACK before already queued DATA frames.
Previously, SETTINGS ACK was sent immediately upon receipt of SETTINGS
frame, before already queued DATA frames created using old SETTINGS.

This incorrect behavior was source of interoperability issues, because
peers rely on the fact that new SETTINGS are in effect after receiving
SETTINGS ACK.

Reported by Feng Li.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-06-02 15:05:32 +03:00
Piotr Sikora 4a8b0bc501 HTTP/2: make SETTINGS ACK frame reusable.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-06-02 15:05:28 +03:00
Piotr Sikora 2e606fcd72 HTTP/2: send SETTINGS ACK after applying all SETTINGS params.
This avoids sending unnecessary SETTINGS ACK in case of PROTOCOL_ERROR.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-06-02 15:05:24 +03:00
Piotr Sikora 0fad8d9259 HTTP/2: emit new frames only after applying all SETTINGS params.
Previously, new frames could be emitted in the middle of applying
new (and already acknowledged) SETTINGS params, which is illegal.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-06-02 15:05:20 +03:00
Sergey Kandaurov 4e9219ad4c Configure: enabled rpath for NetBSD. 2017-06-02 12:55:31 +03:00
Roman Arutyunyan 8bd97c5e6f Configure: disabled IP_PKTINFO feature on certain platforms.
On Cygwin and NetBSD 7.0+ struct in_pktinfo has no ipi_spec_dst field, which
caused nginx compilation error.  Now presence of this field is ensured by the
IP_PKTINFO feature test.

The problem was introduced by dbb0c854e308 (1.13.0).
2017-06-01 15:44:23 +03:00
Maxim Dounin 5e5fff63ba Style. 2017-06-01 16:49:14 +03:00
Piotr Sikora 3ecc886d23 Upstream: style.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-05-31 13:51:36 -07:00
Piotr Sikora 638e0f9baa Headers filter: style.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-05-31 13:51:35 -07:00
Piotr Sikora 3e15571ac6 HTTP/2: add debug logging of pseudo-headers and cookies.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-05-30 17:42:27 +03:00
Valentin Bartenev 6bde1f3bba Version bump. 2017-05-30 19:29:45 +03:00
Maxim Dounin 9d380d9e1e release-1.13.1 tag 2017-05-30 17:55:23 +03:00
Maxim Dounin b2fb10cbbf nginx-1.13.1-RELEASE 2017-05-30 17:55:22 +03:00
Maxim Dounin 0699fa96f6 Updated OpenSSL used for win32 builds. 2017-05-30 17:14:00 +03:00
Roman Arutyunyan b14c04beae Fixed background requests with asynchronous operations.
If the main request was finalized while a background request performed an
asynchronous operation, the main request ended up in ngx_http_writer() and was
not finalized until a network event or a timeout.  For example, cache
background update with aio enabled made nginx unable to process further client
requests or close the connection, keeping it open until client closes it.

Now regular finalization of the main request is not suspended because of an
asynchronous operation in another request.

If a background request was terminated while an asynchronous operation was in
progress, background request's write event handler was changed to
ngx_http_request_finalizer() and never called again.

Now, whenever a request is terminated while an asynchronous operation is in
progress, connection error flag is set to make further finalizations of any
request with this connection lead to termination.

These issues appeared in 1aeaae6e9446 (not yet released).
2017-05-29 23:33:38 +03:00
Maxim Dounin 2bb80c06e7 Configure: sched_setaffinity() test moved to auto/unix.
The sched_setaffinity() function was introduced in DragonFly BSD 4.7,
so it is no longer Linux-specific.

Prodded by Sepherosa Ziehau.
2017-05-29 16:48:30 +03:00
Maxim Dounin 2a256d6081 Style: changed checks of ngx_ssl_create_connection() to != NGX_OK.
In http these checks were changed in a6d6d762c554, though mail module
was missed at that time.  Since then, the stream module was introduced
based on mail, using "== NGX_ERROR" check.
2017-05-29 16:34:35 +03:00
Maxim Dounin 5235d26b54 SSL: set TCP_NODELAY on SSL connections before handshake.
With OpenSSL 1.1.0+, the workaround for handshake buffer size as introduced
in a720f0b0e083 (ticket #413) no longer works, as OpenSSL no longer exposes
handshake buffers, see https://github.com/openssl/openssl/commit/2e7dc7cd688.
Moreover, it is no longer possible to adjust handshake buffers at all now.

To avoid additional RTT if handshake uses more than 4k we now set TCP_NODELAY
on SSL connections before handshake.  While this still results in sub-optimal
network utilization due to incomplete packets being sent, it seems to be
better than nothing.
2017-05-29 16:34:29 +03:00
Ruslan Ermilov 69c51b2387 Introduced ngx_tcp_nodelay(). 2017-05-26 22:52:48 +03:00
Roman Arutyunyan 8583aed728 Background subrequests for cache updates.
Previously, cache background update might not work as expected, making client
wait for it to complete before receiving the final part of a stale response.
This could happen if the response could not be sent to the client socket in one
filter chain call.

Now background cache update is done in a background subrequest.  This type of
subrequest does not block any other subrequests or the main request.
2017-05-25 15:57:59 +03:00
Roman Arutyunyan bbe9b3d7ae Fixed deferred accept with EPOLLRDHUP enabled (ticket #1278).
Previously, the read event of the accepted connection was marked ready, but not
available.  This made EPOLLRDHUP-related code (for example, in ngx_unix_recv())
expect more data from the socket, leading to unexpected behavior.

For example, if SSL, PROXY protocol and deferred accept were enabled on a listen
socket, the client connection was aborted due to unexpected return value of
c->recv().
2017-05-24 13:17:08 +03:00
Valentin Bartenev 14bc16027e HTTP/2: fixed segfault when memory allocation failed.
If allocation of cleanup handler in the HTTP/2 header filter failed, then
a stream might be freed with a HEADERS frame left in the output queue.

Now the HEADERS frame is accounted in the queue before trying to allocate
the cleanup handler.
2017-05-23 20:19:39 +03:00
Maxim Dounin 741e44aa5a Contrib: proper syntax parsing in vim syntax highlighting.
Instead of highlighting directives in arbitrary positions, proper
parsing of nginx.conf syntax was implemented, matching what nginx does
internally.  This allows vim to correctly highlight various complex cases,
including:

    return 301 http://example.com/path#fragment";

and also avoids highlighting of parameters as directives, as in

    server_name missing.semicolon.example.com
    index index.php;

where "index" is not a directive but a parameter of the "server_name"
directive due to missing semicolon.

Most important downside of this approach seems to be that there is no
easy way to introduce directive-specific parameters.  As such, only "listen"
directive parameters were preserved.
2017-05-22 16:34:47 +03:00
Dmitry Volyntsev ac8cd0ff4c Cache: ignore long locked entries during forced expire.
Abnormally exited workers may leave locked cache entries, this can
result in the cache size on disk exceeding max_size and shared memory
exhaustion.

This change mitigates the issue by ignoring locked entries during forced
expire.  It also increases the visibility of the problem by logging such
entries.
2017-05-18 18:39:16 +03:00
Sergey Kandaurov 84a68d10f9 Upstream: fixed u->headers_in.headers allocation error handling.
Previously, an allocation error resulted in uninitialized memory access
when evaluating $upstream_http_ variables.

On a related note, see r->headers_out.headers cleanup work in 0cdee26605f3.
2017-05-18 14:17:00 +03:00
Maxim Dounin 42c3f10fe8 Configure: recent Sun C versions. 2017-05-15 20:09:44 +03:00
Maxim Dounin be7d7499e5 Configure: disabled gcc atomics with Sun C (ticket #1261).
Oracle Developer Studio 12.5 introduced GCC-compatible __sync builtins.
Unfortunately, these builtins are neither GCC-compatible (they generate
warnings when used with volatile), nor working (unexpectedly fail on
unpredictable combinations of code layout and compiler flags).  As such,
the gcc builtin atomic operations configure test explicitly disabled when
compiling with Sun C.
2017-05-15 20:09:43 +03:00
Maxim Dounin 2cabd63422 Configure: style. 2017-05-15 20:09:40 +03:00
Ruslan Ermilov 574b8be784 Realip: allow hostnames in set_real_ip_from (ticket #1180). 2017-05-15 17:17:01 +03:00
Ruslan Ermilov 96fb77a64c Access: simplified rule parser code. 2017-05-15 17:16:32 +03:00
Sergey Kandaurov 83cd4390c2 SSL: allowed renegotiation in client mode with OpenSSL < 1.1.0.
In ac9b1df5b246 (1.13.0) we attempted to allow renegotiation in client mode,
but when using OpenSSL 1.0.2 or older versions it was additionally disabled
by SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS.
2017-05-03 15:15:56 +03:00
Maxim Dounin 2ceb9b503d Added missing "fall through" comments (ticket #1259).
Found by gcc7 (-Wimplicit-fallthrough).
2017-04-27 16:57:18 +03:00
Ruslan Ermilov af4833675c Don't pretend we support HTTP major versions >1 as HTTP/1.1. 2017-04-25 23:39:13 +03:00
Ruslan Ermilov 5758071262 Version bump. 2017-04-25 23:39:06 +03:00
Maxim Dounin fa535865ec release-1.13.0 tag 2017-04-25 17:18:22 +03:00
Maxim Dounin 009d33973b nginx-1.13.0-RELEASE 2017-04-25 17:18:21 +03:00
Valentin Bartenev ca2dbc6fc5 HTTP/2: reduced difference to HTTP/1.x in reading request body.
Particularly, this eliminates difference in behavior for requests without body
and deduplicates code.

Prodded by Piotr Sikora.
2017-04-24 14:17:13 +03:00
Valentin Bartenev e11a774eec HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.
It's required by RFC 7540.  While there is no real harm from such frames,
that should help to detect broken clients.

Based on a patch by Piotr Sikora.
2017-04-24 14:16:57 +03:00
Sergey Kandaurov 68443f18f6 Gzip static: use an appropriate error on memory allocation failure. 2017-04-20 18:26:38 +03:00
Sergey Kandaurov a006d29b8a Cleaned up r->headers_out.headers allocation error handling.
If initialization of a header failed for some reason after ngx_list_push(),
leaving the header as is can result in uninitialized memory access by
the header filter or the log module.  The fix is to clear partially
initialized headers in case of errors.

For the Cache-Control header, the fix is to postpone pushing
r->headers_out.cache_control until its value is completed.
2017-04-20 18:26:37 +03:00
Igor Sysoev dbeb3679ae Core: signal sender pid logging. 2017-04-20 13:58:16 +03:00
Sergey Kandaurov 395bc1a10b Sub filter: restored ngx_http_set_ctx() at the proper place.
Previously, ngx_http_sub_header_filter() could fail with a partially
initialized context, later accessed in ngx_http_sub_body_filter()
if called from the perl content handler.

The issue had appeared in 2c045e5b8291 (1.9.4).

A better fix would be to handle ngx_http_send_header() errors in
the perl module, though this doesn't seem to be easy enough.
2017-04-18 19:55:23 +03:00
Sergey Kandaurov 40b6db6897 SSL: compatibility with OpenSSL master branch.
The SSL_CTRL_SET_CURVES_LIST macro is removed in the OpenSSL master branch.
SSL_CTX_set1_curves_list is preserved as compatibility with previous versions.
2017-04-18 16:08:46 +03:00
Sergey Kandaurov 83907aacb1 SSL: disabled renegotiation detection in client mode.
CVE-2009-3555 is no longer relevant and mitigated by the renegotiation
info extension (secure renegotiation).  On the other hand, unexpected
renegotiation still introduces potential security risks, and hence we do
not allow renegotiation on the server side, as we never request renegotiation.

On the client side the situation is different though.  There are backends
which explicitly request renegotiation, and disabled renegotiation
introduces interoperability problems.  This change allows renegotiation
on the client side, and fixes interoperability problems as observed with
such backends (ticket #872).

Additionally, with TLSv1.3 the SSL_CB_HANDSHAKE_START flag is currently set
by OpenSSL when receiving a NewSessionTicket message, and was detected by
nginx as a renegotiation attempt.  This looks like a bug in OpenSSL, though
this change also allows better interoperability till the problem is fixed.
2017-04-18 16:08:44 +03:00
Sergey Kandaurov 13cc565639 SSL: added support for TLSv1.3 in ssl_protocols directive.
Support for the TLSv1.3 protocol will be introduced in OpenSSL 1.1.1.
2017-04-18 15:12:38 +03:00
Roman Arutyunyan 8167db88c7 Set UDP datagram source address (ticket #1239).
Previously, the source IP address of a response UDP datagram could differ from
the original datagram destination address.  This could happen if the server UDP
socket is bound to a wildcard address and the network interface chosen to output
the response packet has a different default address than the destination address
of the original packet.  For example, if two addresses from the same network are
configured on an interface.

Now source address is set explicitly if a response is sent for a server UDP
socket bound to a wildcard address.
2017-04-11 16:41:53 +03:00
Sergey Kandaurov 0db51faece Core: removed extra ngx_alloc() and ngx_calloc() prototypes. 2017-04-18 13:01:19 +03:00
Sergey Kandaurov d5b05f45bd Enabled IPV6_RECVPKTINFO / IPV6_PKTINFO on macOS.
This change allows setting the destination IPv6 address of a UDP datagram
received on a wildcard socket.
2017-04-17 14:42:12 +03:00
Simon Leblanc 0e74e20b79 Added support for the "308 Permanent Redirect" (ticket #877). 2017-04-11 03:13:46 +02:00
Vladimir Homutov 939e9f2c7c Mail: configurable socket buffer sizes.
The "rcvbuf" and "sndbuf" parameters are now supported by
the "listen" directive.
2017-04-03 17:30:34 +03:00
Vladimir Homutov 68e78a4274 Stream: configurable socket buffer sizes.
The "rcvbuf" and "sndbuf" parameters are now supported by
the "listen" directive.
2017-04-03 17:29:19 +03:00
Valentin Bartenev 1bda840e2c Core: improved JSON escaping.
Two-character representations are now used for \b, \f, \n, \r, and \t.
2017-04-12 22:47:57 +03:00
Ruslan Ermilov 3664dfc498 Use ngx_calloc_buf() where appropriate. 2017-04-12 22:21:04 +03:00
Ruslan Ermilov 150f18bf12 Version bump. 2017-04-12 22:14:24 +03:00
Maxim Dounin 98ac48b5df release-1.11.13 tag 2017-04-04 18:01:57 +03:00
Maxim Dounin 987c191009 nginx-1.11.13-RELEASE 2017-04-04 18:01:57 +03:00
Piotr Sikora 34fee6ab73 Upstream: allow recovery from "429 Too Many Requests" response.
This change adds "http_429" parameter to "proxy_next_upstream" for
retrying rate-limited requests, and to "proxy_cache_use_stale" for
serving stale cached responses after being rate-limited.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-24 02:48:03 -07:00
Piotr Sikora b9af1d6bb9 Added support for "429 Too Many Requests" response (RFC6585).
This change adds reason phrase in status line and pretty response body
when "429" status code is used in "return", "limit_conn_status" and/or
"limit_req_status" directives.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-24 02:48:03 -07:00
hucongcong 6e1c9a3b2d Fixed type. 2017-04-03 14:29:40 +08:00
Roman Arutyunyan 8c04fa263b Slice filter: prevented slice redirection (ticket #1219).
When a slice subrequest was redirected to a new location, its context was lost.
After its completion, a new slice subrequest for the same slice was created.
This could lead to infinite loop.  Now the slice module makes sure each slice
subrequest starts output with the slice context available.
2017-03-31 21:47:56 +03:00
Roman Arutyunyan f9f53a50b7 Slice filter: allowed at most one subrequest at a time.
Previously, if slice main request write handler was called while a slice
subrequest was running, a new subrequest for the same slice was started.
2017-03-28 14:03:57 +03:00
Maxim Dounin 63ab1ce549 Moved handling of wev->delayed to the connection event handler.
With post_action or subrequests, it is possible that the timer set for
wev->delayed will expire while the active subrequest write event handler
is not ready to handle this.  This results in request hangs as observed
with limit_rate / sendfile_max_chunk and post_action (ticket #776) or
subrequests (ticket #1228).

Moving the handling to the connection event handler fixes the hangs observed,
and also slightly simplifies the code.
2017-04-02 14:32:29 +03:00
Maxim Dounin 5611ad024e Perl: fixed delaying subrequests.
Much like in limit_req, use the wev->delayed flag to ensure proper handling
and interoperability with limit_rate.
2017-04-02 14:32:28 +03:00
Maxim Dounin 8a0dcc1b22 Limit req: fixed delaying subrequests.
Since limit_req uses connection's write event to delay request processing,
it can conflict with timers in other subrequests.  In particular, even
if applied to an active subrequest, it can break things if wev->delayed
is already set (due to limit_rate or sendfile_max_chunk), since after
limit_req finishes the wev->delayed flag will be set and no timer will be
active.

Fix is to use the wev->delayed flag in limit_req as well.  This ensures that
wev->delayed won't be set after limit_req finishes, and also ensures that
limit_req's timers will be properly handled by other subrequests if the one
delayed by limit_req is not active.
2017-04-02 14:32:26 +03:00
Piotr Sikora fd5ed3f491 HTTP/2: style and typos.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-26 01:25:01 -07:00
Valentin Bartenev d68fed3d6c HTTP/2: fixed connection finalization.
All streams in connection must be finalized before the connection
itself can be finalized and all related memory is freed.  That's
not always possible on the current event loop iteration.

Thus when the last stream is finalized, it sets the special read
event handler ngx_http_v2_handle_connection_handler() and posts
the event.

Previously, this handler didn't check the connection state and
could call the regular event handler on a connection that was
already in finalization stage.  In the worst case that could
lead to a segmentation fault, since some data structures aren't
supposed to be used during connection finalization.  Particularly,
the waiting queue can contain already freed streams, so the
WINDOW_UPDATE frame received by that moment could trigger
accessing to these freed streams.

Now, the connection error flag is explicitly checked in
ngx_http_v2_handle_connection_handler().
2017-03-29 20:21:01 +03:00
Valentin Bartenev 8af9495ae7 HTTP/2: fixed stream finalization.
In order to finalize stream the error flag is set on fake connection and
either "write" or "read" event handler is called.  The read events of fake
connections are always ready, but it's not the case with the write events.

When the ready flag isn't set, the error flag can be not checked in some
cases and as a result stream isn't finalized.  Now the ready flag is
explicilty set on write events for proper finalization in all cases.
2017-03-29 20:16:23 +03:00
Piotr Sikora d24dd6f4e1 HTTP/2: emit PROTOCOL_ERROR on padding errors.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-26 01:25:05 -07:00
Piotr Sikora 07da7cf1a0 HTTP/2: fix flow control with padded DATA frames.
Previously, flow control didn't account for padding in DATA frames,
which meant that its view of the world could drift from peer's view
by up to 256 bytes per received padded DATA frame, which could lead
to a deadlock.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-26 01:25:04 -07:00
Piotr Sikora 8bd92cf07e HTTP/2: fix $body_bytes_sent variable.
Previously, its value included payloads and frame headers of HEADERS
and CONTINUATION frames.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-26 01:25:03 -07:00
Piotr Sikora b0dcbb2896 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>
2017-03-26 01:25:02 -07:00
Maxim Dounin 83036f9570 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.
2017-03-28 18:15:42 +03:00
Maxim Dounin 511a550664 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.
2017-03-28 18:15:41 +03:00
Maxim Dounin f967f27091 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).
2017-03-28 18:15:39 +03:00
Sergey Kandaurov 6a7ab2b427 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.
2017-03-28 14:21:38 +03:00
Ruslan Ermilov 12e06ec490 Core: set nginx_shared_zone name via ngx_str_set(). 2017-03-28 11:28:51 +03:00
Ruslan Ermilov 334a8b5178 Use ngx_array_init() to initialize arrays. 2017-03-28 11:28:42 +03:00
Ruslan Ermilov a771c53366 Version bump. 2017-03-28 11:28:36 +03:00
Maxim Dounin cd2a80b487 release-1.11.12 tag 2017-03-24 18:05:06 +03:00
Maxim Dounin db3209bf87 nginx-1.11.12-RELEASE 2017-03-24 18:05:05 +03:00
Maxim Dounin 40c97456ee 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.
2017-03-24 16:26:12 +03:00
Ruslan Ermilov 38a18ae0bc Simplified code about duplicate root/alias directive. 2017-03-22 23:36:35 +03:00
Ruslan Ermilov 65e3bc0d89 Unified error messages about duplicate directives. 2017-03-22 22:49:52 +03:00
Ruslan Ermilov 43e1e85287 Version bump. 2017-03-22 22:49:42 +03:00
Maxim Dounin 13e7c2b590 release-1.11.11 tag 2017-03-21 18:04:22 +03:00
Maxim Dounin 4ca40b0f75 nginx-1.11.11-RELEASE 2017-03-21 18:04:22 +03:00
Maxim Dounin 87e3aab40c Added HTTP/2 to win32 builds. 2017-03-21 17:28:15 +03:00
Ruslan Ermilov 7422c3676c Fixed a comment. 2017-03-17 12:09:31 +03:00
Ruslan Ermilov d232828eb4 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.
2017-03-16 20:38:31 +03:00
Ruslan Ermilov 16144fc5ac 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.
2017-03-16 20:38:26 +03:00
Ruslan Ermilov ee41c4d508 Added missing "static" specifier found by gcc -Wtraditional.
This has somehow escaped from fbdaad9b0e7b.
2017-03-16 19:01:05 +03:00
Maxim Dounin 7b60732b5d Style. 2017-03-07 18:51:17 +03:00
Maxim Dounin 2882ddcb95 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.
2017-03-07 18:51:16 +03:00
Maxim Dounin 7e91d78604 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.
2017-03-07 18:51:15 +03:00
Maxim Dounin b9215e49d9 Core: introduced ngx_rbtree_next(). 2017-03-07 18:51:13 +03:00
Maxim Dounin e74567b930 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.
2017-03-07 18:51:12 +03:00
Maxim Dounin 8f1fa77f92 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.
2017-03-07 18:49:31 +03:00
Ruslan Ermilov a0302b0f2e Removed casts not needed after 1f513d7f1b45. 2017-03-07 11:47:58 +03:00
Sergey Kandaurov de13f11b01 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).
2017-03-06 17:56:23 +03:00
Ruslan Ermilov b02d59cad9 Added missing "static" specifiers found by gcc -Wtraditional. 2017-03-06 11:09:47 +03:00
Eran Kornblau d4b0ddfeb0 Added missing static specifiers. 2017-03-02 08:46:00 -05:00
othree 4f24189da7 Contrib: vim syntax, update 3rd party module directives. 2017-03-01 23:41:39 +08:00
Maxim Dounin 131e957031 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.
2017-02-27 22:36:15 +03:00
othree 3d483db9a7 Contrib: vim syntax, update core module directives. 2017-02-24 18:05:58 +08:00
othree 9541a16bb4 Contrib: vim syntax, listen option and SSL/Mail protocol keywords. 2017-02-22 12:26:41 +08:00
Maxim Dounin 00ceb37bd1 Fixed ngx_parse_size() / ngx_parse_offset() with 0-length strings. 2017-02-17 17:01:27 +03:00
Maxim Dounin 0f12cd2439 Trailing space removed. 2017-02-16 18:37:22 +03:00
Maxim Dounin f9eb083749 Docs: changes.xslt regenerated. 2017-02-16 18:33:03 +03:00
Maxim Dounin 1640941d6c 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.
2017-02-16 18:32:49 +03:00
Maxim Dounin bd80284989 Version bump. 2017-02-16 18:20:14 +03:00
Maxim Dounin 413baabe88 release-1.11.10 tag 2017-02-14 18:36:04 +03:00
Maxim Dounin 192125cafb nginx-1.11.10-RELEASE 2017-02-14 18:36:04 +03:00
Maxim Dounin 5d9f6d7c13 Gzip: free chain links on the hot path (ticket #1046). 2017-02-13 21:45:01 +03:00
Maxim Dounin efbb7cde80 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.
2017-02-10 20:24:26 +03:00
Maxim Dounin c1dac6e2f5 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.
2017-02-10 17:49:19 +03:00
Roman Arutyunyan 8759e14539 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.
2017-02-10 16:33:12 +03:00
Roman Arutyunyan 12ec596e93 Upstream: proxy_cache_background_update and friends.
The directives enable cache updates in subrequests.
2017-02-10 15:13:41 +03:00
Roman Arutyunyan 81e9a504fe 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.
2016-12-22 14:25:34 +03:00
Maxim Dounin 532014626f 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.
2017-02-08 19:36:03 +03:00
Maxim Dounin c36fd71386 Request body: c->error on "100 Continue" errors (ticket #1194). 2017-02-08 19:35:31 +03:00
Sergey Kandaurov 3442b94d70 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.
2017-02-06 18:38:06 +03:00
Maxim Dounin 63f996c3ed 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.
2017-02-02 20:29:16 +03:00
Sergey Kandaurov 07bd2fa9ad Configure: removed execute bit from auto/unix. 2017-02-01 20:04:06 +03:00
Dmitry Volyntsev 335e9e5170 Variables: generic prefix variables. 2017-01-31 21:19:58 +03:00
Ruslan Ermilov 8a19135528 Implemented the "server_tokens build" option.
Based on a patch by Tom Thorogood.
2017-01-31 12:09:40 +03:00
Maxim Dounin 83339786c2 Updated OpenSSL used for win32 builds. 2017-01-27 19:06:35 +03:00
Maxim Dounin e4bc8babe3 Upstream: removed unused bl_time and bl_state fields. 2017-01-26 16:16:48 +03:00
Thibault Charbonnier 73e4e89431 Upstream: removed unused ngx_http_upstream_conf_t.timeout field. 2017-01-24 17:52:39 -08:00
Vladimir Homutov 553059afd0 Upstream: removed compatibility shims from ngx_http_upstream_t.
The type is no longer modified in NGINX Plus.
2017-01-25 15:39:22 +03:00
Vladimir Homutov b06ca1a064 Version bump. 2017-01-26 11:44:55 +03:00
Maxim Dounin 7190d8b3ce release-1.11.9 tag 2017-01-24 17:02:19 +03:00
Maxim Dounin 008738d898 nginx-1.11.9-RELEASE 2017-01-24 17:02:18 +03:00
Maxim Dounin 17d2f1c51c Updated zlib and PCRE used for win32 builds. 2017-01-24 16:41:29 +03:00
Maxim Dounin 68b799c5de 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.
2017-01-20 21:14:19 +03:00
Maxim Dounin 5160f08abc 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.
2017-01-20 21:14:18 +03:00
Maxim Dounin fb48696ed1 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.
2017-01-20 21:12:48 +03:00
Maxim Dounin 01d042be7e 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.
2017-01-20 14:03:20 +03:00
Maxim Dounin 5425ef4841 Added cycle parameter to ngx_drain_connections().
No functional changes, mostly style.
2017-01-20 14:03:19 +03:00
Vladimir Homutov 91378d5984 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).
2017-01-19 16:20:07 +03:00
Vladimir Homutov 3ade735e52 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).
2017-01-19 16:17:05 +03:00
Sergey Kandaurov 1ec676905e Mail: make it possible to disable SASL EXTERNAL. 2017-01-12 19:22:03 +03:00
Vladimir Homutov 7a621a0c00 Stream: avoid infinite loop in case of socket read error. 2017-01-11 12:01:56 +03:00
Ruslan Ermilov 2f26840c9a Year 2017. 2017-01-10 17:13:06 +03:00
Ruslan Ermilov 75d99209f0 Version bump. 2017-01-10 17:13:01 +03:00
Maxim Dounin fff8d2d8dc release-1.11.8 tag 2016-12-27 17:23:08 +03:00
Maxim Dounin b367040de1 nginx-1.11.8-RELEASE 2016-12-27 17:23:07 +03:00
Roman Arutyunyan aa73bdcf97 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.
2016-12-26 14:27:05 +03:00
Maxim Dounin ba3f002e7c 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.
2016-12-24 18:01:14 +03:00
Maxim Dounin ac971e6d8d 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.
2016-12-24 18:01:14 +03:00
Maxim Dounin 740895228e 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().
2016-12-24 18:01:14 +03:00
Maxim Dounin 029f6e31bf Win32: minimized redefinition of ssize_t.
All variants of GCC have ssize_t available, there is no need to
redefine it.
2016-12-24 18:01:14 +03:00
Maxim Dounin fd561f1373 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.
2016-12-24 18:01:14 +03:00
Maxim Dounin 713bed4c44 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.
2016-12-24 18:01:14 +03:00
Maxim Dounin 20d2781b29 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.
2016-12-24 18:01:14 +03:00
Maxim Dounin a1b30a45e5 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".
2016-12-24 18:01:14 +03:00
Maxim Dounin e574f63d16 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.
2016-12-23 17:28:20 +03:00
Ruslan Ermilov 5c53097598 Fixed missing "Location" field with some relative redirects.
Relative redirects did not work with directory redirects and
auto redirects issued by nginx.
2016-12-22 11:58:52 +03:00
Ruslan Ermilov cee1594cab 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.
2016-12-21 23:10:51 +03:00
Ruslan Ermilov e91340f661 Limited recursion when evaluating variables.
Unlimited recursion might cause stack exhaustion in some misconfigurations.
2016-12-21 22:01:24 +03:00
Vladimir Homutov 7fb6560f85 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.
2016-12-20 12:05:14 +03:00
Roman Arutyunyan b0a0391890 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.
2016-12-19 14:02:39 +03:00
Ruslan Ermilov 925d460707 Configure: detect nginx version for nginx.pm at make time. 2016-12-16 19:54:37 +03:00
Dmitry Volyntsev acd2b8e2e9 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.
2016-12-16 18:21:55 +03:00
Dmitry Volyntsev a7dbe8032b 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.
2016-12-16 18:21:55 +03:00
Dmitry Volyntsev f3d2ddc5ff 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.
2016-12-16 18:21:42 +03:00
Ruslan Ermilov 4ee13b6b99 Resolver: fixed possible use-after-free in worker on fast shutdown.
The fix in a3dc657f4e95 was incomplete.
2016-12-16 14:53:28 +03:00
Ruslan Ermilov 984f29ac3b Resolver: fixed possible use-after-free in worker on fast shutdown. 2016-12-15 21:44:34 +03:00
Maxim Dounin d8f10e47aa 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().
2016-12-15 19:00:23 +03:00
Piotr Sikora 6c70cfa31f SSL: fix call to BIO_get_mem_data().
Fixes build with BoringSSL.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-12-13 14:19:30 -08:00
Valentin Bartenev ded28d0cb3 Access log: support for json escaping. 2016-12-15 16:25:42 +03:00
Armin Grodon 90ed9c9427 Contrib: added 'commentstring' for vim-commentary support. 2016-12-13 00:49:44 +01:00
Ruslan Ermilov 79e76d2eed The size of cmcf->phase_engine.handlers explained. 2016-12-13 22:00:49 +03:00
Ruslan Ermilov 64f88dad18 Version bump. 2016-12-13 22:00:42 +03:00
Maxim Dounin ba9cab241e release-1.11.7 tag 2016-12-13 18:21:23 +03:00
Maxim Dounin 78addced0f nginx-1.11.7-RELEASE 2016-12-13 18:21:23 +03:00
Valentin Bartenev ce29bf0b41 HTTP/2: prevented creating temp files for requests without body.
The problem was introduced by 52bd8cc17f34.
2016-12-10 13:23:38 +03:00
Valentin Bartenev ad4a293350 HTTP/2: fixed posted streams handling.
A bug was introduced by 82efcedb310b that could lead to timing out of
responses or segmentation fault, when accept_mutex was enabled.

The output queue in HTTP/2 can contain frames from different streams.
When the queue is sent, all related write handlers need to be called.
In order to do so, the streams were added to the h2c->posted queue
after handling sent frames.  Then this queue was processed in
ngx_http_v2_write_handler().

If accept_mutex is enabled, the event's "ready" flag is set but its
handler is not called immediately.  Instead, the event is added to
the ngx_posted_events queue.  At the same time in this queue can be
events from upstream connections.  Such events can result in sending
output queue before ngx_http_v2_write_handler() is triggered.  And
at the time ngx_http_v2_write_handler() is called, the output queue
can be already empty with some streams added to h2c->posted.

But after 82efcedb310b, these streams weren't processed if all frames
have already been sent and the output queue was empty.  This might lead
to a situation when a number of streams were get stuck in h2c->posted
queue for a long time.  Eventually these streams might get closed by
the send timeout.

In the worst case this might also lead to a segmentation fault, if
already freed stream was left in the h2c->posted queue.  This could
happen if one of the streams was terminated but wasn't closed, due to
the HEADERS frame or a partially sent DATA frame left in the output
queue.  If this happened the ngx_http_v2_filter_cleanup() handler
removed the stream from the h2c->waiting or h2c->posted queue on
termination stage, before the frame has been sent, and the stream
was again added to the h2c->posted queue after the frame was sent.

In order to fix all these problems and simplify the code, write
events of fake stream connections are now added to ngx_posted_events
instead of using a custom h2c->posted queue.
2016-11-28 20:58:14 +03:00
Ruslan Ermilov 85d550f3c9 Map: the "volatile" parameter.
By default, "map" creates cacheable variables [1].  With this
parameter it creates a non-cacheable variable.

An original idea was to deduce the cacheability of the "map"
variable by checking the cacheability of variables specified
in source and resulting values, but it turned to be too hard.
For example, a cacheable variable can be overridden with the
"set" directive or with the SSI "set" command.  Also, keeping
"map" variables cacheable by default is good for performance
reasons.  This required adding a new parameter.

[1] Before db699978a33f (1.11.0), the cacheability of the
"map" variable could vary depending on the cacheability of
variables specified in resulting values (ticket #1090).
This is believed to be a bug rather than a feature.
2016-12-08 17:51:49 +03:00
Ruslan Ermilov ba78acdf25 Map: simplified "map" block parser.
No functional changes.
2016-12-08 17:29:01 +03:00
Ruslan Ermilov 97688040a0 Slab: commented bitmap initialization for small allocations. 2016-12-08 17:22:07 +03:00
Ruslan Ermilov d2106097e9 Slab: free pages statistics. 2016-12-07 22:25:37 +03:00
Ruslan Ermilov cba15ca399 Slab: slots statistics.
For each slot, the number of total and used entries, as well as
the number of allocation requests and failures, are tracked.
2016-12-07 22:25:37 +03:00
Ruslan Ermilov aacf558467 Slab: simplified some math.
No functional changes.
2016-12-07 22:25:37 +03:00
Ruslan Ermilov 04f67a3b6c Slab: simplified allocation from slots.
Removed code that would cause an endless loop, and removed condition
check that is always false.  The first page in the slot list is
guaranteed to satisfy an allocation.
2016-12-07 22:25:37 +03:00
Ruslan Ermilov 4b4f376949 Slab: fixed the number of pages calculation.
When estimating the number of pages, do not count memory for slots.
In some cases this gives one extra usable memory page.
2016-12-07 22:25:37 +03:00
Ruslan Ermilov 6833118859 Slab: added comment about list heads. 2016-12-07 22:25:37 +03:00
Ruslan Ermilov 8e0a992e50 Slab: improved code readability.
No functional changes.
2016-12-07 22:25:37 +03:00
Maxim Dounin 73c35b9841 Core: fixed environment on exit.
On exit environment allocated from a pool is no longer available, leading
to a segmentation fault if, for example, a library tries to use it from
an atexit() handler.

Fix is to allocate environment via ngx_alloc() instead, and explicitly
free it using a pool cleanup handler if it's no longer used (e.g., on
configuration reload).
2016-12-07 19:03:31 +03:00
Maxim Dounin 61d665c722 Perl: removed special environment handling for the perl module.
In Perl 5.8.6 the default was switched to use putenv() when used as
embedded library unless "PL_use_safe_putenv = 0" is explicitly used
in the code.  Therefore, for modern versions of Perl it is no longer
necessary to restore previous environment when calling perl_destruct().
2016-12-07 19:03:26 +03:00
Maxim Dounin 2beb4754a0 Perl: added PERL_SET_INTERP().
For Perl compiled with threads, without PERL_SET_INTERP() the PL_curinterp
remains set to the first interpreter created (that is, one created at
original start).  As a result after a reload Perl thinks that operations
are done withing a thread, and, most notably, denies to change environment.

For example, the following code properly works on original start,
but fails after a reload:

    perl 'sub {
        my $r = shift;

        $r->send_http_header("text/plain");

        $ENV{TZ} = "UTC";
        $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n");
        $ENV{TZ} = "Europe/Moscow";
        $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n");

        return OK;
    }';

To fix this, PERL_SET_INTERP() added anywhere where PERL_SET_CONTEXT()
was previously used.

Note that PERL_SET_INTERP() doesn't seem to be documented anywhere.
Yet it is used in some other software, and also seems to be the only
solution possible.
2016-12-07 19:03:19 +03:00
Sergey Kandaurov e031c48705 Fixed spelling of logical AND operator, no functional changes.
Found by PVS-Studio.
2016-12-07 13:54:30 +03:00
hucongcong 994288e097 Mp4: fixed setting wrong mdat atom size in very rare cases.
Atom size is the sum of atom header size and atom data size. The
specification says that the first 4 bytes are set to one when
the atom size is greater than the maximum unsigned 32-bit value.
Which means atom header size should be considered when the
comparison takes place between atom data size and 0xffffffff.
2016-11-22 13:40:08 +08:00
Maxim Dounin cd21132a67 SSL: $ssl_curves (ticket #1088).
The variable contains a list of curves as supported by the client.
Known curves are listed by their names, unknown ones are shown
in hex, e.g., "0x001d:prime256v1:secp521r1:secp384r1".

Note that OpenSSL uses session data for SSL_get1_curves(), and
it doesn't store full list of curves supported by the client when
serializing a session.  As a result $ssl_curves is only available
for new sessions (and will be empty for reused ones).

The variable is only meaningful when using OpenSSL 1.0.2 and above.
With older versions the variable is empty.
2016-12-05 22:23:23 +03:00
Maxim Dounin 81b3808de2 SSL: $ssl_ciphers (ticket #870).
The variable contains list of ciphers as supported by the client.
Known ciphers are listed by their names, unknown ones are shown
in hex, e.g., ""AES128-SHA:AES256-SHA:0x00ff".

The variable is fully supported only when using OpenSSL 1.0.2 and above.
With older version there is an attempt to provide some information
using SSL_get_shared_ciphers().  It only lists known ciphers though.
Moreover, as OpenSSL uses session data for SSL_get_shared_ciphers(),
and it doesn't store relevant data when serializing a session.  As
a result $ssl_ciphers is only available for new sessions (and not
available for reused ones) when using OpenSSL older than 1.0.2.
2016-12-05 22:23:23 +03:00
Maxim Dounin db21612f0d SSL: $ssl_client_v_start, $ssl_client_v_end, $ssl_client_v_remain. 2016-12-05 22:23:23 +03:00
Maxim Dounin 0badc6aab0 SSL: $ssl_client_verify extended with a failure reason.
Now in case of a verification failure $ssl_client_verify contains
"FAILED:<reason>", similar to Apache's SSL_CLIENT_VERIFY, e.g.,
"FAILED:certificate has expired".

Detailed description of possible errors can be found in the verify(1)
manual page as provided by OpenSSL.
2016-12-05 22:23:22 +03:00
Maxim Dounin f2e4293321 OCSP stapling: improved error logging context.
It now logs the IP address of the responder used (if it's already known),
as well as the certificate name.
2016-12-05 22:23:22 +03:00
Maxim Dounin 9fa1ef2dfa OCSP stapling: added certificate name to warnings. 2016-12-05 22:23:22 +03:00
Maxim Dounin cfc873aaa3 OCSP stapling: added http response status logging. 2016-12-05 22:23:22 +03:00
Maxim Dounin 43c2337df5 OCSP stapling: style. 2016-12-05 22:23:22 +03:00
Ruslan Ermilov 7331782655 Slab: improved double free detection.
Previously, an attempt to double free the starting page of the
free range was not detected.
2016-12-03 10:01:39 +03:00
Ruslan Ermilov be48931c8d Slab: always show the requested allocation size in debug messages.
Previously, allocations smaller than min_size were shown as min_size.
2016-12-03 10:01:03 +03:00
Ruslan Ermilov 055ddd55db Slab: style.
Removed redundant parentheses.  No functional changes.
2016-12-03 09:55:40 +03:00
Dmitry Volyntsev cd158e7d03 Events: improved error event handling for UDP sockets.
Normally, the epoll module calls the read and write handlers depending
on whether EPOLLIN and EPOLLOUT are reported by epoll_wait().  No error
processing is done in the module, the handlers are expected to get an
error when doing I/O.

If an error event is reported without EPOLLIN and EPOLLOUT, the module
set both EPOLLIN and EPOLLOUT to ensure the error event is handled at
least in one active handler.

This works well unless the error is delivered along with only one of
EPOLLIN or EPOLLOUT, and the corresponding handler does not do any I/O.
For example, it happened when getting EPOLLERR|EPOLLOUT from
epoll_wait() upon receiving "ICMP port unreachable" while proxying UDP.
As the write handler had nothing to send it was not able to detect and
log an error, and did not switch to the next upstream.

The fix is to unconditionally set EPOLLIN and EPOLLOUT in case of an
error event.  In the aforementioned case, this causes the read handler
to be called which does recv() and detects an error.

In addition to the epoll module, analogous changes were made in
devpoll/eventport/poll.
2016-11-21 16:03:42 +03:00
Valentin Bartenev e855bb2829 HTTP/2: fixed saving preread buffer to temp file (ticket #1143).
Previously, a request body bigger than "client_body_buffer_size" wasn't written
into a temporary file if it has been pre-read entirely.  The preread buffer
is freed after processing, thus subsequent use of it might result in sending
corrupted body or cause a segfault.
2016-11-28 19:19:21 +03:00
Maxim Dounin a52d8e876a Configure: honor dependencies of dynamic modules.
Dependencies of dynamic modules are added to NGX_ADDON_DEPS (and
it is now used for dynamic modules) to be in line with what happens
in case of static compilation.

To avoid duplication, MAIL_DEPS and STREAM_DEPS are no longer passed
to auto/module when these modules are compiled as dynamic ones.  Mail
and stream dependencies are handled explicitly via corresponding
variables.
2016-11-21 16:49:19 +03:00
Maxim Dounin 5de7fc64b6 Version bump. 2016-11-21 16:49:17 +03:00
Maxim Dounin 2a53e0887c release-1.11.6 tag 2016-11-15 18:11:46 +03:00
Maxim Dounin 530837051f nginx-1.11.6-RELEASE 2016-11-15 18:11:46 +03:00
Maxim Dounin 988b7221cf Fixed a typo, removed an empty line. 2016-11-14 21:55:44 +03:00
Maxim Dounin faf81ec21e Upstream: handling of upstream SSL handshake timeouts.
Previously SSL handshake timeouts were not properly logged, and resulted
in 502 errors instead of 504 (ticket #1126).
2016-11-14 17:21:06 +03:00
hucongcong a43df1feee Range filter: only initialize ctx->ranges in main request.
It is not necessary to initialize ctx->ranges in all request, because
ctx->ranges in subrequest will be reassigned to ctx->ranges of main
request.
2016-11-10 10:44:52 +08:00
hucongcong 9c5c471d21 Core: slight optimization in ngx_chain_update_chains().
It is not necessary to traverse *busy and link the *out when *out is NULL.
2016-11-10 10:17:53 +08:00
Ruslan Ermilov d3d7d99f02 Style: switch. 2016-11-04 19:12:19 +03:00
Maxim Dounin eb5b53c01f Cache: prefix-based temporary files.
On Linux, the rename syscall can be slow due to a global file system lock,
acquired for the entire rename operation, unless both old and new files are
in the same directory.  To address this temporary files are now created
in the same directory as the expected resulting cache file when using the
"use_temp_path=off" parameter.

This change mostly reverts 99639bfdfa2a and 3281de8142f5, restoring the
behaviour as of a9138c35120d (with minor changes).
2016-11-03 17:10:29 +03:00
Maxim Dounin 4c93c98094 Upstream: avoid holding a cache node with upgraded connections.
Holding a cache node lock doesn't make sense as we can't use caching
anyway, and results in "ignore long locked inactive cache entry" alerts
if a node is locked for a long time.

The same is done for unbuffered connections, as they can be alive for
a long time as well.
2016-11-03 17:09:32 +03:00
Dmitry Volyntsev 7a60042522 Cache: proxy_cache_max_range_offset and friends.
It configures a threshold in bytes, above which client range
requests are not cached.  In such a case the client's Range
header is passed directly to a proxied server.
2016-11-02 20:05:21 +03:00
Sergey Kandaurov 5aa3aa8ee4 HTTP/2: flow control debugging. 2016-11-02 11:47:12 +03:00
Maxim Dounin 9c74a07478 Perl: fixed optimization in SSI command handler.
As the pointer to the first argument was tested instead of the argument
itself, array of arguments was always created, even if there were no
arguments.  Fix is to test args[0] instead of args.

Found by Coverity (CID 1356862).
2016-11-01 20:39:21 +03:00
Ruslan Ermilov 2a8951e45c HTTP/2: slightly improved debugging. 2016-10-31 23:38:51 +03:00
Ruslan Ermilov 7e030b97a2 Upstream: removed ngx_http_upstream_srv_conf_t.default_port.
This is an API change.
2016-10-17 14:30:54 +03:00
Ruslan Ermilov de496abb34 Upstream: don't consider default_port when matching upstreams.
The only thing that default_port comparison did in the current
code is prevented implicit upstreams to the same address/port
from being aliased for http and https, e.g.:

	proxy_pass http://10.0.0.1:12345;
	proxy_pass https://10.0.0.1:12345;

This is inconsistent because it doesn't work for a similar case
with uswgi_pass:

	uwsgi_pass uwsgi://10.0.0.1:12345;
	uwsgi_pass suwsgi://10.0.0.1:12345;

or with an explicit upstream:

	upstream u {
	    server 10.0.0.1:12345;
	}

	proxy_pass http://u;
	proxy_pass https://u;

Before c9059bd5445b, default_port comparison was needed to
differentiate implicit upstreams in

	proxy_pass http://example.com;

and

	proxy_pass https://example.com;

as u->port was not set.
2016-10-17 14:27:45 +03:00
Ruslan Ermilov 0ccc92df77 Upstream: consistently initialize explicit upstreams.
When an upstream{} block follows a proxy_pass reference to it,
such an upstream inherited port and default_port settings from
proxy_pass.  This was different from when they came in another
order (see ticket #1059).  Explicit upstreams should not have
port and default_port in any case.

This fixes the following case:

	server { location / { proxy_pass http://u; } ... }
	upstream u { server 127.0.0.1; }
	server { location / { proxy_pass https://u; } ... }

but not the following:

	server { location / { proxy_pass http://u; } ... }
	server { location / { proxy_pass https://u; } ... }
	upstream u { server 127.0.0.1; }
2016-10-17 14:14:02 +03:00
Ruslan Ermilov d5d8e03c87 Upstream: do not unnecessarily create per-request upstreams.
If proxy_pass (and friends) with variables evaluates an upstream
specified with literal address, nginx always created a per-request
upstream.

Now, if there's a matching upstream specified in the configuration
(either implicit or explicit), it will be used instead.
2016-10-31 18:33:36 +03:00
Ruslan Ermilov d46512eb9e Upstream: added the ngx_http_upstream_resolved_t.name field.
This fixes inconsistency in what is stored in the "host" field.
Normally it would contain the "host" part of the parsed URL
(e.g., proxy_pass with variables), but for the case of an
implicit upstream specified with literal address it contained
the text representation of the socket address (that is, host
including port for IP).

Now the "host" field always contains the "host" part of the URL,
while the text representation of the socket address is stored
in the newly added "name" field.

The ngx_http_upstream_create_round_robin_peer() function was
modified accordingly in a way to be compatible with the code
that does not know about the new "name" field.

The "stream" code was similarly modified except for not adding
compatibility in ngx_stream_upstream_create_round_robin_peer().

This change is also a prerequisite for the next change.
2016-10-31 18:33:33 +03:00
Ruslan Ermilov 7b015433cd Upstream: removed unnecessary condition in proxy_eval() and friends.
The first condition added in d3454e719bbb should have just replaced
the second one.
2016-10-31 18:33:31 +03:00
Valentin Bartenev 073aa10a93 HTTP/2: limited maximum number of requests in connection.
The new directive "http2_max_requests" is introduced.  From users point of
view it works quite similar to "keepalive_requests" but has significantly
bigger default value that is more suitable for HTTP/2.
2016-10-31 16:33:02 +03:00
Maxim Dounin a5a638de0c Mp4: introduced custom version of ngx_atofp().
This allows to correctly parse "start" and "end" arguments without
null-termination (ticket #475), and also fixes rounding errors observed
with strtod() when using i387 instructions.
2016-10-27 17:57:16 +03:00
Dmitry Lazurkin 38e1062954 Proxy: support variables for proxy_method directive. 2016-10-16 18:24:01 +03:00
Dmitry Volyntsev 4420802f87 SSL: RFC2253 compliant $ssl_client_s_dn and $ssl_client_i_dn.
Originally, the variables kept a result of X509_NAME_oneline(),
which is, according to the official documentation, a legacy
function.  It produces a non standard output form and has
various quirks and inconsistencies.

The RFC2253 compliant behavior is introduced for these variables.
The original variables are available through $ssl_client_s_dn_legacy
and $ssl_client_i_dn_legacy.
2016-10-21 16:28:39 +03:00
Valentin Bartenev bb90853a4e Image filter: support for WebP.
In collaboration with Ivan Poluyanov.
2016-10-21 15:18:44 +03:00
Valentin Bartenev 12390c4a73 HTTP/2: graceful shutdown of active connections (closes #1106).
Previously, while shutting down gracefully, the HTTP/2 connections were
closed in transition to idle state after all active streams have been
processed.  That might never happen if the client continued opening new
streams.

Now, nginx sends GOAWAY to all HTTP/2 connections and ignores further
attempts to open new streams.  A worker process will quit as soon as
processing of already opened streams is finished.
2016-10-20 16:15:03 +03:00
Maxim Dounin 5fcafd251f SSL: compatibility with BoringSSL.
BoringSSL changed SSL_set_tlsext_host_name() to be a real function
with a (const char *) argument, so it now triggers a warning due to
conversion from (u_char *).  Added an explicit cast to silence the
warning.

Prodded by Piotr Sikora, Alessandro Ghedini.
2016-10-19 18:36:50 +03:00
Vladimir Homutov 94ea39774f Core: show file contents only once while dumping configuration.
Files are considered the same if the path used by nginx during parsing matches.
2016-10-18 16:33:38 +03:00
Valentin Bartenev 5171bbb41a SSL: overcame possible buffer over-read in ngx_ssl_error().
It appeared that ERR_error_string_n() cannot handle zero buffer size well enough
and causes over-read.

The problem has also been fixed in OpenSSL:
https://git.openssl.org/?p=openssl.git;h=e5c1361580d8de79682958b04a5f0d262e680f8b
2016-10-18 20:46:06 +03:00
Rob N ★ 42dca0fee6 Mail: support SASL EXTERNAL (RFC 4422).
This is needed to allow TLS client certificate auth to work. With
ssl_verify_client configured, the auth daemon can choose to allow the
connection to proceed based on the certificate data.

This has been tested with Thunderbird for IMAP only. I've not yet found a
client that will do client certificate auth for POP3 or SMTP, and the method is
not really documented anywhere that I can find. That said, its simple enough
that the way I've done is probably right.
2016-10-08 18:05:00 +11:00
Maxim Dounin f34e5a0217 Mail: extensible auth methods in pop3 module. 2016-10-18 19:38:46 +03:00
Maxim Dounin 92a74ff25e Upstream: handling of proxy_set_header at http level.
When headers are set at the "http" level and not redefined in
a server block, we now preserve conf->headers into the "http"
section configuration to inherit it to all servers.

The same applies to conf->headers_cache, though it may not be effective
if no servers use cache at the "server" level as conf->headers_cache
is only initialized if cache is enabled on a given level.

Similar changes made in fastcgi/scgi/uwsgi to preserve conf->params
and conf->params_cache.
2016-10-14 19:48:26 +03:00
Maxim Dounin 88edfc470d Proxy: do not create conf->headers_source when not needed. 2016-10-14 19:48:26 +03:00
Maxim Dounin ad5439854f Upstream: hide_headers_hash handling at http level.
When headers to hide are set at the "http" level and not redefined in
a server block, we now preserve compiled headers hash into the "http"
section configuration to inherit this hash to all servers.
2016-10-14 19:48:26 +03:00
Maxim Dounin babece37a9 Upstream: hide_headers_hash inherited regardless of cache settings.
Dependency on cache settings existed prior to 2728c4e4a9ae (0.8.44)
as Set-Cookie header was automatically hidden from responses when
using cache.  This is no longer the case, and hide_headers_hash can
be safely inherited regardless of cache settings.
2016-10-14 19:48:26 +03:00
Maxim Dounin e1d283da6d Style. 2016-10-14 19:48:26 +03:00
Ruslan Ermilov c4c08c1b0f Cache: cache manager debugging. 2016-10-13 15:50:36 +03:00
Ruslan Ermilov 7e9648bb64 Version bump. 2016-10-13 15:35:48 +03:00
Maxim Dounin fd155be334 release-1.11.5 tag 2016-10-11 18:03:01 +03:00
Maxim Dounin d08e0e149d nginx-1.11.5-RELEASE 2016-10-11 18:03:00 +03:00
Maxim Dounin 64c6d2eb4c Updated OpenSSL used for win32 builds. 2016-10-11 16:52:48 +03:00
Maxim Dounin 6c5693e070 Modules compatibility: removed dependencies on NGX_MAIL_SSL.
External structures are now identical regardless of mail SSL module
compiled in or not.
2016-10-10 18:44:17 +03:00
Maxim Dounin 218de89db9 Modules compatibility: removed dependencies on NGX_STREAM_SSL.
External structures are now identical regardless of stream SSL module
compiled in or not.
2016-10-10 18:44:17 +03:00
Maxim Dounin 97a8024132 Modules compatibility: compatibility with NGX_HTTP_SSL.
With this change it is now possible to load modules compiled without
the "--with-http_ssl_module" configure option into nginx binary compiled
with it, and vice versa (if a module doesn't use ssl-specific functions),
assuming both use the "--with-compat" option.
2016-10-10 18:44:17 +03:00
Maxim Dounin 5b968069c9 Modules compatibility: compatibility with NGX_HAVE_FILE_AIO.
With this change it is now possible to load modules compiled without
the "--with-file-aio" configure option into nginx binary compiled with it,
and vice versa, assuming both use the "--with-compat" option.
2016-10-10 18:44:17 +03:00
Maxim Dounin 19347aabb4 Modules compatibility: compatibility with NGX_THREADS.
With this change it is now possible to load modules compiled without
the "--with-threads" configure option into nginx binary compiled with it,
and vice versa (if a module does not use thread-specific functions),
assuming both use the "--with-compat" option.
2016-10-10 18:44:17 +03:00
Maxim Dounin 7f7f27f0c3 Allowed '-' in method names.
It is used at least by SOAP (M-POST method, defined by RFC 2774) and
by WebDAV versioning (VERSION-CONTROL and BASELINE-CONTROL methods,
defined by RFC 3253).
2016-10-10 16:24:50 +03:00
Maxim Dounin 1c45ee343e Core: sockaddr lengths now respected by ngx_cmp_sockaddr().
Linux can return AF_UNIX sockaddrs with partially filled sun_path,
resulting in spurious comparison failures and failed binary upgrades.
Added proper checking of the lengths provided.

Reported by Jan Seda,
http://mailman.nginx.org/pipermail/nginx-devel/2016-September/008832.html.
2016-10-10 16:15:41 +03:00
Maxim Dounin 0ed3b2a38b Core: ngx_conf_set_access_slot() user access (ticket #1096).
Previously, user access bits were always set to "rw" unconditionally,
even with "user:r" explicitly specified.  With this change we only add
default user access bits (0600) if they weren't set explicitly.
2016-10-07 16:59:14 +03:00
Maxim Dounin 8cdec7c277 Realip: fixed duplicate processing on redirects (ticket #1098).
Duplicate processing was possible if the address set by realip was
listed in set_realip_from, and there was an internal redirect so module
context was cleared.  This resulted in exactly the same address being set,
so this wasn't a problem before the $realip_remote_addr variable was
introduced, though now results in incorrect $realip_remote_addr being
picked.

Fix is to use ngx_http_realip_get_module_ctx() to look up module context
even if it was cleared.  Additionally, the order of checks was switched to
check the configuration first as it looks more effective.
2016-10-06 23:16:05 +03:00
Sergey Kandaurov e2cb434777 Stream ssl_preread: fixed $ssl_preread_server_name variable.
Made sure to set the variable length only after successful SNI parsing.
2016-10-05 18:11:39 +03:00
Dmitry Volyntsev 87555e1215 Cache: cache manager limits.
The new parameters "manager_files", "manager_sleep"
and "manager_threshold" were added to proxy_cache_path
and friends.

Note that ngx_path_manager_pt was changed to return ngx_msec_t
instead of time_t (API change).
2016-10-05 14:22:30 +03:00
Ruslan Ermilov dee0a82d86 Core: use c->log while closing connection.
c->pool is not destroyed here since c52408583801.
2016-10-05 13:57:43 +03:00
Maxim Dounin be67803206 SSL: use X509_check_host() with LibreSSL.
Explicit checks for OPENSSL_VERSION_NUMBER replaced with checks
for X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT, thus allowing X509_check_host()
to be used with other libraries.  In particular, X509_check_host() was
introduced in LibreSSL 2.5.0.
2016-10-04 17:26:45 +03:00
Maxim Dounin 03c5053566 Configure: removed the --with-ipv6 option.
IPv6 now compiled-in automatically if support is found.  If there is a need
to disable it for some reason, --with-cc-opt="-DNGX_HAVE_INET6=0" can be used
for this.
2016-10-04 16:38:14 +03:00
Roman Arutyunyan ecd3b1bb1e Addition filter: set last_in_chain flag when clearing last_buf.
When the last_buf flag is cleared for add_after_body to append more data from a
subrequest, other filters may still have buffered data, which should be flushed
at this point.  For example, the sub_filter may have a partial match buffered,
which will only be flushed after the subrequest is done, ending up with
interleaved data in output.

Setting last_in_chain instead of last_buf flushes the data and fixes the order
of output buffers.
2016-10-03 21:03:27 +03:00
Roman Arutyunyan 034ca0309c Do not set last_buf flag in subrequests.
The last_buf flag should only be set in the last buffer of the main request.
Otherwise, several last_buf flags can appear in output.  This can, for example,
break the chunked filter, which will include several final chunks in output.
2016-10-03 20:48:51 +03:00
Ruslan Ermilov 8c17cc1e2f Modules compatibility: removed two NGX_HAVE_DEFERRED_ACCEPT checks.
Removed (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
from the signature accordingly.
2016-10-03 15:58:30 +03:00
Maxim Dounin fc4edc1ec3 Modules compatibility: removed unneeded NGX_HAVE_REUSEPORT checks.
Removed NGX_HAVE_REUSEPORT from the signature accordingly.
2016-10-03 15:58:29 +03:00
Maxim Dounin 74315d7327 Modules compatibility: removed unneeded IPV6_V6ONLY checks.
The IPV6_V6ONLY macro is now checked only while parsing appropriate flag
and when using the macro.

The ipv6only field in listen structures is always initialized to 1,
even if not supported on a given platform.  This is expected to prevent
a module compiled without IPV6_V6ONLY from accidentally creating dual
sockets if loaded into main binary with proper IPV6_V6ONLY support.
2016-10-03 15:58:25 +03:00
Maxim Dounin 007abac8d1 Modules compatibility: http2.
HTTP/2-specific fields in structures are now available unconditionally.
Removed NGX_HTTP_V2 from the signature accordingly.
2016-10-03 15:58:22 +03:00
Maxim Dounin e8d394c0a7 Modules compatibility: degradation fields now always present.
There is no need to save these two bits as they are wasted anyway.
Removed NGX_HTTP_DEGRADATION from the signature accordingly.
2016-10-03 15:58:19 +03:00
Maxim Dounin 1891cbed73 Modules compatibility: --with-compat configure option. 2016-10-03 15:58:16 +03:00
Ruslan Ermilov dbb0b99656 Introduced the NGX_COMPAT macro.
When enabled, some structures are padded to be size compatible
with their NGINX Plus versions.
2016-09-29 15:28:24 +03:00
Dmitry Volyntsev ca06f73069 Resolver: introduced state field in ngx_resolver_srv_name_t.
It keeps the actual state value of a DNS SRV subrequest
and can be used to report a more detailed log for
failed SRV records.
2016-09-29 19:40:47 +03:00
Maxim Dounin 9a6b5499e0 Modules compatibility: down flag promoted to a bitmask.
It is to be used as a bitmask with various bits set/reset when appropriate.
Any bit set means that the peer should not be used, that is, exactly what
current checks do, no additional changes required.
2016-09-29 18:06:05 +03:00
Maxim Dounin 1d8b45ec7a Modules compatibility: upstream config field.
It is to be used to track version of an upstream configuration used for
request processing.
2016-09-29 18:06:04 +03:00
Maxim Dounin 9c162356a0 Modules compatibility: status fields. 2016-09-29 18:06:03 +03:00
Maxim Dounin 20323051a4 Modules compatibility: health check fields. 2016-09-29 18:06:02 +03:00
Maxim Dounin ac9825fe77 Modules compatibility: cache purge fields. 2016-09-29 18:06:01 +03:00
Maxim Dounin 290af2fad4 Modules compatibility: slow start fields. 2016-09-29 18:06:00 +03:00
Maxim Dounin 3a3e6219d1 Modules compatibility: peer.notify.
This callback can be used to notify balancer about various events.
For now, it is only used in nginx-plus.
2016-09-29 18:05:59 +03:00
Ruslan Ermilov 5e4b1b8863 Stream: style.
Explicitly initialized peer's max_conns for upstreams created with
variables similar to how it's done in http.
2016-09-29 12:59:13 +03:00
Ruslan Ermilov 8425546542 Upstream: max_conns. 2016-09-22 19:32:47 +03:00
Ruslan Ermilov 5d1226a4ce Upstream: removed the quick recovery mechanism.
Its usefulness it questionable, and it interacts badly with max_conns.
2016-09-22 19:32:45 +03:00
Maxim Dounin b70abc5241 Upstream: introduced u->upstream.
It holds upstream{} block configuration, including ones selected via
run-time lookup using variables.
2016-09-22 19:32:26 +03:00
Maxim Dounin 2407a66373 Upstream: style. 2016-09-22 19:31:08 +03:00
Maxim Dounin 3a6c023989 Upstream: style, ngx_http_upstream_rr_peer_t.next moved. 2016-07-25 16:23:35 +03:00
Konstantin Pavlov 0c89c8bc5a Perl: pass additional linker options to perl module.
Previously flags passed by --with-ld-opt were not used when building perl
module, which meant hardening flags provided by package build systems were not
applied.
2016-09-20 22:11:23 +03:00
Valentin Bartenev 92578d6888 Fixed log levels of configuration parsing errors.
All the errors that prevent loading configuration must be printed on the "emerg"
log level.  Previously, nginx might silently fail to load configuration in some
cases as the default log level is "error".
2016-09-20 15:07:16 +03:00
Ruslan Ermilov d0c13e8c8c Removed influence of some options on structures. 2016-09-20 12:30:52 +03:00
Vladimir Homutov 41a985c12b Upstream hash: fixed missing upstream name initialization. 2016-09-16 15:13:24 +03:00
Vladimir Homutov eb3bb4df85 Stream ssl_preread: removed internal macro.
The ngx_log_debug() macro is internal and should not be used.
2016-09-15 15:36:02 +03:00
Vladimir Homutov 175d4bb90c Stream: ssl_preread module.
The ssl_preread module extracts information from the SSL Client Hello message
without terminating SSL.  Currently, only $ssl_preread_server_name variable
is supported, which contains server name from the SNI extension.
2016-09-15 14:56:51 +03:00
Vladimir Homutov 7eccf9879c Stream: preread phase.
In this phase, head of a stream is read and analysed before proceeding to the
content phase.  Amount of data read is controlled by the module implementing
the phase, but not more than defined by the "preread_buffer_size" directive.
The time spent on processing preread is controlled by the "preread_timeout"
directive.

The typical preread phase module will parse the beginning of a stream and set
variable that may be used by the content phase, for example to make routing
decision.
2016-09-15 14:56:02 +03:00
Roman Arutyunyan 6883869eb7 Stream: phases. 2016-09-15 14:55:54 +03:00
Roman Arutyunyan bb3fcf3e3f Stream: filters. 2016-09-15 14:55:46 +03:00
Vladimir Homutov f03438cca0 Version bump. 2016-09-15 14:56:26 +03:00
Maxim Dounin b17d05c4b6 release-1.11.4 tag 2016-09-13 18:39:24 +03:00
Maxim Dounin 462312939f nginx-1.11.4-RELEASE 2016-09-13 18:39:23 +03:00
Maxim Dounin 1bc825e2c8 OCSP stapling: fixed using wrong responder with multiple certs. 2016-09-12 20:11:06 +03:00
Sergey Kandaurov 63c807fb88 SSL: improved session ticket callback error handling.
Prodded by Guido Vranken.
2016-09-12 18:57:42 +03:00
Sergey Kandaurov 1c9f2dd191 SSL: factored out digest and cipher in session ticket callback.
No functional changes.
2016-09-12 18:57:42 +03:00
Dmitry Volyntsev 2c66228385 Stream: increase default value for proxy_protocol_timeout to 30s. 2016-09-08 15:51:36 +03:00
Dmitry Volyntsev 791bd716af Stream: realip module. 2016-09-01 14:45:33 +03:00
Dmitry Volyntsev 6377f87d38 Core: introduced ngx_cidr_match() function. 2016-09-07 13:56:53 +03:00
Dmitry Volyntsev d7df0f5ff3 Stream: allow using the session context inside handlers.
Previously, it was not possible to use the stream context
inside ngx_stream_init_connection() handlers.  Now, limit_conn,
access handlers, as well as those added later, can create
their own contexts.
2016-09-06 21:28:17 +03:00
Dmitry Volyntsev 2005b6bc51 Stream: $proxy_protocol_addr and $proxy_protocol_port. 2016-09-06 21:28:16 +03:00
Dmitry Volyntsev f3e6fe0980 Stream: the "proxy_protocol" parameter of the "listen" directive. 2016-09-06 21:28:16 +03:00
Dmitry Volyntsev ab41eb3341 Stream: postpone session initialization under accept mutex.
Previously, it was possible that some system calls could be
invoked while holding the accept mutex.  This is clearly
wrong as it prevents incoming connections from being accepted
as quickly as possible.
2016-09-06 21:28:13 +03:00
Vladimir Homutov 2f6748ce8c Stream: log module. 2016-09-05 17:50:16 +03:00
Vladimir Homutov 4ce91142ef Stream: upstream response time variables.
The $upstream_connect_time, $upstream_first_byte_time and
$upstream_session_time variables keep corresponding times.
2016-09-02 18:27:12 +03:00
Vladimir Homutov 522a62f6c0 Stream: $upstream_bytes_sent and $upstream_bytes_received. 2016-09-02 18:27:08 +03:00
Vladimir Homutov f302100397 Stream: the $upstream_addr variable.
Keeps the full address of the upstream server.  If several servers were
contacted during proxying, their addresses are separated by commas,
e.g. "192.168.1.1:80, 192.168.1.2:80".
2016-09-02 18:27:05 +03:00
Roman Arutyunyan aa0009333e Stream: the $status variable.
The stream session status is one of the following:

200 - normal completion
403 - access forbidden
500 - internal server error
502 - bad gateway
503 - limit conn
2016-08-11 20:22:23 +03:00
Maxim Dounin dc821de3a2 Event pipe: do not set file's thread_handler if not needed.
This fixes a problem with aio threads and sendfile with aio_write switched
off, as observed with range requests after fc72784b1f52 (1.9.13).  Potential
problems with sendfile in threads were previously described in 9fd738b85fad,
and this seems to be one of them.

The problem occurred as file's thread_handler was set to NULL by event pipe
code after a sendfile thread task was scheduled.  As a result, no sendfile
completion code was executed, and the same buffer was additionally sent
using non-threaded sendfile.  Fix is to avoid modifying file's thread_handler
if aio_write is switched off.

Note that with "aio_write on" it is still possible that sendfile will use
thread_handler as set by event pipe.  This is believed to be safe though,
as handlers used are compatible.
2016-09-01 20:05:23 +03:00
Maxim Dounin 7ee778693e Event pipe: process data after recv_chain() errors.
When c->recv_chain() returns an error, it is possible that we already
have some data previously read, e.g., in preread buffer.  And in some
cases it may be even a complete response.  Changed c->recv_chain() error
handling to process the data, much like it is already done if kevent
reports about an error.

This change, in particular, fixes processing of small responses
when an upstream fails to properly close a connection with lingering and
therefore the connection is reset, but the response is already fully
obtained by nginx (see ticket #1037).
2016-09-01 18:29:55 +03:00
Roman Arutyunyan 9c0040b43c Realip: fixed uninitialized memory access.
Previously, the realip module could be left with uninitialized context after an
error in the ngx_http_realip_set_addr() function.  That context could be later
accessed by $realip_remote_addr and $realip_remote_port variable handlers.
2016-09-01 14:33:51 +03:00
Vladimir Homutov 2d024ed616 Stream: the $protocol variable.
The variable keeps protocol used by the client, "TCP" or "UDP".
2016-08-26 15:33:07 +03:00
Vladimir Homutov 5baed059e5 Stream: the $session_time variable.
The variable keeps time spent on processing the stream session.
2016-08-26 15:33:04 +03:00
Vladimir Homutov 2bc540ba13 Stream: the $bytes_received variable.
The variable keeps the number of bytes received from the client.
2016-08-26 15:33:02 +03:00
Piotr Sikora 202d8cecef Thread pools: create threads in detached state.
This prevents theoretical resource leak, since those threads are never joined.

Found with ThreadSanitizer.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-08-15 05:52:04 -07:00
Sergey Kandaurov b30fd702ba Geo: fixed indentation. 2016-08-25 12:59:39 +03:00
Maxim Dounin 4c3245e3ec Contrib: unicode2nginx compatibility with recent Perl versions.
In recent Perl versions unpack("C*") unpacks wide characters by default,
likely since perl 5.10 (seen at least in perl 5.20).  Replaced with
unpack("U0C*") instead to unpack bytes.

While here, improved style and updated my email.
2016-08-24 15:53:17 +03:00
Ruslan Ermilov 85b24c072f Geo: fixed warnings when removing nonexistent ranges.
geo $geo {
    ranges;

    10.0.0.0-10.0.0.255 test;

    delete 10.0.1.0-10.0.1.255;     # should warn

    delete 10.0.0.0-10.0.0.255;
    delete 10.0.0.0-10.0.0.255;     # should warn
}
2016-08-23 15:59:42 +03:00
Ruslan Ermilov e4331faa7f Geo: fixed insertion of ranges specified in descending order. 2016-08-23 15:59:14 +03:00
Ruslan Ermilov 73f9b84fa9 Geo: fixed removing a range in certain cases.
If the range includes two or more /16 networks and does
not start at the /16 boundary, the last subrange was not
removed (see 91cff7f97a50 for details).
2016-08-23 15:59:06 +03:00
Ruslan Ermilov fd044c8ce8 Geo: fixed overflow when iterating over ranges. 2016-08-23 15:57:29 +03:00
Sergey Kandaurov e410d2dd6a SSL: adopted session ticket handling for OpenSSL 1.1.0.
Return 1 in the SSL_CTX_set_tlsext_ticket_key_cb() callback function
to indicate that a new session ticket is created, as per documentation.
Until 1.1.0, OpenSSL didn't make a distinction between non-negative
return values.

See https://git.openssl.org/?p=openssl.git;a=commitdiff;h=5c753de for details.
2016-08-22 18:53:21 +03:00
Piotr Sikora 172cb63eaf SSL: remove no longer needed workaround for BoringSSL.
BoringSSL added a no-op stub for OPENSSL_config() on 2016-01-26.

Requested by David Benjamin.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-08-18 14:49:48 -07:00
Ruslan Ermilov d40e8e1625 Events: fixed setting of IP_BIND_ADDRESS_NO_PORT/SO_REUSEADDR.
The IP_BIND_ADDRESS_NO_PORT option is set on upstream sockets
if proxy_bind does not specify a port.  The SO_REUSEADDR option
is set on UDP upstream sockets if proxy_bind specifies a port.

Due to checking of the wrong port, IP_BIND_ADDRESS_NO_PORT was
never set, and SO_REUSEPORT was always set.
2016-08-22 11:40:10 +03:00
Roman Arutyunyan b83431f900 Ensure "listen" exists in a mail or stream server (ticket #1049). 2016-08-17 11:26:51 +03:00
Roman Arutyunyan 61af7807aa Fixed wrong type of the "line" field.
The new type ngx_uint_t was supposed when formatting the line number.
2016-08-18 17:13:07 +03:00
Valentin Bartenev 06af4eb471 Geo: fixed access to already freed memory.
Previously, in "ranges" mode when all added ranges were deleted,
the ctx.high.low[i] was left pointing to a temporary array.
2016-08-18 17:11:03 +03:00
Vladimir Homutov aa85edd539 Upstream: the $upstream_bytes_received variable.
Unlike $upstream_response_length that only counts the body size,
the new variable also counts the size of response header and data
received after switching protocols when proxying WebSockets.
2016-08-10 16:46:39 +03:00
Ruslan Ermilov e8a82fb8a4 Simplified extraction of current time. 2016-08-08 17:11:29 +03:00
Sergey Kandaurov 726c324f87 SSL: guarded SSL_R_NO_CIPHERS_PASSED not present in OpenSSL 1.1.0.
It was removed in OpenSSL 1.1.0 Beta 3 (pre-release 6).  It was
not used since OpenSSL 1.0.1n and 1.0.2b.
2016-08-08 13:44:49 +03:00
Ruslan Ermilov c9f905673d Always seed PRNG with PID, seconds, and milliseconds. 2016-08-04 23:43:10 +03:00
Ruslan Ermilov e3c4fddbea Fixed undefined behavior when left shifting signed integer. 2016-08-04 23:42:00 +03:00
Ruslan Ermilov 2d02048d43 Win32: added per-thread random seeding.
The change in b91bcba29351 was not enough to fix random() seeding.
On Windows, the srand() seeds the PRNG only in the current thread,
and worse, is not inherited from the calling thread.  Due to this,
worker threads were not properly seeded.

Reported by Marc Bevand.
2016-08-04 01:15:41 +03:00
Vladimir Homutov 6d17548054 Stream: fixed build without stream_ssl_module (ticket #1032). 2016-07-26 19:34:12 +03:00
Vladimir Homutov d404cd003c Version bump. 2016-07-26 19:07:18 +03:00
Maxim Dounin 0d6acca280 release-1.11.3 tag 2016-07-26 16:58:58 +03:00
Maxim Dounin 01383680a4 nginx-1.11.3-RELEASE 2016-07-26 16:58:58 +03:00
Vladimir Homutov 4d22d48e37 Fixed regex captures handling without PCRE.
If PCRE is disabled, captures were treated as normal variables in
ngx_http_script_compile(), while code calculating flushes array length in
ngx_http_compile_complex_value() did not account captures as variables.
This could lead to write outside of the array boundary when setting
last element to -1.

Found with AddressSanitizer.
2016-07-06 14:33:40 +03:00
Vladimir Homutov 9022f6a3e0 Stream: variables in proxy_pass and proxy_ssl_name. 2016-06-14 18:29:46 +03:00
Valentin Bartenev 49b91cfa53 HTTP/2: flushing of the SSL buffer in transition to the idle state.
It fixes potential connection leak if some unsent data was left in the SSL
buffer.  Particularly, that could happen when a client canceled the stream
after the HEADERS frame has already been created.  In this case no other
frames might be produced and the HEADERS frame alone didn't flush the buffer.
2016-07-19 20:34:17 +03:00
Valentin Bartenev eaebfdbdff HTTP/2: refactored ngx_http_v2_send_output_queue().
Now it returns NGX_AGAIN if there's still data to be sent.
2016-07-19 20:34:02 +03:00
Valentin Bartenev b8550fd94e HTTP/2: fixed send timer handling.
Checking for return value of c->send_chain() isn't sufficient since there
are data can be left in the SSL buffer.  Now the wew->ready flag is used
instead.

In particular, this fixed a connection leak in cases when all streams were
closed, but there's still some data to be sent in the SSL buffer and the
client forgot about the connection.
2016-07-19 20:31:09 +03:00
Valentin Bartenev b463b5ee76 HTTP/2: avoid sending output queue if there's nothing to send.
Particularly this fixes alerts on OS X and NetBSD systems when HTTP/2 is
configured over plain TCP sockets.

On these systems calling writev() with no data leads to EINVAL errors
being logged as "writev() failed (22: Invalid argument) while processing
HTTP/2 connection".
2016-07-19 20:30:21 +03:00
Valentin Bartenev 3ed4babfed HTTP/2: always handle streams in error state.
Previously, a stream could be closed by timeout if it was canceled
while its send window was exhausted.
2016-07-19 20:22:44 +03:00
Valentin Bartenev be07b0eef9 HTTP/2: prevented output of the HEADERS frame for canceled streams.
It's useless to generate HEADERS if the stream has been canceled already.
2016-07-19 20:22:44 +03:00
Valentin Bartenev 074a6bac2e HTTP/2: always send GOAWAY while worker is shutting down.
Previously, if the worker process exited, GOAWAY was sent to connections in
idle state, but connections with active streams were closed without GOAWAY.
2016-07-19 20:22:44 +03:00
Valentin Bartenev ea47d8d7aa Events: support for EPOLLEXCLUSIVE.
This flag appeared in Linux 4.5 and is useful for avoiding thundering herd
problem.

The current Linux kernel implementation walks the list of exclusive waiters,
and queues an event to each epfd, until it finds the first waiter that has
threads blocked on it via epoll_wait().
2016-07-15 15:18:57 +03:00
Valentin Bartenev 96313b3c7e Style: sorted epoll flags. 2016-07-15 15:18:57 +03:00
Valentin Bartenev 911e167ffb Events: the "accept_mutex" directive is turned off by default.
Now it is believed that the accept mutex brings more harm than benefits.
Especially in various benchmarks it often results in situation where only
one worker grabs all connections.
2016-07-15 15:18:57 +03:00
Vladimir Homutov acac037289 Stream: split_clients module. 2016-07-12 17:34:52 +03:00
Vladimir Homutov 32d39c0607 Stream: geo module. 2016-06-30 16:12:50 +03:00
Vladimir Homutov 8851ca2f7e Stream: geoip module. 2016-07-12 17:34:43 +03:00
Vladimir Homutov 7f22fe9ae8 Stream: style. 2016-07-12 17:34:40 +03:00
Vladimir Homutov d54ac9788a Stream: individual build options for modules. 2016-07-12 12:38:01 +03:00
Sergey Kandaurov 10557c7585 HTTP/2: avoid left-shifting signed integer into the sign bit.
On non-aligned platforms, properly cast argument before left-shifting it in
ngx_http_v2_parse_uint32 that is used with u_char.  Otherwise it propagates
to int to hold the value and can step over the sign bit.  Usually, on known
compilers, this results in negation.  Furthermore, a subsequent store into a
wider type, that is ngx_uint_t on 64-bit platforms, results in sign-extension.

In practice, this can be observed in debug log as a very large exclusive bit
value, when client sent PRIORITY frame with exclusive bit set:

: *14 http2 PRIORITY frame sid:5 on 1 excl:8589934591 weight:17

Found with UndefinedBehaviorSanitizer.
2016-07-07 21:03:21 +03:00
Sergey Kandaurov 9d8d6ece82 Avoid left-shifting integers into the sign bit, which is undefined.
Found with UndefinedBehaviorSanitizer.
2016-07-07 21:02:28 +03:00
Piotr Sikora 3723e72808 Configure: stop polluting NGX_ namespace.
While there, fix the only test that used alternative variable name.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-06-27 15:00:06 -07:00
Piotr Sikora aeeafbe0ca Configure: fix build with -Werror=old-style-definition.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-06-27 15:00:05 -07:00
Piotr Sikora a6ba3b7fba Configure: fix build with -Werror=nonnull.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-06-27 15:00:04 -07:00
Piotr Sikora ff5e8c8c33 Configure: fix build with -Werror=unused-but-set-variable.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-06-27 15:00:03 -07:00
Piotr Sikora a76563bce2 Configure: fix build with -Werror=unused-value.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-06-27 15:00:02 -07:00
Piotr Sikora 86e8e88e65 Configure: style.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-06-27 15:00:01 -07:00
Piotr Sikora 854fcd66d9 Configure: remove auto/lib/test, unused since nginx-0.1.2.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2015-10-23 18:21:33 -07:00
Vladimir Homutov adcc0ad031 Stream: resolver. 2016-07-07 13:15:31 +03:00
Ruslan Ermilov 81baf95438 Use NGX_MAX_PATH_LEVEL where appropriate.
The macro was unused since 0.7.44.
2016-07-06 13:22:29 +03:00
Ruslan Ermilov 5fc0f263df Version bump. 2016-07-06 13:10:06 +03:00
Maxim Dounin 9243b6b84b release-1.11.2 tag 2016-07-05 18:56:14 +03:00
Maxim Dounin 5d39f0b3af nginx-1.11.2-RELEASE 2016-07-05 18:56:14 +03:00
Maxim Dounin 8b9c183f79 Updated PCRE used for win32 builds. 2016-07-05 18:30:56 +03:00
Roman Arutyunyan 74839ea88f Stream: return module. 2016-05-18 22:08:49 +03:00
Vladimir Homutov 3ed8de06ec Stream: SSL-related variables. 2016-06-29 12:52:52 +03:00
Vladimir Homutov 4b910cbf87 Stream: got rid of pseudo variables.
Stream limit_conn, upstream_hash and proxy modules now use complex values.
2016-06-29 12:46:12 +03:00
Vladimir Homutov 34c207aecf Stream: map module. 2016-06-29 12:46:12 +03:00
Vladimir Homutov c24ac32afc Stream: core module variables. 2016-06-14 18:28:14 +03:00
Vladimir Homutov fe16c7379e Stream: variables and script.
This is a port of corresponding http code with unrelated features excluded.
2016-07-04 16:37:36 +03:00
Vladimir Homutov e27d25e01a Stream: added preconfiguration step. 2016-06-15 15:10:24 +03:00
Roman Arutyunyan a7eb242cb0 Sub filter: eliminate unnecessary buffering.
Previously, when a buffer was processed by the sub filter, its final bytes
could be buffered by the filter even if they don't match any pattern.
This happened because the Boyer-Moore algorithm, employed by the sub filter
since b9447fc457b4 (1.9.4), matches the last characters of patterns prior to
checking other characters.  If the last character is out of scope, initial
bytes of a potential match are buffered until the last character is available.

Now, after receiving a flush or recycled buffer, the filter performs
additional checks to reduce the number of buffered bytes.  The potential match
is checked against the initial parts of all patterns.  Non-matching bytes are
not buffered.  This improves processing of a chunked response from upstream
by sending the entire chunks without buffering unless a partial match is found
at the end of a chunk.
2016-07-02 15:59:53 +03:00
Roman Arutyunyan b205bd123b Sub filter: introduced the ngx_http_sub_match() function.
No functional changes.
2016-07-02 15:59:52 +03:00
Maxim Dounin 44313caee5 Internal md5 and sha1 implementations are now always used.
This reduces the number of moving parts in ABI compatibility checks.
Additionally, it also allows to use OpenSSL in FIPS mode while still
using md5 for non-security tasks.
2016-06-30 18:57:39 +03:00
Ruslan Ermilov 583f6ef30b Removed unused flag accept_context_updated from ngx_event_t.
Also, removed practically unused flag accept_context_updated from
ngx_connection_t.
2016-06-29 14:30:00 +03:00
Roman Arutyunyan 9b1e38c9e8 Style. 2016-06-27 18:42:29 +03:00
Piotr Sikora ec49a8e60b HTTP/2: style.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-06-22 13:47:54 -07:00
Roman Arutyunyan c341996d38 Style. 2016-06-22 11:50:02 +03:00
Roman Arutyunyan fef71e0df8 Stream: use ngx_pcalloc() in ngx_stream_proxy_bind(). 2016-06-22 11:50:02 +03:00
Roman Arutyunyan ac2d83227d Fixed build on MSVC. 2016-06-20 15:11:50 +03:00
Roman Arutyunyan feb8fe61ff Stream: set SO_REUSEADDR for UDP upstream sockets.
The option is only set if the socket is bound to a specific port to allow
several such sockets coexist at the same time.  This is required, for example,
when nginx acts as a transparent proxy and receives two datagrams from the same
client in a short time.

The feature is only implemented for Linux.
2016-06-20 12:48:47 +03:00
Roman Arutyunyan 0b9eadf910 Stream: support for $remote_port in proxy_bind.
The following two types of bind addresses are supported in addition to
$remote_addr and address literals:

- $remote_addr:$remote_port
- [$remote_addr]:$remote_port

In both cases client remote address with port is used in upstream socket bind.
2016-06-20 11:50:44 +03:00
Roman Arutyunyan 2c095694bc Upstream: support for port in proxy_bind and friends. 2016-06-20 11:50:43 +03:00
Roman Arutyunyan 2fd4cd0981 Introduced ngx_inet_get_port() and ngx_inet_set_port() functions. 2016-06-20 11:50:39 +03:00
Andrei Belov 83ff429bce Set IP_BIND_ADDRESS_NO_PORT socket option for upstream sockets. 2016-06-20 10:41:17 +03:00
Tim Taubert 522f7dd4d5 SSL: ngx_ssl_ciphers() to set list of ciphers.
This patch moves various OpenSSL-specific function calls into the
OpenSSL module and introduces ngx_ssl_ciphers() to make nginx more
crypto-library-agnostic.
2016-06-15 21:05:30 +01:00
Valentin Bartenev b92bd1200f HTTP/2: fixed the "http request count is zero" alert.
When the stream is terminated the HEADERS frame can still wait in the output
queue.  This frame can't be removed and must be sent to the client anyway,
since HTTP/2 uses stateful compression for headers.  So in order to postpone
closing and freeing memory of such stream the special close stream handler
is set to the write event.  After the HEADERS frame is sent the write event
is called and the stream will be finally closed.

Some events like receiving a RST_STREAM can trigger the read handler of such
stream in closing state and cause unexpected processing that can result in
another attempt to finalize the request.  To prevent it the read handler is
now set to ngx_http_empty_handler.

Thanks to Amazon.
2016-06-16 20:55:11 +03:00
Valentin Bartenev c47eba68e2 HTTP/2: avoid adding Content-Length for requests without body.
There is no reason to add the "Content-Length: 0" header to a proxied request
without body if the header isn't presented in the original request.

Thanks to Amazon.
2016-06-16 20:55:11 +03:00
Valentin Bartenev fb76e75edb HTTP/2: prevented double termination of a stream.
According to RFC 7540, an endpoint should not send more than one RST_STREAM
frame for any stream.

Also, now all the data frames will be skipped while termination.
2016-06-16 20:55:11 +03:00
Valentin Bartenev 57a76ade8b HTTP/2: fixed a segfault while processing unbuffered upload.
The ngx_http_v2_finalize_connection() closes current stream, but that is an
invalid operation while processing unbuffered upload.  This results in access
to already freed memory, since the upstream module sets a cleanup handler that
also finalizes the request.
2016-06-16 20:55:11 +03:00
Maxim Dounin c2e391c832 An internal SHA1 implementation. 2016-06-09 16:55:38 +03:00
Otto Kekäläinen f66a37934a Fixed spelling. 2016-06-08 08:27:41 +03:00
Valentin Bartenev da10c88894 Fixed an error log message. 2016-06-07 17:44:20 +03:00
Sergey Kandaurov aa86ee53b5 Configure: revised GCC version processing.
Now GCC 6 and onwards will use -Wno-unused-parameter.
2016-06-07 12:15:56 +03:00
Sergey Kandaurov 32415c48a8 Version bump. 2016-06-07 12:26:34 +03:00
Maxim Dounin 6a17768e30 release-1.11.1 tag 2016-05-31 16:43:49 +03:00
Maxim Dounin 381adb4711 nginx-1.11.1-RELEASE 2016-05-31 16:43:49 +03:00
Maxim Dounin eaa1428c51 Core: skip special buffers on writing (ticket #981).
A special last buffer with cl->buf->pos set to NULL can be present in
a chain when writing request body if chunked encoding was used.  This
resulted in a NULL pointer dereference if it happened to be the only
buffer left after a do...while loop iteration in ngx_write_chain_to_file().

The problem originally appeared in nginx 1.3.9 with chunked encoding
support.  Additionally, rev. 3832b608dc8d (nginx 1.9.13) changed the
minimum number of buffers to trigger this from IOV_MAX (typically 1024)
to NGX_IOVS_PREALLOCATE (typically 64).

Fix is to skip such buffers in ngx_chain_to_iovec(), much like it is
done in other places.
2016-05-31 05:13:30 +03:00
Maxim Dounin 406202bf51 Trailing spaces removed. 2016-05-30 18:09:41 +03:00
Valentin Bartenev 305b52b44e HTTP/2: unbreak build on MSVC. 2016-05-24 21:54:32 +03:00
Valentin Bartenev e92d7bd21e Version bump. 2016-05-24 21:54:32 +03:00
Maxim Dounin 54f4da0450 release-1.11.0 tag 2016-05-24 18:54:42 +03:00
Maxim Dounin f55ae4f496 nginx-1.11.0-RELEASE 2016-05-24 18:54:41 +03:00
Maxim Dounin cf10a5e2ae Updated OpenSSL used for win32 builds. 2016-05-24 17:44:01 +03:00
Maxim Dounin 00cf50c68c Fixed build on MSVC. 2016-05-24 17:43:58 +03:00
Valentin Bartenev f4c72efa4c HTTP/2: implemented preread buffer for request body (closes #959).
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-24 17:37:52 +03:00
Ruslan Ermilov 05c36257f6 Realip: detect duplicate real_ip_header directive. 2016-05-23 19:17:24 +03:00
Dmitry Volyntsev 1de8821b24 Realip: port support in X-Real-IP and X-Forwarded-For.
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-23 18:44:23 +03:00
Dmitry Volyntsev 5234222b04 Realip: take client port from PROXY protocol header.
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-23 18:44:22 +03:00
Dmitry Volyntsev c4b6ea614e Added the $realip_remote_port variable. 2016-05-23 18:44:22 +03:00
Dmitry Volyntsev 6433b194e1 Added the $proxy_protocol_port variable. 2016-05-23 18:44:21 +03:00
Maxim Dounin fc978084d5 Renamed "u" to "sockaddr" in listen options types. 2016-05-23 16:37:28 +03:00
Ruslan Ermilov a6400247ef Introduced the ngx_sockaddr_t type.
It's properly aligned and can hold any supported sockaddr.
2016-05-23 16:37:20 +03:00
Ruslan Ermilov 748b77db95 Stream: fixed duplicate listen address detection.
The 6f8254ae61b8 change inadvertently fixed the duplicate port
detection similar to how it was fixed for mail in b2920b517490.
It also revealed another issue: the socket type (tcp vs. udp)
wasn't taken into account.
2016-05-23 12:50:59 +03:00
Ruslan Ermilov 04d95aee1a Use ngx_cmp_sockaddr() where appropriate. 2016-05-20 19:10:42 +03:00
Valentin Bartenev c21b8c2024 HTTP/2: the "421 Misdirected Request" response (closes #848).
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-20 18:41:17 +03:00
Ruslan Ermilov bf89326f24 Belatedly changed the ngx_create_listening() prototype.
The function is called only with "struct sockaddr *" since 0.7.58.
2016-05-20 17:02:04 +03:00
Maxim Dounin 889b8b9312 SSL: removed default DH parameters.
Using the same DH parameters on multiple servers is believed to be subject
to precomputation attacks, see http://weakdh.org/.  Additionally, 1024 bits
are not enough in the modern world as well.  Let users provide their own
DH parameters with the ssl_dhparam directive if they want to use EDH ciphers.

Note that SSL_CTX_set_dh_auto() as provided by OpenSSL 1.1.0 uses fixed
DH parameters from RFC 5114 and RFC 3526, and therefore subject to the same
precomputation attacks.  We avoid using it as well.

This change also fixes compilation with OpenSSL 1.1.0-pre5 (aka Beta 2),
as OpenSSL developers changed their policy after releasing Beta 1 and
broke API once again by making the DH struct opaque (see ticket #860).
2016-05-19 14:46:32 +03:00
Maxim Dounin 1d28f99a9e SSL: support for multiple curves (ticket #885).
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-19 14:46:32 +03:00
Maxim Dounin df6791fa79 SSL: style. 2016-05-19 14:46:32 +03:00
Maxim Dounin d8f309670b SSL: error messages style. 2016-05-19 14:46:32 +03:00
Maxim Dounin 3dc95a5597 SSL: support for multiple certificates (ticket #814). 2016-05-19 14:46:32 +03:00
Maxim Dounin 677f032704 SSL: support for per-certificate chains.
The SSL_CTX_add0_chain_cert() function as introduced in OpenSSL 1.0.2 now
used instead of SSL_CTX_add_extra_chain_cert().

SSL_CTX_add_extra_chain_cert() adds extra certs for all certificates
in the context, while SSL_CTX_add0_chain_cert() only to a particular
certificate.  There is no difference unless multiple certificates are used,
though it is important when using multiple certificates.

Additionally, SSL_CTX_select_current_cert() is now called before using
a chain to make sure correct chain will be returned.
2016-05-19 14:46:32 +03:00
Maxim Dounin 9b134ce774 SSL: made it possible to iterate though all certificates.
A pointer to a previously configured certificate now stored in a certificate.
This makes it possible to iterate though all certificates configured in
the SSL context.  This is now used to configure OCSP stapling for all
certificates, and in ngx_ssl_session_id_context().

As SSL_CTX_use_certificate() frees previously loaded certificate of the same
type, and we have no way to find out if it's the case, X509_free() calls
are now posponed till ngx_ssl_cleanup_ctx().

Note that in OpenSSL 1.0.2+ this can be done without storing things in exdata
using the SSL_CTX_set_current_cert() and SSL_CTX_get0_certificate() functions.
These are not yet available in all supported versions though, so it's easier
to continue to use exdata for now.
2016-05-19 14:46:32 +03:00
Maxim Dounin 8932cc0170 OCSP stapling: additional function to configure stapling on a cert. 2016-05-19 14:46:32 +03:00
Maxim Dounin a940933978 OCSP stapling: staple now extracted via SSL_get_certificate().
This makes it possible to properly return OCSP staple with multiple
certificates configured.

Note that it only works properly in OpenSSL 1.0.1d+, 1.0.0k, 0.9.8y+.
In older versions SSL_get_certificate() fails to return correct certificate
when the certificate status callback is called.
2016-05-19 14:46:32 +03:00
Maxim Dounin 307205d051 OCSP stapling: staple now stored in certificate, not SSL context. 2016-05-19 14:46:32 +03:00
Maxim Dounin 660928c29d OCSP stapling: staple provided in arguments. 2016-05-19 14:46:32 +03:00
Maxim Dounin 04c4212de9 Added overflow checks for version numbers (ticket #762).
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-18 16:21:32 +03:00
Maxim Dounin b5cdf67888 Events: close descriptors on errors in ngx_epoll_test_rdhup(). 2016-05-18 15:57:30 +03:00
Maxim Dounin a2089c6dab Events: changed ngx_epoll_test_rdhup() to use existing epollfd. 2016-05-18 15:57:29 +03:00
Maxim Dounin cbc94b5b3b Fixed work with --test-build-epoll after f7849bfb6d21. 2016-05-18 15:57:28 +03:00
Maxim Dounin bdff3e7a5a Cache: fixed updating bypassed cached errors (ticket #827). 2016-05-16 20:37:38 +03:00
Maxim Dounin ca94b7d3ee Dav: return 501 on PUT with ranges (ticket #948). 2016-05-16 20:37:23 +03:00
Valentin Bartenev b24752465d Fixed an error log message about epoll_wait() timeout.
The errno value is unset in case of epoll_wait() timeout.
2016-05-16 16:22:34 +03:00
Valentin Bartenev b32d9b87cf Improved EPOLLRDHUP handling.
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-13 17:19:23 +03:00
Dmitry Volyntsev eb11242a8e Map: support of complex values in resulting strings. 2016-05-12 16:43:19 +03:00
Ruslan Ermilov 9003b8a6e6 Removed a surplus condition from ngx_parse_inet6_url().
No functional changes, since the condition was always true.
2016-05-11 17:55:30 +03:00
Valentin Bartenev 85e7f29d53 Core: fixed port handling in ngx_parse_inet6_url().
This fixes buffer over-read when no port is specified in cases
similar to 5df5d7d771f6, and catches missing port separator.
2016-05-11 17:55:20 +03:00
Ruslan Ermilov 9a72fc4fae Removed unused flag unexpected_eof from ngx_connection_t. 2016-04-28 16:30:19 +03:00
Vladimir Homutov 24251be5e9 Variable $request_id.
The variable contains text representation based on random data, usable as
a unique request identifier.
2016-04-26 19:31:46 +03:00
Roman Arutyunyan 65b4772bb0 Upstream: the "transparent" parameter of proxy_bind and friends.
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;
2015-12-18 19:05:27 +03:00
Roman Arutyunyan 31963203de Stream: prepared proxy_bind to accept parameters. 2016-04-13 15:42:47 +03:00
Roman Arutyunyan 9dddb819a9 Upstream: prepared proxy_bind to accept parameters.
In addition, errors occurred while setting bind address are no longer ignored.
2016-04-13 15:42:46 +03:00
Ruslan Ermilov 3e972a54e4 Removed some bitrot.
Removed NGX_CONF_MULTI unused since 1.3.4.
Removed ngx_url_t.one_addr unused since 1.3.10.
2016-04-26 18:26:43 +03:00
Ruslan Ermilov dc78c5ecea Version bump. 2016-04-26 18:26:18 +03:00
Maxim Dounin a71c8e8df2 release-1.9.15 tag 2016-04-19 19:02:37 +03:00
Maxim Dounin 4fecb1c968 nginx-1.9.15-RELEASE 2016-04-19 19:02:37 +03:00
Valentin Bartenev a2ed226871 HTTP/2: send the output queue after emitting WINDOW_UPDATE.
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-19 17:38:49 +03:00
Valentin Bartenev 7ac31e7823 HTTP/2: skip data frames in case of internal errors.
This prevents possible processing of such frames and triggering
rb->post_handler if an error occurred during r->request_body
initialization.
2016-04-19 17:38:49 +03:00
Valentin Bartenev d6ac75d6c6 HTTP/2: don't send WINDOW_UPDATE for an empty request body.
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-19 17:38:49 +03:00
Maxim Dounin bea9c1b085 Thread pools: memory barriers in task completion notifications.
The ngx_thread_pool_done object isn't volatile, and at least some
compilers assume that it is permitted to reorder modifications of
volatile and non-volatile objects.  Added appropriate ngx_memory_barrier()
calls to make sure all modifications will happen before the lock is released.

Reported by Mindaugas Rasiukevicius,
http://mailman.nginx.org/pipermail/nginx-devel/2016-April/008160.html.
2016-04-19 17:18:28 +03:00
Maxim Dounin 16165af181 HTTP/2: write logs when refusing streams with data.
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-18 21:18:24 +03:00
Valentin Bartenev 0dedeb6bee HTTP/2: send WINDOW_UPDATE instead of RST_STREAM with NO_ERROR.
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-14 15:14:15 +03:00
Valentin Bartenev 3a5d18b10c HTTP/2: refuse streams with data until SETTINGS is acknowledged.
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-14 15:14:15 +03:00
Valentin Bartenev 0568bcf3eb HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
No functional changes.
2016-04-14 15:14:15 +03:00
Valentin Bartenev d13420e2d9 FastCGI: skip special bufs in buffered request body chain.
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-11 18:42:34 +03:00
Ruslan Ermilov 38cde475a8 Fixed NGX_CONF_TAKE1/NGX_CONF_FLAG misuse (as in e444e8f6538b). 2016-04-12 19:01:56 +03:00
Alessandro Ghedini a67bd03847 Fixed typos. 2016-04-11 16:47:11 +01:00
Ruslan Ermilov fab8ffe7a9 Removed redundant "u" format specifier.
It is implied for "x" and "X".
2016-04-08 15:03:38 +03:00
Ruslan Ermilov d4dbdf5d0f Simplified ngx_unix_recv() and ngx_readv_chain().
This makes ngx_unix_recv() and ngx_udp_unix_recv() differ minimally.
2016-04-08 16:49:35 +03:00
Valentin Bartenev 82cec54b98 Merged implementations of ngx_unix_recv().
There's no real need in two separate implementations,
with and without kqueue support.
2016-04-08 16:41:45 +03:00
Valentin Bartenev 91defaafce Fixed small inconsistency in handling EOF among receive functions.
Now all functions always drop the ready flag in this case.
2016-04-08 16:39:49 +03:00
Valentin Bartenev 206739e4f4 Merged implementations of ngx_udp_unix_recv().
There's no real need in two separate implementations,
with and without kqueue support.
2016-04-08 16:38:42 +03:00
Josh Soref 0ad1149053 Fixed spelling. 2016-04-07 11:50:13 +03:00
Ruslan Ermilov fc9d4d627a Version bump. 2016-04-07 19:09:42 +03:00
Maxim Dounin 8e627e8e1f release-1.9.14 tag 2016-04-05 17:57:08 +03:00
Maxim Dounin 1deffb7c7a nginx-1.9.14-RELEASE 2016-04-05 17:57:08 +03:00
Maxim Dounin b06f1d4b25 Compatibility with FreeBSD 2.2.9.
Added (RTLD_NOW | RTLD_GLOBAL) to dlopen() test.  There is no RTLD_GLOBAL
on FreeBSD 2.2.9.

Added uint32_t test, with fallback to u_int32_t, similar to uint64_t one.
Added fallback to u_int32_t in in_addr_t test.

With these changes it is now possible to compile nginx on FreeBSD 2.2.9
with only few minor warnings (assuming -Wno-error).
2016-04-01 16:38:31 +03:00
Maxim Dounin 29e755667e Configure: improved multiple types handling in auto/types/typedef. 2016-04-01 16:38:30 +03:00
Maxim Dounin ab2981176d Configure: fixed autotest source code logging.
Fixed a regression introduced in rev. 434548349838 that prevented
auto/types/sizeof and auto/types/typedef properly reporting autotest
source code to autoconf.err in case of test failure.
2016-04-01 16:38:28 +03:00
Valentin Bartenev 761bb975b6 HTTP/2: support for unbuffered upload of request body. 2016-04-01 15:57:10 +03:00
Valentin Bartenev 3b940bd677 HTTP/2: rewritten handling of request body.
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-01 15:56:03 +03:00
Valentin Bartenev a5f4b62f78 HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
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-04-01 15:56:03 +03:00
Maxim Dounin a5f237f07b Core: removed incorrect GCC 2.7 check.
It was broken since introduction (__GNU__ instead of __GNUC__) and did
nothing.  Moreover, GCC 2.7 is happy with the normal version of the code.

Reported by Joel Cunningham,
http://mailman.nginx.org/pipermail/nginx-devel/2016-March/007964.html.
2016-04-01 13:17:12 +03:00
Maxim Dounin 2605ad3b2e Trailing space fix. 2016-04-01 04:17:00 +03:00
Maxim Dounin 1ad7f43338 SSL: SSLeay_version() is deprecated in OpenSSL 1.1.0.
SSLeay_version() and SSLeay() are no longer available if OPENSSL_API_COMPAT
is set to 0x10100000L.  Switched to using OpenSSL_version() instead.

Additionally, we now compare version strings instead of version numbers,
and this correctly works for LibreSSL as well.
2016-03-31 23:38:38 +03:00
Sergey Kandaurov d4454f30ac SSL: X509 was made opaque in OpenSSL 1.1.0.
To increment reference counters we now use newly introduced X509_up_ref()
function.
2016-03-31 23:38:37 +03:00
Sergey Kandaurov 0681a4dc28 SSL: EVP_MD_CTX was made opaque in OpenSSL 1.1.0. 2016-03-31 23:38:36 +03:00
Maxim Dounin 843ffba22f SSL: RSA_generate_key() is deprecated in OpenSSL 1.1.0.
OpenSSL removed support for all 40 and 56 bit ciphers.
2016-03-31 23:38:34 +03:00
Maxim Dounin 8d8330a960 SSL: initialization changes for OpenSSL 1.1.0.
OPENSSL_config() deprecated in OpenSSL 1.1.0.  Additionally,
SSL_library_init(), SSL_load_error_strings() and OpenSSL_add_all_algorithms()
are no longer available if OPENSSL_API_COMPAT is set to 0x10100000L.

The OPENSSL_init_ssl() function is now used instead with appropriate
arguments to trigger the same behaviour.  The configure test changed to
use SSL_CTX_set_options().

Deinitialization now happens automatically in OPENSSL_cleanup() called
via atexit(3), so we no longer call EVP_cleanup() and ENGINE_cleanup()
directly.
2016-03-31 23:38:33 +03:00
Maxim Dounin 9c32be2e19 SSL: get_session callback changed in OpenSSL 1.1.0. 2016-03-31 23:38:32 +03:00
Maxim Dounin 94afc4a899 SSL: guarded error codes not present in OpenSSL 1.1.0. 2016-03-31 23:38:31 +03:00
Maxim Dounin d7b1b3a8e6 SSL: reasonable version for LibreSSL.
LibreSSL defines OPENSSL_VERSION_NUMBER to 0x20000000L, but uses an old
API derived from OpenSSL at the time LibreSSL forked.  As a result, every
version check we use to test for new API elements in newer OpenSSL versions
requires an explicit check for LibreSSL.

To reduce clutter, redefine OPENSSL_VERSION_NUMBER to 0x1000107fL if
LibreSSL is used.  The same is done by FreeBSD port of LibreSSL.
2016-03-31 23:38:29 +03:00
Ruslan Ermilov 4e9e78ba7a Removed the prototype mysql module. 2016-03-31 22:33:26 +03:00
Ruslan Ermilov dd1aa10b1a Fixed ngx_os_signal_process() prototype. 2016-03-31 22:00:33 +03:00
Sergey Kandaurov ce5c9f9c22 Fixed ngx_pid_t formatting in ngx_sprintf() and logging. 2016-03-31 02:34:04 +03:00
Sergey Kandaurov 926014f8f3 Fixed format specifiers in ngx_sprintf(). 2016-03-31 02:34:00 +03:00
Sergey Kandaurov c0c23f246e Fixed logging. 2016-03-31 02:33:57 +03:00
Sergey Kandaurov a7d75a1323 Events: fixed logging. 2016-03-31 02:33:55 +03:00
Sergey Kandaurov 305a9c68f3 Fixed logging with variable field width. 2016-03-31 02:33:53 +03:00
Sergey Kandaurov 8928bbc4e7 Fixed logging in close error handling. 2016-03-31 02:33:50 +03:00
Ruslan Ermilov 09d44cf553 Fixed mistranslated phrase. 2016-03-30 12:07:19 +03:00
Ruslan Ermilov 4ebf9b7c2d Events: fixed test building with eventport on OS X.
Broken in d17f0584006f (1.9.13).
2016-03-30 11:57:28 +03:00
Ruslan Ermilov ef0f309222 Style. 2016-03-30 11:52:16 +03:00
Ruslan Ermilov c17caeba15 Version bump. 2016-03-30 11:52:07 +03:00
Maxim Dounin eca2256156 release-1.9.13 tag 2016-03-29 18:09:30 +03:00
Maxim Dounin d0490711d0 nginx-1.9.13-RELEASE 2016-03-29 18:09:30 +03:00
Maxim Dounin 88fd21ad06 Updated OpenSSL used for win32 builds. 2016-03-29 09:54:11 +03:00
Maxim Dounin ae5f9f67d1 Win32: replaced NGX_EXDEV with more appropriate error code.
Correct error code for NGX_EXDEV on Windows is ERROR_NOT_SAME_DEVICE,
"The system cannot move the file to a different disk drive".

Previously used ERROR_WRONG_DISK is about wrong diskette in the drive and
is not appropriate.

There is no real difference though, as MoveFile() is able to copy files
between disk drives, and will fail with ERROR_ACCESS_DENIED when asked
to copy directories.  The ERROR_NOT_SAME_DEVICE error is only used
by MoveFileEx() when called without the MOVEFILE_COPY_ALLOWED flag.
2016-03-29 09:52:15 +03:00
Maxim Dounin 8a021f91c5 Win32: additional error code NGX_EEXIST_FILE (ticket #910).
On Windows there are two possible error codes which correspond to
the EEXIST error code: ERROR_FILE_EXISTS used by CreateFile(CREATE_NEW),
and ERROR_ALREADY_EXISTS used by CreateDirectory().

MoveFile() seems to use both: ERROR_ALREADY_EXISTS when moving within
one filesystem, and ERROR_FILE_EXISTS when copying a file to a different
drive.
2016-03-29 09:51:46 +03:00
Maxim Dounin 12fbc63dd0 Upstream: proxy_next_upstream non_idempotent.
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-28 19:50:19 +03:00
Maxim Dounin d32d3ed021 Upstream: cached connections now tested against next_upstream.
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-28 19:49:52 +03:00
Ruslan Ermilov b0f78b90b0 Fixed --test-build-*.
Fixes various aspects of --test-build-devpoll, --test-build-eventport, and
--test-build-epoll.

In particular, if --test-build-devpoll was used on Linux, then "devpoll"
event method would be preferred over "epoll".  Also, wrong definitions of
event macros were chosen.
2016-03-28 19:29:18 +03:00
Roman Arutyunyan 4d9896e500 Sub filter: fixed allocation alignment. 2016-03-28 13:35:25 +03:00
Piotr Sikora e6c83d5cf2 Core: allow strings without null-termination in ngx_parse_url().
This fixes buffer over-read while using variables in the "proxy_pass",
"fastcgi_pass", "scgi_pass", and "uwsgi_pass" directives, where result
of string evaluation isn't null-terminated.

Found with MemorySanitizer.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-02-26 17:30:27 -08:00
Roman Arutyunyan d0576e2685 Fixed socket inheritance on reload and binary upgrade.
On nginx reload or binary upgrade, an attempt is made to inherit listen sockets
from the previous configuration.  Previously, no check for socket type was made
and the inherited socket could have the wrong type.  On binary upgrade, socket
type was not detected at all.  Wrong socket type could lead to errors on that
socket due to different logic and unsupported syscalls.  For example, a UDP
socket, inherited as TCP, lead to the following error after arrival of a
datagram: "accept() failed (102: Operation not supported on socket)".
2016-03-25 14:10:38 +03:00
Vladimir Homutov a0c983a073 Stream: additional logging for UDP. 2016-03-18 19:53:22 +03:00
Dmitry Volyntsev 2110c97a3b Win32: fixed build after 384154fc634f. 2016-03-23 18:34:05 +03:00
Roman Arutyunyan 26676b5dea Stream: detect port absence in proxy_pass with IP literal.
This is a clone of http commit 26c127bab5ef.
2016-03-23 17:45:15 +03:00
Dmitry Volyntsev 469c6c0ec7 Resolver: added support for SRV records. 2016-03-23 17:44:36 +03:00
Dmitry Volyntsev c043ab8868 Resolver: do not enable resolve timer if provided timeout is zero. 2016-03-23 17:44:36 +03:00
Dmitry Volyntsev 1fe4d0d9c2 Resolver: introduced valid field in resolver responses.
It hints the amount of time a response could be considered
as valid.
2016-03-23 17:44:36 +03:00
Valentin Bartenev f8a9182cad Core: introduced the NGX_DEBUG_PALLOC macro.
It allows to turn off accumulation of small pool allocations into a big
preallocated chunk of memory.  This is useful for debugging memory access
with sanitizer, since such accumulation can cover buffer overruns from
being detected.
2016-03-23 17:44:04 +03:00
Valentin Bartenev c790cc89e5 Core: use ngx_palloc_small() to allocate ngx_pool_large_t.
This structure cannot be allocated as a large block anyway, otherwise that will
result in infinite recursion, since each large allocation requires to allocate
another ngx_pool_large_t.

The room for the structure is guaranteed by the NGX_MIN_POOL_SIZE constant.
2016-03-23 17:44:04 +03:00
Valentin Bartenev fe909d302b Core: introduced the ngx_palloc_small() function.
It deduplicates some code for allocations from memory pool.
No functional changes.
2016-03-23 17:44:04 +03:00
Valentin Bartenev 89afe36eba Core: moved logging before freeing large blocks of pool.
This fixes use-after-free memory access with enabled debug log
when pool->log is allocated as a large block.
2016-03-23 17:44:04 +03:00
Maxim Dounin f038906190 Backed out server_tokens changes.
Backed out changesets: cf3e75cfa951, 6b72414dfb4f, 602dc42035fe, e5076b96fd01.
2016-03-22 16:58:38 +03:00
Dmitry Volyntsev 270fd4ff89 Cache: fixed slots accounting error introduced in c9d680b00744. 2016-03-23 14:16:31 +03:00
Ruslan Ermilov 450e73892c Reconsidered server_tokens with an empty value.
An empty value will be treated as "off".
2016-03-22 15:52:28 +03:00
Valentin Bartenev a25f676f93 HTTP/2: improved debugging of sending control frames. 2016-03-21 17:04:21 +03:00
Sergey Kandaurov 056f4bb6e0 Events: fixed test building with devpoll and eventport on Linux.
Avoid POLLREMOVE and itimerspec redefinition.
2016-03-21 12:36:36 +03:00
Piotr Sikora 5334fb8ad0 Fix build with -Wmissing-prototypes.
Broken in 5eb4d7541107 (1.9.6), fix somehow missed in 3600bbfb43e3.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-03-18 16:38:08 -07:00
Dmitry Volyntsev 0f1ea31f87 Cache: added watermark to reduce IO load when keys_zone is full.
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-18 15:08:21 +03:00
Dmitry Volyntsev f15ed65dd6 Cache: report error if slab allocator fails during cache loading. 2016-03-18 14:27:30 +03:00
Maxim Dounin daa97e51f1 Threads: writing via threads pools in event pipe.
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-18 06:44:49 +03:00
Maxim Dounin 74b0d3b2fe Threads: offloading of temp files writing to thread pools.
The ngx_thread_write_chain_to_file() function introduced, which
uses ngx_file_t thread_handler, thread_ctx and thread_task fields.
The task context structure (ngx_thread_file_ctx_t) is the same for
both reading and writing, and can be safely shared as long as
operations are serialized.

The task->handler field is now always set (and not only when task is
allocated), as the same task can be used with different handlers.

The thread_write flag is introduced in the ngx_temp_file_t structure
to explicitly enable use of ngx_thread_write_chain_to_file() in
ngx_write_chain_to_temp_file() when supported by caller.

In collaboration with Valentin Bartenev.
2016-03-18 06:44:03 +03:00
Maxim Dounin 133186357e Threads: task pointer stored in ngx_file_t.
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-18 06:43:52 +03:00
Maxim Dounin 7805efe486 Fixed timeouts with threaded sendfile() and subrequests.
If a write event happens after sendfile() but before we've got the
sendfile results in the main thread, this write event will be ignored.
And if no more events will happen, the connection will hang.

Removing the events works in the simple cases, but not always, as
in some cases events are added back by an unrelated code.  E.g.,
the upstream module adds write event in the ngx_http_upstream_init()
to track client aborts.

Fix is to use wev->complete instead.  It is now set to 0 before
a sendfile() task is posted, and it is set to 1 once a write event
happens.  If on completion of the sendfile() task wev->complete is 1,
we know that an event happened while we were executing sendfile(), and
the socket is still ready for writing even if sendfile() did not sent
all the data or returned EAGAIN.
2016-03-18 05:04:45 +03:00
Ruslan Ermilov 36849fed01 Style. 2016-03-16 14:44:41 +03:00
Maxim Dounin 08a147246d Truncation detection in sendfilev() on Solaris.
While sendfilev() is documented to return -1 with EINVAL set
if the file was truncated, at least Solaris 11 silently returns 0,
and this results in CPU hog.  Added a test to complain appropriately
if 0 is returned.
2016-03-15 18:26:59 +03:00
Maxim Dounin f6ae521c59 Truncation detection in sendfile() on Linux.
This addresses connection hangs as observed in ticket #504, and
CPU hogs with "aio threads; sendfile on" as reported in the mailing list,
see http://mailman.nginx.org/pipermail/nginx-ru/2016-March/057638.html.

The alert is identical to one used on FreeBSD.
2016-03-15 18:26:17 +03:00
Roman Arutyunyan 4221836322 Stream: UDP proxy. 2016-01-20 19:52:12 +03:00
Roman Arutyunyan 00bfe729c6 Stream: post first read events from client and upstream.
The main proxy function ngx_stream_proxy_process() can terminate the stream
session.  The code, following it, should check its return code to make sure the
session still exists.  This happens in client and upstream initialization
functions.  Swapping ngx_stream_proxy_process() call with the code, that
follows it, leaves the same problem vice versa.

In future ngx_stream_proxy_process() will call ngx_stream_proxy_next_upstream()
making it too complicated to know if stream session still exists after this
call.

Now ngx_stream_proxy_process() is called from posted event handlers in both
places with no code following it.  The posted event is automatically removed
once session is terminated.
2016-03-15 15:55:23 +03:00
Ruslan Ermilov 094f2d1067 Win32: fixed build after cf3e75cfa951. 2016-03-15 15:15:30 +03:00
Ruslan Ermilov b507ea017e Win32: fixed build after cf3e75cfa951. 2016-03-15 15:10:41 +03:00
Ruslan Ermilov acea4d643d Added variables support to server_tokens.
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-15 13:36:19 +03:00
Valentin Bartenev cf0bfeb78a Fixed handling of EAGAIN with sendfile in threads. 2016-03-14 22:42:35 +03:00
Roman Arutyunyan 45049f2ad6 Events: fixed error logging in devpoll. 2016-03-15 00:04:04 +03:00
Sergey Kandaurov c863295398 Fixed compilation with -Wmissing-prototypes. 2016-03-14 19:23:23 +03:00
Justin Li 2081b8526b Upstream: avoid closing client connection in edge case.
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-08 22:31:55 -05:00
Maxim Dounin 4fad0939ed Upstream: fixed "zero size buf" alerts with cache (ticket #918).
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-10 21:58:03 +03:00
Ruslan Ermilov e2aa474972 Configure: style.
Generate Makefile with not so long lines.
2016-03-10 18:31:05 +03:00
Maxim Dounin bf38e46665 Dynamic modules: do not overwrite old modules on install.
Just using "cp" is incorrect, as it will overwrite old files
possibly used by OS, leading to unexpected effects.  Changed
to "mv + cp", much like used for the main binary.
2016-03-10 16:50:13 +03:00
Ruslan Ermilov 9f0c2d393d Configure: style.
Removed extraneous braces around shell variables.
2016-03-10 10:43:00 +03:00
Maxim Dounin bffa43dede Copy filter: fixed sendfile aio handlers to set ctx->aio.
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-03 21:14:19 +03:00
Maxim Dounin f1bf7f7fef Fixed sendfile in threads (or with aio preload) and subrequests.
If sendfile in threads is used, it is possible that multiple
subrequests will trigger multiple ngx_linux_sendfile_thread() calls,
as operations are only serialized in output chain based on r->aio,
that is, on subrequest level.

This resulted in "task #N already active" alerts, in particular, when
running proxy_store.t with "aio threads; sendfile on;".

Fix is to tolerate duplicate calls, with an additional safety check
that the file is the same as previously used.

The same problem also affects "aio on; sendfile on;" on FreeBSD
(previously known as "aio sendfile;"), where aio->preload_handler()
could be called multiple times due to similar reasons, resulting in
"second aio post" alerts.  Fix is the same as well.

It is also believed that similar problems can arise if a filter
calls the next body filter multiple times for some reason.  These are
mostly theoretical though.
2016-03-03 21:14:12 +03:00
Valentin Bartenev 593957ddf4 Introduced the ngx_chain_to_iovec() function.
It's similar to ngx_output_chain_to_iovec() and uses only preallocated memory.
2016-03-03 18:41:05 +03:00
Valentin Bartenev a52a9c8f2e Request body: moved handling of the last part in the save filter.
No functional changes.
2016-03-01 15:18:07 +03:00
Ruslan Ermilov 8f0bffad5a Dynamic modules: perl. 2016-02-26 14:27:04 +03:00
Ruslan Ermilov 86dc04c396 Dynamic modules: expose the "modules" target. 2016-02-29 18:52:33 +03:00
Ruslan Ermilov 1c95665235 Dynamic modules: removed unnecessary initialization.
It became unnecessary after 85dea406e18f.
2016-02-25 16:29:51 +03:00
Ruslan Ermilov 40750e0549 Dynamic modules: make sure to call config.make for dynamic addons. 2016-02-25 15:22:05 +03:00
Ruslan Ermilov 4585a82504 Version bump. 2016-02-25 16:28:42 +03:00
Maxim Dounin bc26e353f1 release-1.9.12 tag 2016-02-24 17:53:23 +03:00
Maxim Dounin b484da26d0 nginx-1.9.12-RELEASE 2016-02-24 17:53:22 +03:00
Valentin Bartenev 4d4bbb7e99 HTTP/2: implemented per request timeouts (closes #626).
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-24 15:58:07 +03:00
Valentin Bartenev 0585f02e65 HTTP/2: always use temporary pool for processing headers.
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-24 16:05:47 +03:00
Valentin Bartenev ad888d257d HTTP/2: cleaned up state while closing stream.
Without this the state might keep pointing to already closed stream.
2016-02-24 16:05:46 +03:00
Valentin Bartenev dec9580896 Fixed buffer over-read while logging invalid request headers.
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-24 16:01:23 +03:00
Maxim Dounin eca5b165f4 Configure: added "build" target.
The "build" target introduced to do all build-related tasks, and
it is now used in Makefile and in objs/Makefile as a dependency for
the "install" target.

In particular, this resolves problems as observed with dynamic modules
by people trying to do "make install" without calling "make" first.
2016-02-19 18:13:54 +03:00
Maxim Dounin 3ae8bf4e65 SSL: avoid calling SSL_shutdown() during handshake (ticket #901).
This fixes "called a function you should not call" and
"shutdown while in init" errors as observed with OpenSSL 1.0.2f
due to changes in how OpenSSL handles SSL_shutdown() during
SSL handshakes.
2016-02-19 17:27:30 +03:00
Maxim Dounin 44ed32516f SSL: fixed SSL_shutdown() comment. 2016-02-19 17:27:23 +03:00
Ruslan Ermilov cc859966b8 Headers filter: fixed "add_header ... '' always".
The "always" parameter was ignored if the header value was empty.
2016-02-18 15:49:11 +03:00
Sergey Kandaurov 8794197116 Configure: skip building OpenSSL documentation to conserve time.
The install_sw target first appeared in OpenSSL 0.9.7e and is documented since
OpenSSL 1.0.0 as the way to install the OpenSSL software without documentation.
2016-02-19 13:31:55 +03:00
Ruslan Ermilov 714324fd0c Configure: fixed static nginx build with OpenSSL (ticket #903).
Before 7142b04337d6, it was possible to build the OpenSSL library
along with nginx, and link nginx statically with this library
(--with-openssl=DIR --with-ld-opt=-static --with-http_ssl_module).
This was broken on Linux by not adding -ldl after -lcrypto.

The fix also makes it possible to link nginx statically on Linux
with the system OpenSSL library, which never worked before.
2016-02-18 11:39:57 +03:00
Vladimir Homutov 634f54bab0 Core: added support for more than 64 CPUs in worker_cpu_affinity. 2016-02-18 13:58:49 +03:00
Valentin Bartenev 1a639c1ad3 HTTP/2: added debug logging of response headers.
Because of HPACK compression it's hard to see what headers are actually
sent by the server.
2016-02-16 17:49:14 +03:00
Valentin Bartenev cfdc3914b0 HTTP/2: use local pointer instead of r->connection.
No functional changes.
2016-02-16 17:49:14 +03:00
Maxim Dounin 679b0b6db6 Core: improved logging on invalid NGINX variable (ticket #900). 2016-02-15 17:41:52 +03:00
Maxim Dounin ae9ca236ea Updated OpenSSL used for win32 builds. 2016-02-13 07:28:14 +03:00
Maxim Dounin a57c77bd5e Win32: simplified and improved handling of MSVC versions.
Now we always set NGX_CC_NAME to "msvc", and additionally test compiler
version as reported by "cl" in auto/cc/msvc (the same version is also
available via the _MSC_VER define).  In particular, this approach allows
to properly check for C99 variadic macros support, which previously was
not used with MSVC versions not explicitly recognized.

Now unneeded wildcards in NGX_CC_NAME tests for msvc removed accordingly,
as well as unused wildcards for owc and icc.
2016-02-13 06:47:34 +03:00
Valentin Bartenev 8d9474e6d9 HTTP/2: fixed undefined behavior in ngx_http_v2_huff_encode().
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-12 16:36:20 +03:00
Valentin Bartenev 63f3238ef8 HTTP/2: implemented HPACK Huffman encoding for response headers.
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-11 15:35:36 +03:00
Ruslan Ermilov bf1f565389 Dynamic modules: fixed a version mismatch message (ticket #898).
Based on a patch by Takashi Takizawa.
2016-02-11 18:46:46 +03:00
Roman Arutyunyan 1d184e56c3 Stream: initialize variable right before using it. 2016-02-11 14:20:26 +03:00
Roman Arutyunyan d220dabbe3 Stream: removed useless typedef. 2016-02-11 14:20:22 +03:00
Ruslan Ermilov f6b3dbf777 Dynamic modules: added auth_basic module libs via ngx_module_libs=. 2016-02-10 11:36:25 +03:00
Piotr Sikora aa2b57e107 Core: ngx_module_t compatibility with C++.
Changes to NGX_MODULE_V1 and ngx_module_t in 85dea406e18f (1.9.11)
broke all modules written in C++, because ISO C++11 does not allow
conversion from string literal to char *.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-02-09 16:31:26 -08:00
Maxim Dounin 6fb1ae5104 Version bump. 2016-02-10 06:23:34 +03:00
Maxim Dounin 470d224160 release-1.9.11 tag 2016-02-09 17:11:57 +03:00
Maxim Dounin c7a3200e24 nginx-1.9.11-RELEASE 2016-02-09 17:11:56 +03:00
Maxim Dounin ffb30705a0 Dynamic modules: NGX_STREAM define removed.
It's not used and contradicts the idea of dynamic loading.
2016-02-08 18:02:04 +03:00
Valentin Bartenev e35b6055b6 Dynamic modules: added dlsym() to configure test.
It appears that AddressSanitizer in GCC 5 intercepts dlopen() and dlclose()
but not dlsym().
2016-02-05 21:48:25 +03:00
Ruslan Ermilov 16de1db67f Dynamic modules: fixed a copy-n-paste error. 2016-02-05 14:02:54 +03:00
Maxim Dounin f3e79434f5 Dynamic modules.
The auto/module script is extended to understand ngx_module_link=DYNAMIC.
When set, it links the module as a shared object rather than statically
into nginx binary.  The module can later be loaded using the "load_module"
directive.

New auto/module parameter ngx_module_order allows to define module loading
order in complex cases.  By default the order is set based on ngx_module_type.

3rd party modules can be compiled dynamically using the --add-dynamic-module
configure option, which will preset ngx_module_link to "DYNAMIC" before
calling the module config script.

Win32 support is rudimentary, and only works when using MinGW gcc (which
is able to handle exports/imports automatically).

In collaboration with Ruslan Ermilov.
2016-02-04 20:25:29 +03:00
Maxim Dounin ab19074ae2 Dynamic modules: auto/module script.
This script simplifies configuration of additional modules,
including 3rd party ones.  The script is extensible, and
will be used to introduce dynamic linking of modules in upcoming
changes.

3rd party module config scripts are called with ngx_module_link
preset to "ADDON" - this allows config scripts to call auto/module
without ngx_module_link explicitly defined, as well as testing if
new interface is in place if compatibility with older nginx versions
is desired.

In collaboration with Ruslan Ermilov.
2016-02-04 18:30:21 +03:00
Maxim Dounin a71722fa89 Dynamic modules: introduced HTTP_INIT_FILTER_MODULES.
Additionally, HTTP_HEADERS_FILTER_MODULE now added to HTTP_FILTER_MODULES.
This avoids explict use of modules at the later stages, now only module
lists are used.  This will be needed in later patches.
2016-02-04 18:30:21 +03:00
Maxim Dounin 875356ff27 Dynamic modules: dlopen() support. 2016-02-04 18:30:21 +03:00
Maxim Dounin 603dbfcbb9 Dynamic modules: changed ngx_modules to cycle->modules. 2016-02-04 18:30:21 +03:00
Maxim Dounin b1c24662c3 Dynamic modules: moved module-related stuff to separate files. 2016-02-04 18:30:21 +03:00
Valentin Bartenev 46b4f57048 HTTP/2: fixed possible buffer overrun (ticket #893).
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-04 18:01:04 +03:00
Valentin Bartenev f8eb17c90b HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION. 2016-02-02 16:33:55 +03:00
Valentin Bartenev 4022f45d85 HTTP/2: fixed request length accounting.
Now it includes not only the received body size,
but the size of headers block as well.
2016-02-02 16:33:55 +03:00
Valentin Bartenev 655649e737 HTTP/2: fixed excessive memory allocation for pool cleanup. 2016-02-02 16:33:55 +03:00
Valentin Bartenev 5417403c6f HTTP/2: removed unused field from ngx_http_v2_stream_t. 2016-02-02 16:33:55 +03:00
Ruslan Ermilov 63f4f9e03d Resolver: style.
Use the original query name in error and debug messages when
processing PTR responses.
2015-12-17 17:30:22 +03:00
Ruslan Ermilov d64daf0338 Resolver: improved PTR response processing.
The previous code only parsed the first answer, without checking its
type, and required a compressed RR name.

The new code checks the RR type, supports responses with multiple
answers, and doesn't require the RR name to be compressed.

This has a side effect in limited support of CNAME.  If a response
includes both CNAME and PTR RRs, like when recursion is enabled on
the server, PTR RR is handled.

Full CNAME support in PTR response is not implemented in this change.
2015-12-17 17:21:16 +03:00
Ruslan Ermilov fa3295f571 Resolver: style.
Renamed argument in ngx_resolver_process_a() for consistency.
2015-12-17 17:21:12 +03:00
Roman Arutyunyan 40e70a26b3 Resolver: free TCP buffers on resolver cleanup. 2016-02-02 13:42:55 +03:00
Ruslan Ermilov 1199c09e22 Resolver: fixed possible resource leak introduced in 5a16d40c63de.
Found by Coverity (CID 1351175).
2016-02-02 11:35:19 +03:00
Roman Arutyunyan 766b190779 Resolver: TCP support.
Resend DNS query over TCP once UDP response came truncated.
2016-01-28 15:28:20 +03:00
Roman Arutyunyan 1e17ee9366 Resolver: per-request DNS server balancer.
Previously, a global server balancer was used to assign the next DNS server to
send a query to.  That could lead to a non-uniform distribution of servers per
request.  A request could be assigned to the same dead server several times in a
row and wait longer for a valid server or even time out without being processed.

Now each query is sent to all servers sequentially in a circle until a
response is received or timeout expires.  Initial server for each request is
still globally balanced.
2016-01-28 15:28:20 +03:00
Roman Arutyunyan f76fcebd3c Resolver: renamed UDP-specific structures, fields and variables.
They will be used for TCP connections as well.
2016-01-28 15:28:20 +03:00
Roman Arutyunyan 7fe05405ec Resolver: removed unused field from ngx_resolver_ctx_t. 2016-01-28 15:28:19 +03:00
Roman Arutyunyan 88488854ac Version bump. 2016-01-28 15:25:58 +03:00
Maxim Dounin 791da2265c release-1.9.10 tag 2016-01-26 17:27:41 +03:00
Maxim Dounin 8d9e3ff560 nginx-1.9.10-RELEASE 2016-01-26 17:27:40 +03:00
Ruslan Ermilov a981438e14 Resolver: limited CNAME recursion.
Previously, the recursion was only limited for cached responses.
2016-01-26 16:47:14 +03:00
Roman Arutyunyan 4fabf0e411 Resolver: fixed use-after-free memory accesses with CNAME.
When several requests were waiting for a response, then after getting
a CNAME response only the last request's context had the name updated.
Contexts of other requests had the wrong name.  This name was used by
ngx_resolve_name_done() to find the node to remove the request context
from.  When the name was wrong, the request could not be properly
cancelled, its context was freed but stayed linked to the node's waiting
list.  This happened e.g. when the first request was aborted or timed
out before the resolving completed.  When it completed, this triggered
a use-after-free memory access by calling ctx->handler of already freed
request context.  The bug manifests itself by
"could not cancel <name> resolving" alerts in error_log.

When a request was responded with a CNAME, the request context kept
the pointer to the original node's rn->u.cname.  If the original node
expired before the resolving timed out or completed with an error,
this would trigger a use-after-free memory access via ctx->name in
ctx->handler().

The fix is to keep ctx->name unmodified.  The name from context
is no longer used by ngx_resolve_name_done().  Instead, we now keep
the pointer to resolver node to which this request is linked.
Keeping the original name intact also improves logging.
2016-01-26 16:46:59 +03:00
Roman Arutyunyan 13b84923fb Resolver: changed the ngx_resolver_create_*_query() arguments.
No functional changes.

This is needed by the following change.
2016-01-26 16:46:48 +03:00
Ruslan Ermilov 60334da462 Resolver: fixed CNAME processing for several requests.
When several requests were waiting for a response, then after getting
a CNAME response only the last request was properly processed, while
others were left waiting.
2016-01-26 16:46:38 +03:00
Ruslan Ermilov 1fdddd2818 Resolver: fixed crashes in timeout handler.
If one or more requests were waiting for a response, then after
getting a CNAME response, the timeout event on the first request
remained active, pointing to the wrong node with an empty
rn->waiting list, and that could cause either null pointer
dereference or use-after-free memory access if this timeout
expired.

If several requests were waiting for a response, and the first
request terminated (e.g., due to client closing a connection),
other requests were left without a timeout and could potentially
wait indefinitely.

This is fixed by introducing per-request independent timeouts.
This change also reverts 954867a2f0a6 and 5004210e8c78.
2016-01-26 16:46:31 +03:00
Roman Arutyunyan f71b88a069 Resolver: fixed possible segmentation fault on DNS format error. 2016-01-26 16:46:18 +03:00
Valentin Bartenev de25471397 Request body: removed surplus assigment, no functional changes.
Setting rb->bufs to NULL is surplus after ngx_http_write_request_body()
has returned NGX_OK.
2016-01-12 19:19:07 +03:00
Maxim Dounin 8fd06cda2b Core: worker_cpu_affinity auto.
If enabled, workers are bound to available CPUs, each worker to once CPU
in order.  If there are more workers than available CPUs, remaining are
bound in a loop, starting again from the first available CPU.

The optional mask parameter defines which CPUs are available for automatic
binding.

In collaboration with Vladimir Homutov.
2016-01-11 19:23:17 +03:00
Maxim Dounin b6c46715b2 Upstream: fixed changing method on X-Accel-Redirect.
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.
2016-01-11 19:08:12 +03:00
Ruslan Ermilov 61b090dbb4 Year 2016. 2016-01-11 10:53:49 +03:00
Maxim Dounin 3a7a65ec15 Upstream: don't keep connections on early responses (ticket #669). 2015-12-17 16:39:15 +03:00
Maxim Dounin 5f0b40f7cd Fixed PROXY protocol on IPv6 sockets (ticket #858). 2015-12-17 16:39:02 +03:00
Maxim Dounin d6a8c66c28 Version bump. 2015-12-17 16:38:51 +03:00
Ruslan Ermilov 43b08a6ef6 Fixed a typo. 2015-12-12 10:32:58 +03:00
Maxim Dounin 663de0936a release-1.9.9 tag 2015-12-09 17:47:21 +03:00
Maxim Dounin c5ee4e6207 nginx-1.9.9-RELEASE 2015-12-09 17:47:20 +03:00
Ruslan Ermilov 6eb2718f6c Fixed fastcgi_pass with UNIX socket and variables (ticket #855).
This was broken in a93345ee8f52 (1.9.8).
2015-12-09 16:26:59 +03:00
Ruslan Ermilov be9e9bbcdb Version bump. 2015-12-09 14:41:16 +03:00
Maxim Dounin da9c382957 release-1.9.8 tag 2015-12-08 18:16:52 +03:00
Maxim Dounin 722a3c0bfe nginx-1.9.8-RELEASE 2015-12-08 18:16:51 +03:00
Roman Arutyunyan 0c2ce9c2ff Slice filter: terminate first slice with last_in_chain flag.
This flag makes sub filter flush buffered data and optimizes allocation in copy
filter.
2015-12-08 17:39:56 +03:00
Roman Arutyunyan 63944bff63 Slice filter: never run subrequests when main request is buffered.
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-08 17:39:56 +03:00
Sergey Kandaurov 0e00eb3b3f SSL: fixed possible segfault on renegotiation (ticket #845).
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-08 16:59:43 +03:00
Maxim Dounin e0402dd4dc Updated OpenSSL and PCRE used for win32 builds. 2015-12-07 20:09:34 +03:00
Maxim Dounin d689366e50 Added slice module to win32 builds. 2015-12-07 20:08:13 +03:00
Roman Arutyunyan 2ed10244f9 Slice filter.
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-07 16:30:48 +03:00
Roman Arutyunyan 1e21053a09 Upstream: fill r->headers_out.content_range from upstream response. 2015-12-07 16:30:47 +03:00
Piotr Sikora ea5fc7b618 Core: fix typo in error message.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2015-12-02 19:17:19 -08:00
Maxim Dounin ebacb0fe52 Style: NGX_PTR_SIZE replaced with sizeof(void *).
The NGX_PTR_SIZE macro is only needed in preprocessor directives where
it's not possible to use sizeof().
2015-12-03 20:06:45 +03:00
Maxim Dounin ad8f3d644a Style. 2015-12-02 01:06:54 +03:00
Ruslan Ermilov 1cca912b47 Stop emulating a space character after r->method_name.
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-30 12:54:01 +03:00
Ruslan Ermilov 304dd9dce1 Proxy: improved code readability.
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.
2015-11-06 15:21:51 +03:00
Ruslan Ermilov 75fe62b8f8 Reduced the number of GET method constants. 2015-11-30 12:04:35 +03:00
Valentin Bartenev 651359b8f0 Increased the default "connection_pool_size" on 64-bit platforms.
The previous default of 256 bytes isn't enough and results in two
allocations on each accepted connection, which is suboptimal.
2015-11-30 16:27:33 +03:00
Ruslan Ermilov a299e7cfeb Configure: improved workaround for system perl on OS X.
The workaround from baf2816d556d stopped to work because the order of
"-arch x86_64" and "-arch i386" has changed.
2015-11-30 12:04:29 +03:00
Ruslan Ermilov 9fb313832a Configure: removed comment obsolete in 3b763d36e055. 2015-11-30 19:01:53 +03:00
Ruslan Ermilov 835680c27e Style: unified request method checks. 2015-11-06 15:22:43 +03:00
Ruslan Ermilov 09bfafaaa0 Core: enabled "include" inside http upstreams (ticket #635).
The directive already works inside stream upstream blocks.
2015-11-23 12:40:19 +03:00
Maxim Dounin 4c7a0d6432 Configure: fixed using OpenSSL include paths. 2015-11-23 22:48:31 +03:00
Ruslan Ermilov 39d42c4e11 Upstream: fixed "no port" detection in evaluated upstreams.
If an upstream with variables evaluated to address without a port,
then instead of a "no port in upstream" error an attempt was made
to connect() which failed with EADDRNOTAVAIL.
2015-11-21 10:44:07 +03:00
Maxim Dounin 19ea8182c5 Missing "variable" word added. 2015-11-17 19:41:39 +03:00
Valentin Bartenev 3ee007a0fd Used the pwritev() syscall for writing files where possible.
It is more effective, because it doesn't require a separate lseek().
2015-11-17 19:01:41 +03:00
Valentin Bartenev 9d32ebe3cd Moved file writev() handling code to a separate function.
No functional changes.
2015-11-17 19:01:41 +03:00
Valentin Bartenev b9b8e6d1a5 Handled EINTR from write() and pwrite() syscalls.
This is in addition to 6fce16b1fc10.
2015-11-17 19:01:41 +03:00
Valentin Bartenev e608ba0a34 Adjusted file->sys_offset after the write() syscall.
This fixes suboptimal behavior caused by surplus lseek() for sequential writes
on systems without pwrite().  A consecutive read after write might result in an
error on systems without pread() and pwrite().

Fortunately, at the moment there are no widely used systems without these
syscalls.
2015-11-17 19:01:41 +03:00
Valentin Bartenev 67a3fbcd94 Version bump. 2015-11-17 19:01:41 +03:00
Maxim Dounin 859ad71970 release-1.9.7 tag 2015-11-17 17:50:57 +03:00
Maxim Dounin 616bc1fb5e nginx-1.9.7-RELEASE 2015-11-17 17:50:56 +03:00
Ruslan Ermilov f1a290ab67 Realip: the $realip_remote_addr variable. 2015-11-16 16:02:02 +03:00
Valentin Bartenev 0734a71e0f HTTP/2: reused HEADERS and CONTINUATION frames buffers. 2015-11-13 20:10:50 +03:00
Valentin Bartenev fa873028dc HTTP/2: fixed handling of output HEADERS frames.
The HEADERS frame is always represented by more than one buffer since
b930e598a199, but the handling code hasn't been adjusted.

Only the first buffer of HEADERS frame was checked and if it had been
sent while others had not, the rest of the frame was dropped, resulting
in broken connection.

Before b930e598a199, the problem could only be seen in case of HEADERS
frame with CONTINUATION.
2015-11-13 20:10:50 +03:00
Valentin Bartenev e617d33457 HTTP/2: fixed invalid headers handling (ticket #831).
The r->invalid_header flag wasn't reset once an invalid header appeared in a
request, resulting in all subsequent headers in the request were also marked
as invalid.
2015-11-13 20:10:50 +03:00
Roman Arutyunyan 0f487ffad2 Upstream: proxy_cache_convert_head directive.
The directive toggles conversion of HEAD to GET for cacheable proxy requests.
When disabled, $request_method must be added to cache key for consistency.
By default, HEAD is converted to GET as before.
2015-11-11 15:47:30 +03:00
Valentin Bartenev c3f11ea40a SSL: only select HTTP/2 using NPN if "http2" is enabled.
OpenSSL doesn't check if the negotiated protocol has been announced.
As a result, the client might force using HTTP/2 even if it wasn't
enabled in configuration.
2015-11-05 15:01:09 +03:00
Valentin Bartenev 44482aa024 HTTP/2: backed out 16905ecbb49e (ticket #822).
It caused inconsistency between setting "in_closed" flag and the moment when
the last DATA frame was actually read.  As a result, the body buffer might not
be initialized properly in ngx_http_v2_init_request_body(), which led to a
segmentation fault in ngx_http_v2_state_read_data().  Also it might cause
start processing of incomplete body.

This issue could be triggered when the processing of a request was delayed,
e.g. in the limit_req or auth_request modules.
2015-11-05 15:01:01 +03:00
Maxim Dounin cabe07bb9f Fixed ngx_parse_time() out of bounds access (ticket #821).
The code failed to ensure that "s" is within the buffer passed for
parsing when checking for "ms", and this resulted in unexpected errors when
parsing non-null-terminated strings with trailing "m".  The bug manifested
itself when the expires directive was used with variables.

Found by Roman Arutyunyan.
2015-10-30 21:43:30 +03:00
Vladimir Homutov 3a71a103c2 Syslog: added "nohostname" option.
The option disables sending hostname in the syslog message header.  This is
useful with syslog daemons that do not expect it (tickets #677 and #783).
2015-10-26 19:06:42 +03:00
Valentin Bartenev 0aa417802d HTTP/2: changed behavior of the "http2_max_field_size" directive.
Now it limits only the maximum length of literal string (either raw or
compressed) in HPACK request header fields.  It's easier to understand
and to describe in the documentation.
2015-10-27 23:16:35 +03:00
Valentin Bartenev 23ad825c28 HTTP/2: fixed spelling. 2015-10-27 23:16:35 +03:00
Valentin Bartenev 2b7ee6d35e Version bump. 2015-10-27 23:16:29 +03:00
Maxim Dounin 29f653e5c2 release-1.9.6 tag 2015-10-27 16:47:30 +03:00
Maxim Dounin 5174369d1d nginx-1.9.6-RELEASE 2015-10-27 16:47:29 +03:00
Valentin Bartenev 97a84ab9d2 HTTP/2: simplified checking the END_STREAM flag.
No functional changes.
2015-10-26 17:46:28 +03:00
Valentin Bartenev 48b21258ec HTTP/2: improved the ngx_http_v2_integer_octets(v) macro.
Previously, it didn't work well for 0, 127, and 128, returning less than needed.
2015-10-26 17:46:16 +03:00
Valentin Bartenev 8b87aa2692 HTTP/2: fixed the NGX_HTTP_V2_MAX_FIELD macro. 2015-10-26 17:46:13 +03:00
Valentin Bartenev 041cad9f16 HTTP/2: fixed splitting of response headers on CONTINUATION frames.
Previous code has been based on assumption that the header block can only be
splitted at the borders of individual headers.  That wasn't the case and might
result in emitting frames bigger than the frame size limit.

The current approach is to split header blocks by the frame size limit.
2015-09-28 02:32:44 +03:00
Valentin Bartenev 62d9a9e8f1 HTTP/2: introduced NGX_HTTP_V2_ENCODE_* macros.
No functional changes.
2015-10-26 17:43:08 +03:00
Valentin Bartenev 898e258a1b HTTP/2: simplified producing of the Last-Modified header. 2015-10-26 17:43:08 +03:00
Valentin Bartenev 1815efe524 HTTP/2: fixed header block size calculation. 2015-10-26 17:43:08 +03:00
Piotr Sikora 583c6aa63f HTTP/2: fix handling of connection errors.
Previously, nginx worker would crash because of a double free
if client disconnected or timed out before sending all headers.

Found with afl-fuzz.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2015-10-01 20:25:55 -07:00
Piotr Sikora 22bb5edafa HTTP/2: fix indirect reprioritization.
Previously, streams that were indirectly reprioritized (either because of
a new exclusive dependency on their parent or because of removal of their
parent from the dependency tree), didn't have their pointer to the parent
node updated.

This broke detection of circular dependencies and, as a result, nginx
worker would crash due to stack overflow whenever such dependency was
introduced.

Found with afl-fuzz.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2015-10-01 20:25:55 -07:00
Piotr Sikora fad83fee17 HTTP/2: reject self-dependent streams.
Per RFC7540, a stream cannot depend on itself.

Previously, this requirement was enforced on PRIORITY frames, but not on
HEADERS frames and due to the implementation details nginx worker would
crash (stack overflow) while opening self-dependent stream.

Found with afl-fuzz.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2015-10-01 20:25:55 -07:00
Piotr Sikora 2d725ea46b Core: read/write locks are also required by the Stream module.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2015-10-23 18:21:33 -07:00
Piotr Sikora 457745f5cb Configure: style fixes for autoconf.err.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2015-10-23 18:21:33 -07:00
Valentin Bartenev b220f3ba28 HTTP/2: improved error handling while parsing integers.
The case when an integer is out of frame bounds should be checked first
as a more accurate error.
2015-10-20 21:28:38 +03:00
Ruslan Ermilov 843a1d3982 HTTP/2: improved HPACK integer parsing code readability.
No functional changes.
2015-10-20 21:26:38 +03:00
Maxim Dounin c9b6aed334 Win32: timer_resolution now ignored with select.
As setitimer() isn't available on Windows, time wasn't updated at all
if timer_resolution was used with the select event method.  Fix is
to ignore timer_resolution in such cases.
2015-10-20 18:16:18 +03:00
Kouhei Sutou c59a392bc6 Win32: fixed build with MinGW and MinGW-w64 gcc.
This change fixes the "comparison between signed and unsigned integer
expressions" warning, introduced in 5e6142609e48 (1.9.4).
2015-10-17 21:41:02 +09:00
Maxim Dounin 3573c29f25 Style: unneeded casts of cf->args->elts removed. 2015-10-19 23:04:49 +03:00
Maxim Dounin 02f5632f86 Fixed variables prefix comparison.
Variable names are not null-terminated, so using ngx_strncmp() without
extra length checks is wrong.

Reported by Markus Linnala,
http://mailman.nginx.org/pipermail/nginx-devel/2015-August/007211.html.
2015-10-19 21:28:17 +03:00
Maxim Dounin 81247e6203 Fixed handling of empty root.
Previously, a configuration with "root" set to an empty string tried test
a character at clcf->root.data[-1].  Additional test added to make sure
this won't happen.

Reported by Markus Linnala, see
http://mailman.nginx.org/pipermail/nginx-devel/2015-August/007210.html.
2015-10-19 21:28:02 +03:00
Maxim Dounin e80d9b9bf7 SSL: preserve default server context in connection (ticket #235).
This context is needed for shared sessions cache to work in configurations
with multiple virtual servers sharing the same port.  Unfortunately, OpenSSL
does not provide an API to access the session context, thus storing it
separately.

In collaboration with Vladimir Homutov.
2015-10-19 21:22:38 +03:00
Valentin Bartenev 22ffc8e33e HTTP/2: fixed parsing of literal header fields without indexing. 2015-10-19 16:16:47 +03:00
Vladimir Homutov 962f253d1b SSL: handled long string truncation in ngx_ssl_error().
If no space left in buffer after adding formatting symbols, error message
could be left without terminating null.  The fix is to output message using
actual length.
2015-10-07 22:19:42 +03:00
Ruslan Ermilov 3aaef64d3d Stream: delete proxy connection timer after SSL handshake.
The timer remained active and could drop active SSL connection.
2015-10-06 08:57:09 +03:00
Kurtis Nusbaum 9a1e196463 Extract out version info function.
The code for displaying version info and configuration info seemed to be
cluttering up the main function. I was finding it hard to read main. This
extracts out all of the logic for displaying version and configuration info
into its own function, thus making main easier to read.
2015-07-12 08:31:38 -07:00
Valentin Bartenev 4a3cb92154 HTTP/2: fixed $server_protocol value (ticket #800). 2015-09-28 20:02:05 +03:00
Maxim Dounin 666a799be3 SSL: compatibility with OpenSSL master branch.
RAND_pseudo_bytes() is deprecated in the OpenSSL master branch, so the only
use was changed to RAND_bytes().  Access to internal structures is no longer
possible, so now we don't try to set SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS even
if it's defined.
2015-09-24 17:19:08 +03:00
Maxim Dounin 74ee2d37ed Version bump. 2015-09-24 17:18:42 +03:00
Maxim Dounin 0bcef665e2 release-1.9.5 tag 2015-09-22 17:36:22 +03:00
Maxim Dounin 1cbf452472 nginx-1.9.5-RELEASE 2015-09-22 17:36:21 +03:00
Maxim Dounin f24f989a4a Style. 2015-09-22 17:09:50 +03:00
Valentin Bartenev ca7adff9cd Increased the default number of output buffers.
Since an output buffer can only be used for either reading or sending, small
amounts of data left from the previous operation (due to some limits) must be
sent before nginx will be able to read further into the buffer.  Using only
one output buffer can result in suboptimal behavior that manifests itself in
forming and sending too small chunks of data.  This is particularly painful
with SPDY (or HTTP/2) where each such chunk needs to be prefixed with some
header.

The default flow-control window in HTTP/2 is 64k minus one bytes.  With one
32k output buffer this results is one byte left after exhausting the window.
With two 32k buffers the data will be read into the second free buffer before
sending, thus the minimum output is increased to 32k + 1 bytes which is much
better.
2015-09-15 17:49:15 +03:00
Valentin Bartenev feda48d445 HTTP/2: fixed header block parsing with CONTINUATION frames (#792).
It appears that the CONTINUATION frames don't need to be aligned to bounds of
individual headers.
2015-09-22 01:40:04 +03:00
Valentin Bartenev de0a8b77bd HTTP/2: fixed HPACK header field parsing. 2015-09-22 01:40:04 +03:00
Roman Arutyunyan c306e79847 Sub filter: fixed initialization in http{} level (ticket #791).
If sub_filter directive was only specified at http{} level, sub filter
internal data remained uninitialized.  That would lead to a crash in runtime.
2015-09-21 23:08:34 +03:00
Valentin Bartenev 02f6fb29a2 The HTTP/2 implementation (RFC 7240, 7241).
The SPDY support is removed, as it's incompatible with the new module.
2015-09-11 20:13:06 +03:00
Maxim Dounin 1119b74df7 Core: fixed segfault with null in wildcard hash names.
A configuration like

    server { server_name .foo^@; }
    server { server_name .foo; }

resulted in a segmentation fault during construction of server names hash.

Reported by Markus Linnala.
Found with afl-fuzz.
2015-09-11 17:04:40 +03:00
Maxim Dounin b20e7137ef Fixed segfault with incorrect location nesting.
A configuration with a named location inside a zero-length prefix
or regex location used to trigger a segmentation fault, as
ngx_http_core_location() failed to properly detect if a nested location
was created.  Example configuration to reproduce the problem:

    location "" {
        location @foo {}
    }

Fix is to not rely on a parent location name length, but rather check
command type we are currently parsing.

Identical fix is also applied to ngx_http_rewrite_if(), which used to
incorrectly assume the "if" directive is on server{} level in such
locations.

Reported by Markus Linnala.
Found with afl-fuzz.
2015-09-11 17:04:04 +03:00
Maxim Dounin c9edcde026 Cache: check the whole cache key in addition to hashes.
This prevents a potential attack that discloses cached data if an attacker
will be able to craft a hash collision between some cache key the attacker
is allowed to access and another cache key with protected data.

See http://mailman.nginx.org/pipermail/nginx-devel/2015-September/007288.html.

Thanks to Gena Makhomed and Sergey Brester.
2015-09-11 17:03:56 +03:00
Roman Arutyunyan fc158e945d Upstream: fixed cache send error handling.
The value of NGX_ERROR, returned from filter handlers, was treated as a generic
upstream error and changed to NGX_HTTP_INTERNAL_SERVER_ERROR before calling
ngx_http_finalize_request().  This resulted in "header already sent" alert
if header was already sent in filter handlers.

The problem appeared in 54e9b83d00f0 (1.7.5).
2015-09-03 15:09:21 +03:00
Valentin Bartenev fa2ba037d7 Fixed building --with-debug, broken by 6fce16b1fc10. 2015-09-02 19:45:40 +03:00
Valentin Bartenev 7dd6ec0ac2 Writing to some file systems can be interrupted.
At least such behavior was observed with CephFS, see:
http://mailman.nginx.org/pipermail/nginx/2015-July/048188.html.
2015-09-02 19:26:40 +03:00
Valentin Bartenev 6af49e71e9 Decreased the NGX_HTTP_MAX_SUBREQUESTS limit.
There is no much sense in such a big value since its semantics
has been changed in 06e850859a26 to limit recursive subrequests.
2015-08-31 23:26:33 +03:00
Valentin Bartenev 9d137c0885 Added protection against r->main->count overflow by subrequests.
This overflow has become possible after the change in 06e850859a26,
since concurrent subrequests are not limited now and each of them is
counted in r->main->count.
2015-08-31 23:25:16 +03:00
Valentin Bartenev 08108d7501 Limit recursive subrequests instead of simultaneous. 2015-08-23 21:03:32 +03:00
Valentin Bartenev 9952518659 Version bump. 2015-08-23 21:03:29 +03:00
Maxim Dounin eb011ca407 release-1.9.4 tag 2015-08-18 18:16:17 +03:00
Maxim Dounin a3255add74 nginx-1.9.4-RELEASE 2015-08-18 18:16:17 +03:00
Maxim Dounin befc4bff20 Perl: prototyping behavior explicitly specified.
When prototyping behavior is not explicitly specified, xsubpp emits
a message to stderr asking to do so (see ticket #608).
2015-08-18 16:26:18 +03:00
Maxim Dounin 055ba52508 Perl: fixed warning about "sep" may be used uninitialized. 2015-08-18 16:26:05 +03:00
Maxim Dounin e37a514ae4 Updated OpenSSL used for win32 builds.
Note that as of OpenSSL 1.0.0, the "ms\do_ms" script (previously documented
to be used if one doesn't want to use the assembly language files) tries to
use MASM.  Additionally, OpenSSL 1.0.2 finally broke MASM support.  To fix
this, we now explicitly use "no-asm" in OpenSSL options.
2015-08-17 18:09:20 +03:00
Maxim Dounin 06a54b3a61 Win32: MSVC 2015 compatibility.
Resolved warnings about declarations that hide previous local declarations.
Warnings about WSASocketA() being deprecated resolved by explicit use of
WSASocketW() instead of WSASocket().  When compiling without IPv6 support,
WinSock deprecated warnings are disabled to allow use of gethostbyname().
2015-08-17 18:09:17 +03:00
Dmitry Volyntsev 83e24dfb14 Sub filter: support of variables in the strings to replace. 2015-08-17 17:42:02 +03:00
Dmitry Volyntsev c7ce35a151 Sub filter: support of multiple strings to replace. 2015-08-17 17:42:02 +03:00
Maxim Dounin a27f0af067 Fixed wrong URI after try_files in nested location (ticket #97).
The following configuration with alias, nested location and try_files
resulted in wrong file being used.  Request "/foo/test.gif" tried to
use "/tmp//foo/test.gif" instead of "/tmp/test.gif":

    location /foo/ {
        alias /tmp/;
        location ~ gif {
            try_files $uri =405;
        }
    }

Additionally, rev. c985d90a8d1f introduced a regression if
the "/tmp//foo/test.gif" file was found (ticket #768).  Resulting URI
was set to "gif?/foo/test.gif", as the code used clcf->name of current
location ("location ~ gif") instead of parent one ("location /foo/").

Fix is to use r->uri instead of clcf->name in all cases in the
ngx_http_core_try_files_phase() function.  It is expected to be
already matched and identical to the clcf->name of the right
location.
2015-08-16 10:51:34 +03:00
Maxim Dounin 8bf94eb4a2 Fixed segfault with try_files introduced by c985d90a8d1f.
If alias was used in a location given by a regular expression,
nginx used to do wrong thing in try_files if a location name (i.e.,
regular expression) was an exact prefix of URI.  The following
configuration triggered a segmentation fault on a request to "/mail":

    location ~ /mail {
        alias /path/to/directory;
        try_files $uri =404;
    }

Reported by Per Hansson.
2015-08-16 10:51:16 +03:00
Sergey Kandaurov 5b2bcdca20 Core: fixed potential division by zero when initializing hash.
Found by Clang Static Analyzer.
2015-08-13 16:27:17 +03:00
Sergey Kandaurov 442ff2ac97 Core: fixed style in the error message. 2015-08-13 16:27:13 +03:00
Vladimir Homutov 3ae90e44b5 Stream: fixed potential error log buffer overrun.
Found by Duan Jiong <djduanjiong@gmail.com>.
2015-08-13 15:55:21 +03:00
Vladimir Homutov ea66206f04 Style. 2015-08-12 12:56:59 +03:00
Vladimir Homutov 7662432d69 Stream: the "tcp_nodelay" directive. 2015-08-10 12:14:41 +03:00
Valentin Bartenev ae9be8fc6b Core: idle connections now closed only once on exiting.
Iterating through all connections takes a lot of CPU time, especially
with large number of worker connections configured.  As a result
nginx processes used to consume CPU time during graceful shutdown.
To mitigate this we now only do a full scan for idle connections when
shutdown signal is received.

Transitions of connections to idle ones are now expected to be
avoided if the ngx_exiting flag is set.  The upstream keepalive module
was modified to follow this.
2015-08-11 16:28:55 +03:00
Andrei Belov 88c2af46ab Fixed typo in the error message. 2015-08-11 10:28:00 +03:00
Gena Makhomed f07deb44a8 Workaround for "configuration file test failed" under OpenVZ.
If nginx was used under OpenVZ and a container with nginx was suspended
and resumed, configuration tests started to fail because of EADDRINUSE
returned from listen() instead of bind():

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
nginx: configuration file /etc/nginx/nginx.conf test failed

With this change EADDRINUSE errors returned by listen() are handled
similarly to errors returned by bind(), and configuration tests work
fine in the same environment:

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

More details about OpenVZ suspend/resume bug:
https://bugzilla.openvz.org/show_bug.cgi?id=2470
2015-07-23 14:00:03 -04:00
Roman Arutyunyan 109f717153 Stream: deprecated proxy_downstream_buffer, proxy_upstream_buffer.
The directive proxy_buffer_size should be used instead.
2015-07-30 16:43:48 -07:00
Roman Arutyunyan a950a01481 Style. 2015-07-29 14:36:36 -07:00
Roman Arutyunyan 2815836357 Stream: added proxy_buffer_size to set the size of data buffers.
Both download and upload buffers now have the same size.  The old directives
proxy_downstream_buffer and proxy_upstream_buffer are removed.
2015-07-29 13:46:26 -07:00
Ruslan Ermilov 82e19c196c Fixed strict aliasing warnings with old GCC versions. 2015-07-16 14:20:48 +03:00
Andrew Hutchings ec7772facf Modify changes doc to acknowledge Lu is from Intel 2015-07-15 20:43:41 +01:00
Maxim Dounin db8e959f4e Version bump. 2015-07-15 22:56:03 +03:00
Maxim Dounin dcf970ecbd release-1.9.3 tag 2015-07-14 19:46:05 +03:00
Maxim Dounin 7fdf3c1c79 nginx-1.9.3-RELEASE 2015-07-14 19:46:05 +03:00
Maxim Dounin fe8d087623 Updated PCRE used for win32 builds. 2015-07-14 19:44:19 +03:00
Roman Arutyunyan cc945f17f1 Stream: renamed rate limiting directives.
The directive proxy_downstream_limit_rate is now called proxy_upload_rate.
The directive proxy_upstream_limit_rate is now called proxy_download_rate.
2015-07-14 09:38:13 -07:00
Maxim Dounin e8c9f3731c Updated OpenSSL used for win32 builds. 2015-07-14 10:13:51 +03:00
Maxim Dounin 3a75cc3038 OCSP stapling: fixed segfault without nextUpdate.
OCSP responses may contain no nextUpdate.  As per RFC 6960, this means
that nextUpdate checks should be bypassed.  Handle this gracefully by
using NGX_MAX_TIME_T_VALUE as "valid" in such a case.

The problem was introduced by 6893a1007a7c (1.9.2).

Reported by Matthew Baldwin.
2015-07-14 01:10:25 +03:00
Maxim Dounin cec200c26e OCSP stapling: fixed ssl_stapling_file (ticket #769).
Broken by 6893a1007a7c (1.9.2) during introduction of strict OCSP response
validity checks.  As stapling file is expected to be returned unconditionally,
fix is to set its validity to the maximum supported time.

Reported by Faidon Liambotis.
2015-07-07 16:38:49 +03:00
Valentin Bartenev abdcdca430 Stream: fixed possible integer overflow in rate limiting. 2015-07-02 17:20:29 +03:00
Roman Arutyunyan 0197065305 Stream: fixed MSVC compilation warning.
Thanks to itpp2012.
2015-07-02 17:15:32 +03:00
Roman Arutyunyan c138128b55 Stream: upstream "connected" flag.
Once upstream is connected, the upstream buffer is allocated.  Previously, the
proxy module used the buffer allocation status to check if upstream is
connected.  Now it's enough to check the flag.
2015-06-25 12:36:52 +03:00
Roman Arutyunyan 6a72ceb695 Stream: upstream and downstream limit rates. 2015-06-23 20:17:48 +03:00
Roman Arutyunyan f9a2aa9742 Stream: common handler for upstream and downstream. 2015-06-23 20:17:47 +03:00
Piotr Sikora 86efa1ecbe Stream: avoid SSL_CTX_set_tmp_rsa_callback() call with LibreSSL.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2015-06-18 03:36:41 -07:00
Ruslan Ermilov d6ce2f87ed Upstream: fixed shared upstreams on win32. 2015-06-16 00:43:00 +03:00
Vladimir Homutov 0262c3d9c6 Stream: connection limiting module.
stream {
    limit_conn_zone $binary_remote_addr zone=perip:1m;
    limit_conn_log_level error;

    server {
        ...
        limit_conn perip 1;
    }
}
2015-06-18 14:17:30 +03:00
Sergey Kandaurov 95daabb1cb Resolver: canceled resend timer on empty resend queues.
This is specifically useful on graceful shutdown.
2015-06-17 17:57:34 +03:00
Piotr Sikora b4127c9645 Configure: create missing intermediates for build directory.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2015-06-10 19:18:19 -07:00
Ruslan Ermilov dc3691a751 Configure: fix tests with multi-level relative build directory.
Based on a patch by Piotr Sikora.
2015-06-17 14:15:27 +03:00
Vladimir Homutov 350b2b1f8b Disabled duplicate http, mail, and stream blocks.
Such configurations have very limited use, introduce various problems and
are not officially supported.
2015-06-16 23:28:38 +03:00
Vladimir Homutov da0505b0a3 Version bump. 2015-06-16 23:31:31 +03:00
Maxim Dounin 43bcde296b release-1.9.2 tag 2015-06-16 17:49:40 +03:00
Maxim Dounin b038e0e473 nginx-1.9.2-RELEASE 2015-06-16 17:49:39 +03:00
Ruslan Ermilov 14b98283e0 Polished the recent change to the manpage. 2015-06-16 16:52:13 +03:00
Vladimir Homutov 974d5bc0d2 Documentation: added -T option description to the man page. 2015-06-16 16:28:56 +03:00
Vladimir Homutov 1e21e6fe90 Core: store and dump processed configuration.
If the -T option is passed, additionally to configuration test, configuration
files are output to stdout.

In the debug mode, configuration files are kept in memory and can be accessed
using a debugger.
2015-05-14 18:54:27 +03:00
Vladimir Homutov 8dbcdb257d Core: added support for writing to stdout. 2015-06-16 15:47:40 +03:00
Roman Arutyunyan 59a94f42da Core: renamed ngx_proxy_protocol_parse to ngx_proxy_protocol_read.
The new name is consistent with the ngx_proxy_protocol_write function.
2015-06-16 13:45:19 +03:00
Roman Arutyunyan 8b4835bfab Stream: client-side PROXY protocol.
The new directive "proxy_protocol" toggles sending out PROXY protocol header
to upstream once connection is established.
2015-06-16 13:45:16 +03:00
Vladimir Homutov 8cec2c4718 Stream: the "proxy_bind" directive. 2015-06-16 09:02:45 +03:00
Maxim Dounin fa6529ab39 Updated OpenSSL used for win32 builds. 2015-06-15 20:20:12 +03:00
Maxim Dounin a5e2da144d OCSP stapling: avoid sending expired responses (ticket #425). 2015-06-11 20:42:39 +03:00
Maxim Dounin 08a4e52aa8 Moved ngx_http_parse_time() to core, renamed accordingly.
The function is now called ngx_parse_http_time(), and can be used by
any code to parse HTTP-style date and time.  In particular, it will be
used for OCSP stapling.

For compatibility, a macro to map ngx_http_parse_time() to the new name
provided for a while.
2015-06-11 20:42:31 +03:00
Maxim Dounin d2b4dc83d4 Removed unused ngx_http_get_time() declaration. 2015-06-11 20:42:24 +03:00
Valentin Bartenev 6a771704df Configure: added gcc5 to the list of known GCC versions. 2015-06-10 19:18:20 +03:00
Ruslan Ermilov e62e8a0006 Configure: search OpenSSL in a bunch of standard places. 2015-06-10 12:25:45 +03:00
Ruslan Ermilov 05084363d7 Configure: moved NGX_SBIN_PATH variable initialization.
It's now initialized in auto/options like the rest of variables
for system paths.

As a side effect, the currently unused macro NGX_SBIN_PATH now
gets the correct value.
2015-06-10 12:25:31 +03:00
Vladimir Homutov ba1eec3b04 Stream: access module.
stream {
    server {
        ...
        allow 127.0.0.1;
        deny all;
    }
}
2015-06-04 13:04:12 +03:00
Vladimir Homutov 7f714ecc48 Stream: added postconfiguration method to stream modules. 2015-06-09 13:00:45 +03:00
Ruslan Ermilov b5e65d633d Mail: listen backlog=. 2015-06-08 23:13:56 +03:00
Ruslan Ermilov 1c02c89ae9 Stream: listen backlog=. 2015-06-08 23:13:33 +03:00
Ruslan Ermilov d02654e7b4 Mail: embed ngx_mail_listen_t into ngx_mail_conf_addr_t. 2015-06-08 23:11:58 +03:00
Ruslan Ermilov 2432c09ef7 Stream: embed ngx_stream_listen_t into ngx_stream_conf_addr_t. 2015-06-08 23:11:42 +03:00
Ruslan Ermilov 82f43aeb19 Stream: fixed "reuseport" to actually work. 2015-06-05 23:03:13 +03:00
Maxim Dounin 652fb06a66 Added the REQUEST_SCHEME parameter.
The REQUEST_SCHEME parameter was introduced in Apache 2.3.11 and seems
to be used by some scripts now.  It looks more logical than previously
used HTTPS.
2015-06-05 22:23:26 +03:00
Roman Arutyunyan eaff49e1d7 Upstream keepalive: reduced diffs to the plus version of nginx. 2015-06-04 23:46:44 +03:00
Maxim Dounin 6c28e55dbb Style. 2015-06-05 17:10:34 +03:00
Sergey Kandaurov 83b0d1c750 Event pipe: call ngx_handle_read_event() with a proper flags type.
The change was missed in f69d1aab6a0f.
2015-06-03 19:12:26 +03:00
Ruslan Ermilov 1fced9afbd Fixed misspellings of the word "dependencies". 2015-06-03 08:23:35 +03:00
Valentin Bartenev 009fe1ef67 Fixed excessive memory usage while parsing configuration.
The b->pos points to the next symbol here.

Reported by ilexshen.
2015-06-01 21:08:56 +03:00
Valentin Bartenev 4741bcb86f Fixed spelling in change logs. 2015-06-01 16:58:07 +03:00
Ruslan Ermilov e07c020105 Fixed bullying style of comments. 2015-05-29 09:26:33 +03:00
Ruslan Ermilov 8c116d36b1 Version bump. 2015-05-29 09:26:27 +03:00
Maxim Dounin 15b91a96ef release-1.9.1 tag 2015-05-26 16:49:51 +03:00
Maxim Dounin 105cb1e616 nginx-1.9.1-RELEASE 2015-05-26 16:49:50 +03:00
Maxim Dounin f5cee646a7 Disabled SSLv3 by default (ticket #653). 2015-05-25 17:58:20 +03:00
Maxim Dounin 1e5b6ec2a1 Configure: GNU Hurd properly recognized.
With this change it's no longer needed to pass -D_GNU_SOURCE manually,
and -D_FILE_OFFSET_BITS=64 is set to use 64-bit off_t.

Note that nginx currently fails to work properly with master process
enabled on GNU Hurd, as fcntl(F_SETOWN) returns EOPNOTSUPP for sockets
as of GNU Hurd 0.6.  Additionally, our strerror() preloading doesn't
work well with GNU Hurd, as it uses large numbers for most errors.
2015-05-25 17:58:13 +03:00
Maxim Dounin 66cb331a38 Fixed reuseport with accept_mutex. 2015-05-21 19:39:11 +03:00
Ruslan Ermilov c4b1b3907f Upstream: report to error_log when max_fails is reached.
This can be useful to understand why "no live upstreams" happens,
in particular.
2015-05-20 22:44:00 +03:00
Maxim Dounin 65ad1171c9 The "reuseport" option of the "listen" directive.
When configured, an individual listen socket on a given address is
created for each worker process.  This allows to reduce in-kernel lock
contention on configurations with high accept rates, resulting in better
performance.  As of now it works on Linux and DragonFly BSD.

Note that on Linux incoming connection requests are currently tied up
to a specific listen socket, and if some sockets are closed, connection
requests will be reset, see https://lwn.net/Articles/542629/.  With
nginx, this may happen if the number of worker processes is reduced.
There is no such problem on DragonFly BSD.

Based on previous work by Sepherosa Ziehau and Yingqi Lu.
2015-05-20 15:51:56 +03:00
Maxim Dounin 1881445bba Simplified ngx_http_init_listening().
There is no need to set "i" to 0, as it's expected to be 0 assuming
the bindings are properly sorted, and we already rely on this when
explicitly set hport->naddrs to 1.  Remaining conditional code is
replaced with identical "hport->naddrs = i + 1".

Identical modifications are done in the mail and stream modules,
in the ngx_mail_optimize_servers() and ngx_stream_optimize_servers()
functions, respectively.

No functional changes.
2015-05-20 15:51:28 +03:00
Maxim Dounin 831662ea73 Introduced worker number, ngx_worker. 2015-05-20 15:51:21 +03:00
Maxim Dounin 9456863c64 Configure: style. 2015-05-20 15:51:13 +03:00
Valentin Bartenev 5fd1f0fd59 Core: properly initialized written bytes counter in memory log. 2015-05-19 19:27:07 +03:00
Sergey Kandaurov 1ac2ceeb8d Upstream hash: consistency across little/big endianness. 2015-05-18 16:05:44 +03:00
Ruslan Ermilov 7c48049b72 Upstream: $upstream_connect_time.
The variable keeps time spent on establishing a connection with
the upstream server.
2015-05-16 01:32:27 +03:00
Ruslan Ermilov a0cfe06ec6 Upstream: times to obtain header/response are stored as ngx_msec_t. 2015-05-16 01:31:04 +03:00
Igor Sysoev 0106fe5106 Events: ngx_event_t size reduction by grouping bit fields. 2015-05-15 17:15:33 +03:00
Ruslan Ermilov 68e6c887d0 Events: made a failure to create a notification channel non-fatal.
This may happen if eventfd() returns ENOSYS, notably seen on CentOS 5.4.
Such a failure will now just disable the notification mechanism and let
the callers cope with it, instead of failing to start worker processes.
If thread pools are not configured, this can safely be ignored.
2015-05-06 17:04:00 +03:00
Ruslan Ermilov de2b39c702 Configure: handle deprecated options.
Removed the deprecated --without-http_limit_zone_module option.
Deprecated the --with-imap and --with-imap_ssl_module options.
2015-04-29 14:59:02 +03:00
Ruslan Ermilov 95ca7efd49 Removed the deprecated "imap" directive. 2015-04-29 13:53:24 +03:00
Ruslan Ermilov 909aa15688 Removed the deprecated "so_keepalive" directive. 2015-04-29 13:53:08 +03:00
Ruslan Ermilov 75fae2df1e Removed deprecated HTTP directives. 2015-04-29 13:52:49 +03:00
Ruslan Ermilov 1554f987b3 Removed the deprecated "connections" directive. 2015-04-29 13:52:37 +03:00
Valentin Bartenev b370ea3fa7 Fixed overflow detection in ngx_inet_addr().
Overflow detection of the last octet might not work.

Reported by Sergey Polovko.
2015-04-28 18:55:03 +03:00
Valentin Bartenev e3efe0d999 Version bump. 2015-04-28 18:54:48 +03:00
Maxim Dounin 5bfbac7203 release-1.9.0 tag 2015-04-28 18:31:18 +03:00
Maxim Dounin 9b6eb4f737 nginx-1.9.0-RELEASE 2015-04-28 18:31:17 +03:00
Maxim Dounin ffd7ee2660 Added stream module to win32 builds. 2015-04-27 18:51:18 +03:00
Maxim Dounin f9d7aaa7b6 Win32: shared memory base addresses and remapping.
Two mechanisms are implemented to make it possible to store pointers
in shared memory on Windows, in particular on Windows Vista and later
versions with ASLR:

- The ngx_shm_remap() function added to allow remapping of a shared memory
  zone to the address originally used for it in the master process.  While
  important, it doesn't solve the problem by itself as in many cases it's
  not possible to use the address because of conflicts with other
  allocations.

- We now create mappings at the same address in all processes by starting
  mappings at predefined addresses normally unused by newborn processes.

These two mechanisms combined allow to use shared memory on Windows
almost without problems, including reloads.

Based on the patch by Sergey Brester:
http://mailman.nginx.org/pipermail/nginx-devel/2015-April/006836.html
2015-04-27 18:25:42 +03:00
Maxim Dounin a5e3b66ce3 Win32: fixed shm.handle loss on reload. 2015-04-27 03:44:30 +03:00
Maxim Dounin 3b43a7a702 Core: fixed nginx_shared_zone name. 2015-04-27 03:44:03 +03:00
Vladimir Homutov 366a6f29e4 Mail: error_log support. 2015-02-20 15:31:37 +03:00
Vladimir Homutov bcf9cd2d24 Core: the ngx_set_connection_log() macro.
The http and stream versions of this macro were identical.
2015-04-25 22:44:02 +03:00
Roman Arutyunyan 7b383d5d3b Merge proxy_protocol setting of listen directives.
It's now enough to specify proxy_protocol option in one listen directive to
enable it in all servers listening on the same address/port.  Previously,
the setting from the first directive was always used.
2015-04-24 10:54:06 +03:00
Ruslan Ermilov 523387de77 Removed the "worker_rlimit_sigpending" directive.
It was only needed by the just removed rtsig module.
2015-04-23 14:26:11 +03:00
Ruslan Ermilov 71b90a9bdd Removed the obsolete rtsig module. 2015-04-23 14:17:40 +03:00
Ruslan Ermilov 90fca2303b Removed the obsolete aio module. 2015-04-22 18:57:32 +03:00
Roman Arutyunyan e99406d3f0 Stream: prevent repeated event notifications after eof.
When client or upstream connection is closed, level-triggered read event
remained active until the end of the session leading to cpu hog.  Now the flag
NGX_CLOSE_EVENT is used to unschedule the event.
2015-04-22 19:55:04 +03:00
Ruslan Ermilov ab98122416 Upstream: allow multiple upstreams to use the same shared zone. 2015-04-22 18:37:34 +03:00
Martin Mlynář 0b830caf30 Memcached: enabled ranges. 2015-04-21 21:04:36 +02:00
Ruslan Ermilov 31f5182119 Upstream: simplified ip_hash and hash peer selection code.
Now that peers are stored as a list, the weighted and unweighted
cases became nearly identical.
2015-04-21 19:09:04 +03:00
Sergey Kandaurov bde284851a Fixed building --with-stream when precompiled headers are used. 2015-04-20 17:36:51 +03:00
Sergey Kandaurov 2e527701f3 Limit req: removed check for unknown limit_req_zone.
With 48b3d5ddfb03, it's possible to specify limit_req_zone after limit_req.
2015-04-20 16:54:41 +03:00
Sergey Kandaurov 58aa1b73ea Core: allow shared memory size to be declared after a reference.
For example, this fixes the case when "proxy_cache_path" is specified
after "proxy_cache" that references it.
2015-04-20 16:53:04 +03:00
Ruslan Ermilov c6d6ff095f Stream: port from NGINX+. 2015-04-20 13:05:11 +03:00
Ruslan Ermilov 4fcfe3955b Upstream: fixed unlocked access to peer->conns. 2015-04-19 22:41:09 +03:00
Ruslan Ermilov 3ae7fed7e1 Replaced the remaining NGX_OLD_THREADS check with NGX_WIN32. 2015-03-26 14:20:51 +03:00
Ruslan Ermilov 6e8ba34b90 Removed NGX_OLD_THREADS from select and poll modules.
These modules can't be compiled on win32.
2015-03-26 14:20:07 +03:00
Ruslan Ermilov 2514db4c42 Removed "worker_threads" and "thread_stack_size" directives. 2015-03-26 14:15:17 +03:00
Ruslan Ermilov e095ef94b6 Removed unused thread-local-storage code. 2015-03-26 14:15:15 +03:00
Ruslan Ermilov 39f8463476 Removed ngx_threaded and related code. 2015-03-26 14:15:13 +03:00
Ruslan Ermilov 5886a316b5 Upstream: get rid of questionable micro-optimization in ip_hash.
If a peer was initially skipped due to max_fails, there's no reason
not to try it again if enough time has passed, and the next_upstream
logic is in action.

This also reduces diffs with NGINX Plus.
2015-04-16 20:09:11 +03:00
Sergey Kandaurov 224ad0943a Core: ensure that ngx_config.h is always included first.
This fixes compilation of various 3rd party modules when nginx is
configured with threads.
2015-04-16 18:18:37 +03:00
Maxim Dounin 56f13aabc3 Version bump. 2015-04-16 17:26:19 +03:00
Ruslan Ermilov fb2cb325d9 Upstream: the "zone" directive.
Upstreams with the "zone" directive are kept in shared memory,
with a consistent view of all worker processes.
2015-04-14 19:01:25 +03:00
Ruslan Ermilov 38f45f0f43 Upstreams: locking. 2015-04-14 19:01:23 +03:00
Ruslan Ermilov ec8cab3f7f Core: read/write locks. 2015-03-21 14:05:08 +03:00
Ruslan Ermilov 6245905f69 Upstream: store peers as a linked list.
This is an API change.
2015-04-10 14:48:36 +03:00
Ruslan Ermilov 9dae3abcc6 Upstream: track the number of active connections to upstreams.
This also simplifies the implementation of the least_conn module.
2015-04-10 13:16:23 +03:00
Ruslan Ermilov a9849bc5d6 Fixed build, broken by 8b7f062a3fe6.
Casting a "const char *" to "char *" doesn't work on older gcc versions.
2015-04-16 15:05:40 +03:00
Vladimir Homutov 555b3e74fe Core: added OpenSSL version information to "nginx -V" output. 2015-04-16 12:17:41 +03:00
Vladimir Homutov fcc244312c Version bump. 2015-04-16 12:13:51 +03:00
Maxim Dounin f446e0f054 release-1.7.12 tag 2015-04-07 18:35:33 +03:00
Maxim Dounin 7d2504b422 nginx-1.7.12-RELEASE 2015-04-07 18:35:33 +03:00
Ruslan Ermilov cb154fccdb Core: guard against spinlock usage without atomic ops.
The new thread pools code uses spinlocks.
2015-03-26 14:15:06 +03:00
Sergey Kandaurov 5e6739f8cc Core: limited levels of subdirectory hierarchy used for temp files.
Similar to ngx_http_file_cache_set_slot(), the last component of file->name
with a fixed length of 10 bytes, as generated in ngx_create_temp_path(), is
used as a source for the names of intermediate subdirectories with each one
taking its own part.  Ensure that the sum of specified levels with slashes
fits into the length (ticket #731).
2015-04-07 01:32:08 +03:00
Sergey Kandaurov d9c0268c38 Core: removed excessive initialization in ngx_conf_set_path_slot().
Level hierarchy is pre-zeroed in ngx_pcalloc() of the surrounding ngx_path_t.
2015-04-07 01:32:07 +03:00
Sergey Kandaurov 9707c564c8 Core: fixed error handling on ngx_conf_full_name() failure. 2015-04-07 01:32:05 +03:00
Ruslan Ermilov 93eabd6a0e Upstream: abbreviated SSL handshake may interact badly with Nagle. 2015-04-07 00:07:04 +03:00
Valentin Bartenev be28c7ada3 Request body: always flush buffers if request buffering is off.
This fixes unbuffered proxying to SSL backends, since it prevents
ngx_ssl_send_chain() from accumulation of request body in the SSL
buffer.
2015-04-06 19:20:36 +03:00
Valentin Bartenev 9b516414e7 Used the correct type for the AIO preload handler return value. 2015-04-06 11:22:24 +03:00
Maxim Dounin 4302005190 Configure: style. 2015-04-03 18:20:57 +03:00
Filipe da Silva 3fd06f4de5 OCSP stapling: missing free calls.
Missing call to X509_STORE_CTX_free when X509_STORE_CTX_init fails.
Missing call to OCSP_CERTID_free when OCSP_request_add0_id fails.
Possible leaks in vary particular scenariis of memory shortage.
2015-04-01 15:05:08 +02:00
Valentin Bartenev 70ee643e20 Cache: added support for reading of the header in thread pools. 2015-04-01 03:49:17 +03:00
Sergey Kandaurov bb1aacc0b5 Fixed invalid access to complex value defined as an empty string.
Found by Valgrind.
2015-03-31 17:45:50 +03:00
Valentin Bartenev 7f2b8fa967 Events: fixed possible crash on start or reload.
The main thread could wake up and start processing the notify event
before the handler was set.
2015-03-27 21:19:20 +03:00
Valentin Bartenev 43cf48b5c1 Events: made posted events macros safe. 2015-03-27 19:57:15 +03:00
Valentin Bartenev a5880ddcbf SPDY: always push pending data.
This helps to avoid suboptimal behavior when a client waits for a control
frame or more data to increase window size, but the frames have been delayed
in the socket buffer.

The delays can be caused by bad interaction between Nagle's algorithm on
nginx side and delayed ACK on the client side or by TCP_CORK/TCP_NOPUSH
if SPDY was working without SSL and sendfile() was used.

The pushing code is now very similar to ngx_http_set_keepalive().
2015-03-23 21:04:13 +03:00
Valentin Bartenev d733a14ab8 SPDY: fixed error handling in ngx_http_spdy_send_output_queue(). 2015-03-23 20:47:46 +03:00
Maxim Dounin caace05203 Version bump. 2015-03-26 17:36:39 +03:00
Maxim Dounin d4247658b6 Proxy: fixed proxy_request_buffering and chunked with preread body.
If any preread body bytes were sent in the first chain, chunk size was
incorrectly added before the whole chain, including header, resulting in
an invalid request sent to upstream.  Fixed to properly add chunk size
after the header.
2015-03-26 02:31:30 +03:00
Maxim Dounin b50687c5f3 release-1.7.11 tag 2015-03-24 18:45:34 +03:00
Maxim Dounin beab15a36c nginx-1.7.11-RELEASE 2015-03-24 18:45:34 +03:00
Maxim Dounin 3612d55fd2 Upstream: uwsgi_request_buffering, scgi_request_buffering. 2015-03-23 21:09:19 +03:00
Maxim Dounin ad3cc3d3c5 FastCGI: fastcgi_request_buffering. 2015-03-23 21:09:19 +03:00
Maxim Dounin bcbe20a32a Proxy: proxy_request_buffering chunked support. 2015-03-23 21:09:19 +03:00
Maxim Dounin d9753b7038 Request body: unbuffered reading.
The r->request_body_no_buffering flag was introduced.  It instructs
client request body reading code to avoid reading the whole body, and
to call post_handler early instead.  The caller should use the
ngx_http_read_unbuffered_request_body() function to read remaining
parts of the body.

Upstream module is now able to use this mode, if configured with
the proxy_request_buffering directive.
2015-03-23 21:09:19 +03:00
Maxim Dounin 6cdfaf073a Request body: filters support. 2015-03-23 21:09:19 +03:00
Maxim Dounin 4a852ff21f Request body: moved request body writing to save filter. 2015-03-23 21:09:19 +03:00
Maxim Dounin a573478150 Request body: free chain links in ngx_http_write_request_body(). 2015-03-23 21:09:12 +03:00
Maxim Dounin 29d1177251 Output chain: free chain links in ngx_chain_writer(). 2015-03-23 21:09:05 +03:00
Maxim Dounin b121516a0f Output chain: zero size buf alerts in ngx_chain_writer().
Now we log a "zero size buf in chain writer" alert if we encounter a zero
sized buffer in ngx_chain_writer(), and skip the buffer.
2015-03-23 20:56:58 +03:00
Maxim Dounin fde053ae49 Format specifier fixed for file size of buffers. 2015-03-23 19:28:54 +03:00
Maxim Dounin 5f7b261a8d Proxy: fixed proxy_set_body with proxy_cache.
If the last header evaluation resulted in an empty header, the e.skip flag
was set and was not reset when we've switched to evaluation of body_values.
This incorrectly resulted in body values being skipped instead of producing
some correct body as set by proxy_set_body.  Fix is to properly reset
the e.skip flag.

As the problem only appeared if the last potentially non-empty header
happened to be empty, it only manifested itself if proxy_set_body was used
with proxy_cache.
2015-03-23 19:28:54 +03:00
Valentin Bartenev eeb300e8d0 Thread pools: implemented graceful exiting of threads. 2015-03-23 17:51:21 +03:00
Valentin Bartenev cfd9b4b898 Thread pools: removed unused pointer to memory pool.
No functional changes.
2015-03-23 17:51:21 +03:00
Valentin Bartenev 3d8c16055f Thread pools: keep waiting tasks mutex in ngx_thread_pool_t.
It's not needed for completed tasks queue since the previous change.

No functional changes.
2015-03-23 17:51:21 +03:00
Valentin Bartenev 14b5f6e9c9 Thread pools: replaced completed tasks queue mutex with spinlock. 2015-03-23 17:51:21 +03:00
Ruslan Ermilov a45bb586a5 Removed stub implementation of win32 mutexes. 2015-03-23 13:52:47 +03:00
Maxim Dounin 97f8e7b93a Updated OpenSSL used for win32 builds. 2015-03-23 02:44:41 +03:00
Maxim Dounin ec92084232 SSL: use of SSL_MODE_NO_AUTO_CHAIN.
The SSL_MODE_NO_AUTO_CHAIN mode prevents OpenSSL from automatically
building a certificate chain on the fly if there is no certificate chain
explicitly provided.  Before this change, certificates provided via the
ssl_client_certificate and ssl_trusted_certificate directives were
used by OpenSSL to automatically build certificate chains, resulting
in unexpected (and in some cases unneeded) chains being sent to clients.
2015-03-23 02:42:35 +03:00
Maxim Dounin 97b0d0cfdc SSL: avoid SSL_CTX_set_tmp_rsa_callback() call with LibreSSL.
LibreSSL removed support for export ciphers and a call to
SSL_CTX_set_tmp_rsa_callback() results in an error left in the error
queue.  This caused alerts "ignoring stale global SSL error (...called
a function you should not call) while SSL handshaking" on a first connection
in each worker process.
2015-03-23 02:42:34 +03:00
Maxim Dounin 5adb0938c9 SSL: clear protocol options.
LibreSSL 2.1.1+ started to set SSL_OP_NO_SSLv3 option by default on
new contexts.  This makes sure to clear it to make it possible to use SSLv3
with LibreSSL if enabled in nginx config.

Prodded by Kuramoto Eiji.
2015-03-23 02:42:32 +03:00
Valentin Bartenev cd504958dc Core: added cyclic memory buffer support for error_log.
Example of usage:

  error_log memory:16m debug;

This allows to configure debug logging with minimum impact on performance.
It's especially useful when rare crashes are experienced under high load.

The log can be extracted from a coredump using the following gdb script:

  set $log = ngx_cycle->log

  while $log->writer != ngx_log_memory_writer
      set $log = $log->next
  end

  set $buf = (ngx_log_memory_buf_t *) $log->wdata
  dump binary memory debug_log.txt $buf->start $buf->end
2015-03-19 19:29:43 +03:00
Ruslan Ermilov fbfd78c669 Removed busy locks. 2015-03-20 06:45:32 +03:00
Ruslan Ermilov ecfd591aa4 Removed ngx_connection_t.lock. 2015-03-20 06:43:19 +03:00
Ruslan Ermilov 6bd5d63411 Removed unix ngx_threaded and related ngx_process_changes. 2015-03-20 06:43:19 +03:00
Ruslan Ermilov 1d16dc7eea Removed old pthread implementation. 2015-03-20 06:43:19 +03:00
Ruslan Ermilov 891c8a01c4 Removed old FreeBSD rfork() thread implementation. 2015-03-20 06:43:19 +03:00
Ruslan Ermilov b736f1bb31 Thread pools: silence warning on process exit.
Work around pthread_cond_destroy() and pthread_mutex_destroy() returning
EBUSY.  A proper solution would be to ensure all threads are terminated.
2015-03-19 23:20:18 +03:00
Ruslan Ermilov 16c773a914 Thread pools: fixed the waiting tasks accounting.
Behave like POSIX semaphores.  If N worker threads are waiting for tasks,
at least that number of tasks should be allowed to be put into the queue.
2015-03-19 13:00:48 +03:00
Ruslan Ermilov 5d1a67c603 Thread pools: keep waiting tasks counter in ngx_thread_pool_t.
It's not needed for completed tasks queue.

No functional changes.
2015-03-19 23:19:35 +03:00
Xiaochen Wang 2070c3baeb SPDY: fixed format specifier in logging. 2015-03-15 21:46:21 +08:00
Valentin Bartenev 1b20e97e8f Added support for offloading Linux sendfile() in thread pools. 2015-03-14 17:37:30 +03:00
Valentin Bartenev c410e10c75 Added support for offloading read() in thread pools. 2015-03-14 17:37:25 +03:00
Ruslan Ermilov 024f0d021a Events: implemented eventport notification mechanism. 2015-03-14 17:37:21 +03:00
Valentin Bartenev 41b9624902 Events: implemented kqueue notification mechanism. 2015-03-14 17:37:16 +03:00
Valentin Bartenev 2b52841a86 Events: implemented epoll notification mechanism. 2015-03-14 17:37:13 +03:00
Valentin Bartenev 065a0f544a Thread pools implementation. 2015-03-14 17:37:07 +03:00
Ruslan Ermilov fcb4524be7 Configure: removed obsolete threads bits. 2015-03-13 19:08:27 +03:00
Ruslan Ermilov c9c87e8544 Renamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.
It's mostly dead code and the original idea of worker threads has been rejected.
2015-03-04 18:26:25 +03:00
Ruslan Ermilov f82cc4437d Configure: fixed type max value detection.
The code tried to use suffixes for "long" and "long long" types, but
it never worked as intended due to the bug in the shell code.  Also,
the max value for any 64-bit type other than "long long" on platforms
with 32-bit "long" would be incorrect if the bug was fixed.

So instead of fixing the bug in the shell code, always use the "int"
constant for 32-bit types, and "long long" constant for 64-bit types.
2015-03-18 02:04:39 +03:00
Ruslan Ermilov 94e7de61ff Overflow detection in ngx_http_parse_chunked(). 2015-03-17 00:26:27 +03:00
Ruslan Ermilov fd6c91baa2 Overflow detection in ngx_http_range_parse(). 2015-03-17 00:26:24 +03:00
Ruslan Ermilov 3a1cf77d15 Overflow detection in ngx_inet_addr(). 2015-03-17 00:26:22 +03:00
Ruslan Ermilov 7d52092df0 Core: overflow detection in ngx_parse_time() (ticket #732). 2015-03-17 00:26:20 +03:00
Ruslan Ermilov ea165e6957 Refactored ngx_parse_time().
No functional changes.
2015-03-17 00:26:18 +03:00
Ruslan Ermilov f971d5dc11 Core: overflow detection in number parsing functions. 2015-03-17 00:26:15 +03:00
Ruslan Ermilov 9c7ff92de8 Core: expose maximum values of time_t and ngx_int_t.
These are needed to detect overflows.
2015-03-17 00:24:34 +03:00
Ruslan Ermilov c21a57d75b Configure: removed redundant auto/have call.
The auto/feature call above is enough to set NGX_HAVE_SENDFILE.
2015-03-13 16:43:01 +03:00
Ruslan Ermilov 3954e53e2b The "aio" directive parser made smarter.
It now prints meaningful warnings on all platforms.

No functional changes.
2015-03-13 16:42:52 +03:00
Ruslan Ermilov da0ef752a6 Events: fixed typo in the error message. 2015-03-12 23:03:03 +03:00
Ruslan Ermilov 1bd4ba54b7 Deprecated "aio sendfile".
Specifying "sendfile on" along with "aio on" activates the
aio pre-loading mode for sendfile().
2015-03-12 20:06:04 +03:00
Ruslan Ermilov 55cce03942 Proxy: use an appropriate error on memory allocation failure. 2015-03-04 08:12:53 +03:00
Ruslan Ermilov 3c78fb7475 Style: moved ngx_http_ephemeral() macro to ngx_http_request.h. 2015-03-04 08:10:40 +03:00
Ruslan Ermilov 29997f511f Style: use %*s format, as in 68d21fd1dc64. 2015-03-04 08:05:38 +03:00
Valentin Bartenev 5a7badcea9 Log: use ngx_cpymem() in a couple of places, no functional changes. 2015-03-04 19:20:30 +03:00
Valentin Bartenev 07876cb34c Upstream keepalive: drop ready flag on EAGAIN from recv(MSG_PEEK).
Keeping the ready flag in this case might results in missing notification of
broken connection until nginx tried to use it again.

While there, stale comment about stale event was removed since this function
is also can be called directly.
2015-03-03 17:48:57 +03:00
Ruslan Ermilov f3094becca Events: simplified ngx_event_aio_t definition.
No functional changes.
2015-03-03 18:09:13 +03:00
Valentin Bartenev 4fda719c24 Refactored ngx_linux_sendfile_chain() even more.
The code that calls sendfile() was cut into a separate function.
This simplifies EINTR processing, yet is needed for the following
changes that add threads support.
2015-02-27 19:19:08 +03:00
Maxim Dounin d033539ebc Style.
Noted by Ruslan Ermilov.
2015-03-03 01:15:21 +03:00
Maxim Dounin 39c238f483 Upstream: upstream argument in ngx_http_upstream_process_request().
In case of filter finalization, r->upstream might be changed during
the ngx_event_pipe() call.  Added an argument to preserve it while
calling the ngx_http_upstream_process_request() function.
2015-03-02 21:44:42 +03:00
Maxim Dounin 33f5d88d35 Upstream: avoid duplicate finalization.
A request may be already finalized when ngx_http_upstream_finalize_request()
is called, due to filter finalization: after filter finalization upstream
can be finalized via ngx_http_upstream_cleanup(), either from
ngx_http_terminate_request(), or because a new request was initiated
to an upstream.  Then the upstream code will see an error returned from
the filter chain and will call the ngx_http_upstream_finalize_request()
function again.

To prevent corruption of various upstream data in this situation, make sure
to do nothing but merely call ngx_http_finalize_request().

Prodded by Yichun Zhang, for details see the thread at
http://nginx.org/pipermail/nginx-devel/2015-February/006539.html.
2015-03-02 21:44:32 +03:00
Roman Arutyunyan b660295f07 SSL: reset ready flag if recv(MSG_PEEK) found no bytes in socket.
Previously, connection hung after calling ngx_http_ssl_handshake() with
rev->ready set and no bytes in socket to read.  It's possible in at least the
following cases:

 - when processing a connection with expired TCP_DEFER_ACCEPT on Linux
 - after parsing PROXY protocol header if it arrived in a separate TCP packet

Thanks to James Hamlin.
2015-03-02 21:15:46 +03:00
Roman Arutyunyan 40f7b854cb Cache: do not inherit last_modified and etag from stale response.
When replacing a stale cache entry, its last_modified and etag could be
inherited from the old entry if the response code is not 200 or 206.  Moreover,
etag could be inherited with any response code if it's missing in the new
response.  As a result, the cache entry is left with invalid last_modified or
etag which could lead to broken revalidation.

For example, when a file is deleted from backend, its last_modified is copied to
the new 404 cache entry and is used later for revalidation.  Once the old file
appears again with its original timestamp, revalidation succeeds and the cached
404 response is sent to client instead of the file.

The problem appeared with etags in 44b9ab7752e3 (1.7.3) and affected
last_modified in 1573fc7875fa (1.7.9).
2015-03-02 19:47:13 +03:00
Roman Arutyunyan 28d9e3813f Upstream hash: speedup consistent hash init.
Repeatedly calling ngx_http_upstream_add_chash_point() to create
the points array in sorted order, is O(n^2) to the total weight.
This can cause nginx startup and reconfigure to be substantially
delayed.  For example, when total weight is 1000, startup takes
5s on a modern laptop.

Replace this with a linear insertion followed by QuickSort and
duplicates removal.  Startup for total weight of 1000 reduces to 40ms.

Based on a patch by Wai Keen Woon.
2015-03-02 18:41:29 +03:00
Sergey Kandaurov f32748b5c5 Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Previously, the Auth-SSL-Verify header with the "NONE" value was always passed
to the auth_http script if verification of client certificates is disabled.
2015-02-27 16:28:31 +03:00
Maxim Dounin 646bcfb3d5 Mail: client SSL certificates support.
The "ssl_verify_client", "ssl_verify_depth", "ssl_client_certificate",
"ssl_trusted_certificate", and "ssl_crl" directives introduced to control
SSL client certificate verification in mail proxy module.

If there is a certificate, detail of the certificate are passed to
the auth_http script configured via Auth-SSL-Verify, Auth-SSL-Subject,
Auth-SSL-Issuer, Auth-SSL-Serial, Auth-SSL-Fingerprint headers.  If
the auth_http_pass_client_cert directive is set, client certificate
in PEM format will be passed in the Auth-SSL-Cert header (urlencoded).

If there is no required certificate provided during an SSL handshake
or certificate verification fails then a protocol-specific error is
returned after the SSL handshake and the connection is closed.

Based on previous work by Sven Peter, Franck Levionnois and Filipe Da Silva.
2015-02-25 17:48:05 +03:00
Maxim Dounin 88a4ebfc69 Mail: added Auth-SSL header to indicate SSL.
Based on a patch by Filipe da Silva.
2015-02-25 17:47:49 +03:00
Maxim Dounin b7b4884a9f Mail: fixed buffer allocation for CRLF after Auth-SMTP-* headers.
There were no buffer overruns in real life as there is extra space
allocated for the Auth-Login-Attempt counter.
2015-02-25 17:47:43 +03:00
Ruslan Ermilov 9a17024ac0 SSL: account sent bytes in ngx_ssl_write(). 2015-02-24 23:52:47 +03:00
Maxim Dounin 3bfefd895c Core: fixed potential buffer overrun when initializing hash.
Initial size as calculated from the number of elements may be bigger
than max_size.  If this happens, make sure to set size to max_size.

Reported by Chris West.
2015-02-24 18:37:14 +03:00
Ruslan Ermilov 756fd68747 Cache: reduced diffs to the plus version of nginx.
No functional changes.
2015-02-17 16:27:52 +03:00
Roman Arutyunyan 665f1492fb Core: make ngx_connection_local_sockaddr() always assign address.
Previously, this function checked for connection local address existence
and returned error if it was missing.  Now a new address is assigned in this
case making it possible to call this function not only for accepted connections.
2015-02-17 14:26:44 +03:00
Sergey Kandaurov d0b0203843 Configure: typo fixed. 2015-02-11 20:18:55 +03:00
Valentin Bartenev d23fd081f7 Unbreak building on FreeBSD without file AIO.
It appeared that the NGX_HAVE_AIO_SENDFILE macro was defined regardless of
the "--with-file-aio" configure option and the NGX_HAVE_FILE_AIO macro.

Now they are related.

Additionally, fixed one macro.
2015-02-11 20:00:07 +03:00
Valentin Bartenev 116ae55fc2 Refactored sendfile() AIO preload.
This reduces layering violation and simplifies the logic of AIO preread, since
it's now triggered by the send chain function itself without falling back to
the copy filter.  The context of AIO operation is now stored per file buffer,
which makes it possible to properly handle cases when multiple buffers come
from different locations, each with its own configuration.
2015-02-11 17:52:15 +03:00
Ruslan Ermilov a4320d2562 Mail: fixed the duplicate listen address detection. 2015-01-23 15:23:29 +03:00
Ruslan Ermilov 3dce24268b Mail: fixed a comment. 2015-01-23 15:23:27 +03:00
Ruslan Ermilov 075a61e4d7 Upstream: detect port absence in fastcgi_pass with IP literal.
If fastcgi_pass (or any look-alike that doesn't imply a default
port) is specified as an IP literal (as opposed to a hostname),
port absence was not detected at configuration time and could
result in EADDRNOTAVAIL at run time.

Fixed this in such a way that configs like

http {
    server {
        location / {
            fastcgi_pass 127.0.0.1;
        }
    }

    upstream 127.0.0.1 {
        server 10.0.0.1:12345;
    }
}

still work.  That is, port absence check is delayed until after
we make sure there's no explicit upstream with such a name.
2015-01-22 16:23:32 +03:00
Ruslan Ermilov e67167015e Version bump. 2015-02-11 15:51:03 +03:00
Maxim Dounin c504ee67ec release-1.7.10 tag 2015-02-10 17:33:32 +03:00
Maxim Dounin 0c9714617b nginx-1.7.10-RELEASE 2015-02-10 17:33:32 +03:00
Maxim Dounin 38b287fa40 Updated OpenSSL used for win32 builds. 2015-02-10 16:54:12 +03:00
Sergey Kandaurov 8dfa0eebff Core: fixed build on Tru64 UNIX.
There was a typo in NGX_EACCES.

Reported by Goetz T. Fischer.
2015-02-10 01:51:08 +03:00
Damien Tournoud d718bb604a Fixed try_files directory test to match only a directory.
Historically, it was possible to match either a file or directory
in the following configuration:

    location / {
        try_files $uri/ =404;
    }
2015-01-21 00:26:32 +01:00
Roman Arutyunyan a2b0b1377b Core: fixed a race resulting in extra sem_post()'s.
The mtx->wait counter was not decremented if we were able to obtain the lock
right after incrementing it.  This resulted in unneeded sem_post() calls,
eventually leading to EOVERFLOW errors being logged, "sem_post() failed
while wake shmtx (75: Value too large for defined data type)".

To close the race, mtx->wait is now decremented if we obtain the lock right
after incrementing it in ngx_shmtx_lock().  The result can become -1 if a
concurrent ngx_shmtx_unlock() decrements mtx->wait before the added code does.
However, that only leads to one extra iteration in the next call of
ngx_shmtx_lock().
2015-02-04 16:22:43 +03:00
Roman Arutyunyan 0b1fa68de9 Core: reverted prefix-based temp files (a9138c35120d).
The use_temp_path http cache feature is now implemented using a separate temp
hierarchy in cache directory.  Prefix-based temp files are no longer needed.
2015-02-02 21:28:09 +03:00
Roman Arutyunyan f34021b4f2 Cache: added temp_path to file cache.
If use_temp_path is set to off, a subdirectory "temp" is created in the cache
directory.  It's used instead of proxy_temp_path and friends for caching
upstream response.
2015-02-02 19:38:35 +03:00
Roman Arutyunyan 5fbcfabd88 Core: supported directory skipping in ngx_walk_tree().
If pre_tree_handler() returns NGX_DECLINED, the directory is ignored.
2015-02-02 19:38:32 +03:00
Valentin Bartenev 557a6cb0e3 Fixed AIO handling in the output chain.
The ctx->aio flag must be taken into account in the short path too.
2015-01-28 21:33:06 +03:00
Igor Sysoev 572142f533 A bounds check of %N format on Windows.
Thanks to Joe Bialek, Adam Zabrocki and Microsoft Vulnerability Research.
2015-01-27 15:38:15 +03:00
Vladimir Homutov 3de770f46e Upstream: $upstream_header_time variable.
Keeps time spent on obtaining the header from an upstream server.  The value is
formatted similar to the $upstream_response_time variable.
2015-01-14 09:03:35 +03:00
Valentin Bartenev 0c4c88529d Year 2015. 2015-01-13 20:13:16 +03:00
Maxim Dounin 3c56d71af6 Core: added disk_full_time checks to error log. 2015-01-13 19:51:37 +03:00
Maxim Dounin 6e0a3b72ad Fixed sendfile() trailers on OS X (8e903522c17a, 1.7.8).
The trailer.count variable was not initialized if there was a header,
resulting in "sendfile() failed (22: Invalid argument)" alerts on OS X
if the "sendfile" directive was used.  The bug was introduced
in 8e903522c17a (1.7.8).
2015-01-13 18:58:23 +03:00
Valentin Bartenev 9a12419419 Upstream: use_temp_path parameter of proxy_cache_path and friends.
When set to "off", temporary files for cacheable responses will be stored
inside cache directory.
2014-12-26 16:22:59 +03:00
Valentin Bartenev b6393ef075 Cache: update variant while setting header.
Some parts of code related to handling variants of a resource moved into
a separate function that is called earlier.  This allows to use cache file
name as a prefix for temporary file in the following patch.
2014-12-26 16:22:56 +03:00
Valentin Bartenev 71f3eca473 Core: added prefix-based temporary files.
Now, if the "path" parameter is NULL, ngx_create_temp_file() will use
file->name as a predefined file path prefix.
2014-12-26 16:22:54 +03:00
Valentin Bartenev 1020a71b3f Unified handling of ngx_create_temp_file() return value.
The original check for NGX_AGAIN was surplus, since the function returns
only NGX_OK or NGX_ERROR.  Now it looks similar to other places.

No functional changes.
2014-12-26 16:22:50 +03:00
Maxim Dounin 87e244bd06 Trailing space fix. 2014-12-24 19:02:58 +03:00
Maxim Dounin b966f5bd88 Fixed building with musl libc (ticket #685). 2014-12-24 19:01:22 +03:00
Maxim Dounin 6579de97aa Version bump. 2014-12-24 18:53:38 +03:00
Maxim Dounin b5cc516664 release-1.7.9 tag 2014-12-23 18:28:38 +03:00
Maxim Dounin 31830a810f nginx-1.7.9-RELEASE 2014-12-23 18:28:37 +03:00
Valentin Bartenev 8b2ab220fa Upstream: added variables support to proxy_cache and friends. 2014-12-22 12:59:09 +03:00
Valentin Bartenev 6331d0dcfc Upstream: preset some cache configuration when bypassing.
No functional changes.
2014-12-22 12:59:06 +03:00
Valentin Bartenev 976a82a4d1 Upstream: refactored proxy_cache and friends.
The configuration handling code has changed to look similar to the proxy_store
directive and friends.  This simplifies adding variable support in the following
patch.

No functional changes.
2014-12-22 12:59:02 +03:00
Valentin Bartenev 916557b7cd Upstream: mutually exclusive inheritance of "cache" and "store".
Currently, storing and caching mechanisms cannot work together, and a
configuration error is thrown when the proxy_store and proxy_cache
directives (as well as their friends) are configured on the same level.

But configurations like in the example below were allowed and could result
in critical errors in the error log:

    proxy_store on;

    location / {
        proxy_cache one;
    }

Only proxy_store worked in this case.

For more predictable and errorless behavior these directives now prevent
each other from being inherited from the previous level.
2014-12-22 12:58:59 +03:00
Valentin Bartenev 25ff0acf10 Upstream: simplified proxy_store and friends configuration code.
This changes internal API related to handling of the "store"
flag in ngx_http_upstream_conf_t.  Previously, a non-null value
of "store_lengths" was enough to enable store functionality with
custom path.  Now, the "store" flag is also required to be set.

No functional changes.
2014-12-22 12:58:56 +03:00
Lukas Tribus 1a90299683 SSL: safeguard use of SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS.
The flag was recently removed by BoringSSL.
2014-12-17 15:12:50 +01:00
Valentin Bartenev a64979ae9a Autoindex: implemented XML output format. 2014-12-12 20:25:42 +03:00
Valentin Bartenev aac9b87cd1 Autoindex: implemented JSON output format. 2014-12-12 20:25:35 +03:00
Valentin Bartenev be898a5f94 Autoindex: rendering code moved to a separate function.
No functional changes.
2014-12-12 20:25:28 +03:00
Maxim Dounin e579df7e73 Headers filter: variables support in expires (ticket #113). 2014-12-11 23:42:11 +03:00
Maxim Dounin 02f6dc581c Headers filter: local variables for config, no functional changes. 2014-12-11 23:42:06 +03:00
Valentin Bartenev d09aa23313 Upstream: fixed inheritance of proxy_store and friends.
The proxy_store, fastcgi_store, scgi_store and uwsgi_store were inherited
incorrectly if a directive with variables was defined, and then redefined
to the "on" value, i.e. in configurations like:

    proxy_store /data/www$upstream_http_x_store;

    location / {
        proxy_store on;
    }
2014-10-09 20:30:11 +04:00
Maxim Dounin db679e00b0 Proxy: fixed incorrect URI change due to if (ticket #86).
In the following configuration request was sent to a backend without
URI changed to '/' due to if:

    location /proxy-pass-uri {
        proxy_pass http://127.0.0.1:8080/;

        set $true 1;

        if ($true) {
            # nothing
        }
    }

Fix is to inherit conf->location from the location where proxy_pass was
configured, much like it's done with conf->vars.
2014-12-09 18:22:39 +03:00
Maxim Dounin 3c7f04bb79 Upstream: fixed unexpected inheritance into limit_except blocks.
The proxy_pass directive and other handlers are not expected to be inherited
into nested locations, but there is a special code to inherit upstream
handlers into limit_except blocks, as well as a configuration into if{}
blocks.  This caused incorrect behaviour in configurations with nested
locations and limit_except blocks, like this:

    location / {
        proxy_pass http://u;

        location /inner/ {
            # no proxy_pass here

            limit_except GET {
                # nothing
            }
        }
    }

In such a configuration the limit_except block inside "location /inner/"
unexpectedly used proxy_pass defined in "location /", while it shouldn't.
Fix is to avoid inheritance of conf->upstream.upstream (and
conf->proxy_lengths) into locations which don't have noname flag.
2014-12-09 18:22:31 +03:00
Maxim Dounin 28ccb3a02b Upstream: inheritance of proxy_pass and friends (ticket #645).
Instead of independant inheritance of conf->upstream.upstream (proxy_pass
without variables) and conf->proxy_lengths (proxy_pass with variables)
we now test them both and inherit only if neither is set.  Additionally,
SSL context is also inherited only in this case now.

Based on the patch by Alexey Radkov.
2014-12-09 18:21:55 +03:00
Maxim Dounin ad4b0e121d Proxy: the "TE" header now stripped by default (ticket #537). 2014-12-09 18:20:19 +03:00
Piotr Sikora ae446ac5d1 Cache: send conditional requests only for cached 200/206 responses.
RFC7232 says:

   The 304 (Not Modified) status code indicates that a conditional GET
   or HEAD request has been received and would have resulted in a 200
   (OK) response if it were not for the fact that the condition
   evaluated to false.

which means that there is no reason to send requests with "If-None-Match"
and/or "If-Modified-Since" headers for responses cached with other status
codes.

Also, sending conditional requests for responses cached with other status
codes could result in a strange behavior, e.g. upstream server returning
304 Not Modified for cached 404 Not Found responses, etc.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-11-26 18:35:37 -08:00
Dmitrii Pichulin 5ceb0443f7 SSL: loading certificate keys via ENGINE_load_private_key(). 2014-08-04 11:03:20 +04:00
Maxim Dounin 9adbea6c3d Version bump. 2014-12-04 16:37:31 +03:00
Maxim Dounin 18856ba3e0 release-1.7.8 tag 2014-12-02 16:02:14 +03:00
Maxim Dounin a6be07b77a nginx-1.7.8-RELEASE 2014-12-02 16:02:14 +03:00
Maxim Dounin 78640b94c1 Trailing spaces removed, typo fixed. 2014-12-02 07:01:37 +03:00
Maxim Dounin e4eba053e7 Cache: proper wakeup of subrequests.
In case of a cache lock timeout and in the aio handler we now call
r->write_event_handler() instead of a connection write handler,
to make sure to run appropriate subrequest.  Previous code failed to run
inactive subrequests and hence resulted in suboptimal behaviour, see
report by Yichun Zhang:

http://mailman.nginx.org/pipermail/nginx-devel/2013-October/004435.html

(Infinite hang claimed in the report seems impossible without 3rd party
modules, as subrequests will be eventually woken up by the postpone filter.)
2014-12-02 05:54:56 +03:00
Maxim Dounin 77f8bcecfd Upstream: improved subrequest logging.
To ensure proper logging make sure to set current_request in all event
handlers, including resolve, ssl handshake, cache lock wait timer and
aio read handlers.  A macro ngx_http_set_log_request() introduced to
simplify this.
2014-12-02 05:54:54 +03:00
Sergey Kandaurov 1888f445c3 Access log: restricted "log_format" to "http" level.
Specifying the "log_format" directive on levels other than "http"
is deprecated since 73d37e1ccb91 (1.1.11).
2014-12-01 14:51:36 +03:00
Maxim Dounin 62db57f1f1 Write filter: fixed handling of sync bufs (ticket #132). 2014-11-28 16:58:39 +03:00
Maxim Dounin e795eca1cf Fixed post_action to not trigger "header already sent" alert.
The alert was introduced in 03ff14058272 (1.5.4), and was triggered on each
post_action invocation.

There is no real need to call header filters in case of post_action,
so return NGX_OK from ngx_http_send_header() if r->post_action is set.
2014-11-28 16:57:50 +03:00
Maxim Dounin c2ee3bf570 Typo. 2014-11-28 16:57:23 +03:00
Valentin Bartenev d45026a7be SPDY: push pending data while closing a stream as with keepalive.
This helps to avoid delays in sending the last chunk of data because
of bad interaction between Nagle's algorithm on nginx side and
delayed ACK on the client side.

Delays could also be caused by TCP_CORK/TCP_NOPUSH if SPDY was
working without SSL and sendfile() was used.
2014-11-21 22:51:49 +03:00
Vladimir Homutov 71870e9988 Syslog: allowed underscore symbol in tag (ticket #667). 2014-11-20 20:02:21 +03:00
Ruslan Ermilov 689a24e7dd Resolver: fixed debug event logging.
In 954867a2f0a6, we switched to using resolver node as the timer event data.
This broke debug event logging.

Replaced now unused ngx_resolver_ctx_t.ident with ngx_resolver_node_t.ident
so that ngx_event_ident() extracts something sensible when accessing
ngx_resolver_node_t as ngx_connection_t.
2014-11-20 15:24:42 +03:00
Ruslan Ermilov 19c855aa1a Resolver: fixed use-after-free memory access.
In 954867a2f0a6, we switched to using resolver node as the
timer event data, so make sure we do not free resolver node
memory until the corresponding timer is deleted.
2014-11-20 15:24:40 +03:00
Valentin Bartenev ed7361ebc3 Style. 2014-11-19 21:46:01 +03:00
Valentin Bartenev a74dfddfe2 Fixed type of sendfile() return value on Linux.
There was no real problem since the amount of bytes can be sent is limited by
NGX_SENDFILE_MAXSIZE to less than 2G.  But that can be changed in the future
2014-11-19 21:18:13 +03:00
Valentin Bartenev 810e212266 Moved writev() handling code to a separate function.
This reduces code duplication and unifies debug logging of the writev() syscall
among various send chain functions.
2014-08-13 15:11:45 +04:00
Valentin Bartenev e20c550471 Merged conditions in the ngx_*_sendfile_chain() functions.
No functional changes.
2014-08-13 15:11:45 +04:00
Valentin Bartenev 53b2418bf8 Moved the code for coalescing file buffers to a separate function. 2014-08-13 15:11:45 +04:00
Valentin Bartenev 5f1d63eeef Refactored ngx_solaris_sendfilev_chain().
Though ngx_solaris_sendfilev_chain() shouldn't suffer from the problem mentioned
in d1bde5c3c5d2 since currently IOV_MAX on Solaris is 16, but this follows the
change from 3d5717550371 in order to make the code look similar to other systems
and potentially eliminates the problem in the future.
2014-11-19 21:17:11 +03:00
Valentin Bartenev 20e03b44e9 Introduced the ngx_output_chain_to_iovec() function.
It deduplicates code of the send chain functions and uses only preallocated
memory, which completely solves the problem mentioned in d1bde5c3c5d2.
2014-10-07 11:38:57 +04:00
Valentin Bartenev a5457cc0c6 Renamed ngx_handle_sent_chain() to ngx_chain_update_sent().
No functional changes.
2014-11-19 21:16:19 +03:00
Piotr Sikora c2b74a6b30 Cache: add support for Cache-Control's s-maxage response directive.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-11-18 17:07:14 -08:00
Roman Arutyunyan 16ecfca0b1 Proxy: renamed and rearranged fields in proxy configuration.
No functional changes.
2014-11-19 17:33:24 +03:00
Roman Arutyunyan 6dbc18eddb Upstream: different header lists for cached and uncached requests.
The upstream modules remove and alter a number of client headers
before sending the request to upstream.  This set of headers is
smaller or even empty when cache is disabled.

It's still possible that a request in a cache-enabled location is
uncached, for example, if cache entry counter is below min_uses.
In this case it's better to alter a smaller set of headers and
pass more client headers to backend unchanged.  One of the benefits
is enabling server-side byte ranges in such requests.
2014-11-19 17:33:23 +03:00
Roman Arutyunyan f8b17cb207 Upstream: moved header lists to separate structures.
No functional changes.
2014-11-19 17:33:22 +03:00
Roman Arutyunyan c75a37b31d Upstream: moved header initializations to separate functions.
No functional changes.
2014-11-19 17:33:21 +03:00
Roman Arutyunyan 832de00dca Scgi: do not push redundant NULL element into conf->params. 2014-11-19 17:33:21 +03:00
Roman Arutyunyan 6ffc853f72 Cache: proxy_cache_lock_age and friends.
Once this age is reached, the cache lock is discarded and another
request can acquire the lock.  Requests which failed to acquire
the lock are not allowed to cache the response.
2014-11-18 20:41:12 +03:00
Valentin Bartenev 57a3cf665d SPDY: fixed check for too long header name or value.
For further progress a new buffer must be at least two bytes larger than
the remaining unparsed data.  One more byte is needed for null-termination
and another one for further progress.  Otherwise inflate() fails with
Z_BUF_ERROR.
2014-11-07 17:22:19 +03:00
Valentin Bartenev 7d81762dc1 SPDY: improved debug logging of inflate() calls. 2014-11-07 17:19:12 +03:00
Maxim Dounin ed42c02cdf SSL: logging level of "inappropriate fallback" (ticket #662).
Patch by Erik Dubbelboer.
2014-11-17 16:38:48 +03:00
Toshikuni Fukaya 609f814fae Upstream: support named location for X-Accel-Redirect. 2014-11-04 19:56:23 +09:00
Piotr Sikora 0d2f0d7a06 Upstream: add "proxy_ssl_certificate" and friends.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-10-30 04:30:41 -07:00
Maxim Dounin 14ab8702ac SPDY: fixed "too long header line" logging.
This fixes possible one byte buffer overrun and makes sure ellipsis are
always added, see 21043ce2a005.
2014-11-07 17:38:55 +03:00
Maxim Dounin b60e5afb58 Cache: removed dead store in ngx_http_file_cache_vary_header().
Found by Clang Static Analyzer.
2014-11-05 18:53:26 +03:00
Valentin Bartenev ed0aa05a35 Access log: cancel the flush timer on graceful shutdown.
Previously, it could prevent a worker process from exiting
for up to the configured flush timeout.
2014-08-25 13:41:31 +04:00
Valentin Bartenev 39a1597ff6 Events: introduced cancelable timers. 2014-08-13 22:45:04 +04:00
Valentin Bartenev c389fe9249 Events: simplified cycle in ngx_event_expire_timers(). 2014-08-25 13:37:06 +04:00
Valentin Bartenev 91d616bd6e Events: removed broken thread support from event timers.
It's mostly dead code.  And the idea of thread support for this task has
been deprecated.
2014-08-25 13:34:39 +04:00
Peter Wu 524f201196 Contrib: add more directives to vim syntax.
uwsgi is not a third-party module anymore. 'split_clients' is a new
block directive type. The directives were automatically extracted from
the ngx_command_t arrays, sorted in the C locale and inserted.

Trailing spaces got removed at some places.
2014-10-22 15:31:19 +02:00
Sergey Kandaurov 3cc52ae56e SSL: simplified ssl_password_file error handling.
Instead of collecting a number of the possible SSL_CTX_use_PrivateKey_file()
error codes that becomes more and more difficult with the rising variety of
OpenSSL versions and its derivatives, just continue with the next password.

Multiple passwords in a single ssl_password_file feature was broken after
recent OpenSSL changes (commit 4aac102f75b517bdb56b1bcfd0a856052d559f6e).

Affected OpenSSL releases: 0.9.8zc, 1.0.0o, 1.0.1j and 1.0.2-beta3.

Reported by Piotr Sikora.
2014-10-24 04:28:00 -07:00
Piotr Sikora 92d150d1cc SPDY: stop emitting multiple empty header values.
Previously, nginx would emit empty values in a header with multiple,
NULL-separated values.

This is forbidden by the SPDY specification, which requires headers to
have either a single (possibly empty) value or multiple, NULL-separated
non-empty values.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-10-27 14:25:56 -07:00
Valentin Bartenev eafd7116f0 Version bump. 2014-10-28 21:58:49 +03:00
Maxim Dounin 3d8846b4c5 release-1.7.7 tag 2014-10-28 18:04:46 +03:00
Maxim Dounin c7463f2227 nginx-1.7.7-RELEASE 2014-10-28 18:04:46 +03:00
Maxim Dounin f16e0e3ceb Updated OpenSSL used for win32 builds. 2014-10-28 17:35:00 +03:00
Kouhei Sutou c3ebaa6c3e Win32: made build-able with MinGW-w64 gcc. 2014-10-15 21:15:01 +09:00
Gu Feng 139fa91662 Upstream: limited next_upstream time and tries when resolving DNS.
When got multiple upstream IP addresses using DNS resolving, the number of
upstreams tries and the maxinum time spent for these tries were not affected.
This patch fixed it.
2014-10-27 19:52:03 +08:00
Roman Arutyunyan ab923bf5b5 Write filter: stored delay in a variable, no functional changes.
The code is now similar to ngx_event_pipe_read_upstream().
2014-10-28 12:29:59 +03:00
Roman Arutyunyan 6d324318e6 Upstream: proxy_limit_rate and friends.
The directives limit the upstream read rate.  For example,
"proxy_limit_rate 42" limits proxy upstream read rate to
42 bytes per second.
2014-10-28 12:29:59 +03:00
Roman Arutyunyan ac193357fa Core: added limit to recv_chain(). 2014-10-28 12:29:58 +03:00
Maxim Dounin 96db3c165c Cache: normalization of some Vary headers.
Spaces in Accept-Charset, Accept-Encoding, and Accept-Language headers
are now ignored.  As per syntax of these headers spaces can only appear
in places where they are optional.
2014-10-27 21:14:12 +03:00
Maxim Dounin d2d646e0b6 Cache: multiple variants of a resource now can be stored.
If a variant stored can't be used to respond to a request, the variant
hash is used as a secondary key.

Additionally, if we previously switched to a secondary key, while storing
a response to cache we check if the variant hash still apply.  If not, we
switch back to the original key, to handle cases when Vary changes.
2014-10-27 21:14:10 +03:00
Maxim Dounin 8814be7b19 Cache: c->reading flag introduced.
It replaces c->buf in checks in ngx_http_file_cache_open(), making it possible
to reopen the file without clearing c->buf.  No functional changes.
2014-10-27 21:14:07 +03:00
Maxim Dounin 9e21d76c07 Cache: hash of Vary headers now stored in cache.
To cache responses with Vary, we now calculate hash of headers listed
in Vary, and return the response from cache only if new request headers
match.

As of now, only one variant of the same resource can be stored in cache.
2014-10-27 21:13:58 +03:00
Maxim Dounin 09a2746546 Cache: disable caching of responses with Vary (ticket #118).
The "proxy_ignore_header" directive now undersands the "Vary" parameter
to ignore the header as needed.
2014-10-27 21:13:39 +03:00
Maxim Dounin 2e53744768 Gzip, gunzip: flush busy buffers if any.
Previous code resulted in transfer stalls when client happened
to read all the data in buffers at once, while all gzip buffers
were exhausted (but ctx->nomem wasn't set).  Make sure to call
next body filter at least once per call if there are busy buffers.

Additionally, handling of calls with NULL chain was changed to follow
the same logic, i.e., next body filter is only called with NULL chain
if there are busy buffers.  This is expected to fix "output chain is empty"
alerts as reported by some users after c52a761a2029 (1.5.7).
2014-10-15 22:57:23 +04:00
Maxim Dounin d688a41296 Style. 2014-10-14 20:19:36 +04:00
Roman Arutyunyan d6ed7812cc Upstream: proxy_force_ranges and friends.
The directives enable byte ranges for both cached and uncached
responses regardless of backend headers.
2014-10-14 18:32:01 +04:00
Kouhei Sutou 3da4471950 Win32: suppressed warnings by "-Werror=sign-compare". 2014-10-11 21:09:29 +09:00
Kouhei Sutou 4998846be0 Win32: fixed wrong type cast.
GetQueuedCompletionStatus() document on MSDN says the
following signature:

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa364986.aspx

    BOOL WINAPI GetQueuedCompletionStatus(
      _In_   HANDLE CompletionPort,
      _Out_  LPDWORD lpNumberOfBytes,
      _Out_  PULONG_PTR lpCompletionKey,
      _Out_  LPOVERLAPPED *lpOverlapped,
      _In_   DWORD dwMilliseconds
    );

In the latest specification, the type of the third argument
(lpCompletionKey) is PULONG_PTR not LPDWORD.
2014-10-11 20:56:35 +09:00
Maxim Dounin c030e197e6 Fixed possible buffer overrun in "too long header line" logging.
Additionally, ellipsis now always added to make it clear that
the header logged is incomplete.

Reported by Daniil Bondarev.
2014-10-08 17:16:04 +04:00
Yichun Zhang 6d26238b2d Core: fixed buffer overrun when hash max_size reached. 2014-10-02 12:00:17 -07:00
Piotr Sikora 98338b8a83 Upstream: fix $upstream_cache_last_modified variable.
Due to the u->headers_in.last_modified_time not being correctly initialized,
this variable was evaluated to "Thu, 01 Jan 1970 00:00:00 GMT" for responses
cached without the "Last-Modified" header which resulted in subsequent proxy
requests being sent with "If-Modified-Since: Thu, 01 Jan 1970 00:00:00 GMT"
header.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-10-01 15:48:53 -07:00
Valentin Bartenev ad5fe53010 Fixed counting of sent bytes in the send chain functions on EINTR.
Previously, a value of the "send" variable wasn't properly adjusted
in a rare case when syscall was interrupted by a signal.  As a result,
these functions could send less data than the limit allows.
2014-08-27 20:51:01 +04:00
Valentin Bartenev e9089c5f96 Version bump. 2014-10-02 22:36:27 +04:00
Maxim Dounin 3792703347 release-1.7.6 tag 2014-09-30 17:20:33 +04:00
Maxim Dounin 2f8545aeff nginx-1.7.6-RELEASE 2014-09-30 17:20:32 +04:00
Maxim Dounin eaf72f27d2 Upstream keepalive: reset c->sent on cached connections.
The c->sent is reset to 0 on each request by server-side http code,
so do the same on client side.  This allows to count number of bytes
sent in a particular request.
2014-09-29 22:27:45 +04:00
Valentin Bartenev a24780a682 Limit req: reduced number of parameters in the lookup function.
No functional changes.
2014-09-24 21:55:19 +04:00
Valentin Bartenev 5181bc99d7 Limit req: use complex value in limit_req_zone.
One intentional side effect of this change is that key is allowed only
in the first position.  Previously, it was possible to specify the key
variable at any position, but that was never documented, and is contrary
with nginx configuration practice for positional parameters.
2014-09-24 21:55:19 +04:00
Valentin Bartenev c6e9a5527f Limit conn: aligned field names in structures.
No functional changes.
2014-09-24 21:55:19 +04:00
Valentin Bartenev b7a468e83e Limit conn: use complex value in limit_conn_zone (ticket #121).
One intentional side effect of this change is that key is allowed only
in the first position.  Previously, it was possible to specify the key
variable at any position, but that was never documented, and is contrary
to nginx configuration practice for positional parameters.
2014-09-24 21:55:19 +04:00
Valentin Bartenev 1a729042d8 Limit conn: removed deprecated "limit_zone" directive.
It's deprecated since 260d591cb6a3 (1.1.8).  The "limit_conn_zone" directive
should be used instead.
2014-09-24 21:55:19 +04:00
Vladimir Homutov f6b25aca0f Syslog: improved error handling of unix domain sockets.
If a syslog daemon is restarted and the unix socket is used, further logging
might stop to work.  In case of send error, socket is closed, forcing
a reconnection at the next logging attempt.
2014-08-26 14:56:54 +04:00
Vladimir Homutov 641abffbd0 Syslog: enabled logging of send errors.
The ngx_cycle->log is used when sending the message.  This allows to log syslog
send errors in another log.

Logging to syslog after its cleanup handler has been executed was prohibited.
Previously, this was possible from ngx_destroy_pool(), which resulted in error
messages caused by attempts to write into the closed socket.

The "processing" flag is renamed to "busy" to better match its semantics.
2014-09-01 17:55:07 +04:00
Gu Feng 27fa7a1960 Avoided to add duplicate hash key in ngx_http_types_slot(). 2014-09-17 22:52:02 +08:00
Valentin Bartenev a48e405c94 Removed duplicate initialization of the "rev" variable. 2014-09-22 19:48:23 +04:00
Valentin Bartenev a44d8699ee Generalized definitions of the number of preallocated iovec's.
No functional changes.
2014-08-13 15:11:45 +04:00
Valentin Bartenev 64fe7be4e6 Reduced difference between the send chain functions.
No functional changes.  This follows the change from ad137a80919f.
2014-08-13 15:11:45 +04:00
Valentin Bartenev 33b474f52c Merged implementations of ngx_readv_chain().
There's no real need in two separate implementations,
with and without kqueue support.
2014-08-13 15:11:45 +04:00
Valentin Bartenev 9294ce37ae Removed the "complete" variable from various send chain functions.
It was made redundant by the previous change, since the "sent" variable
is no longer modified.
2014-08-13 15:11:45 +04:00
Valentin Bartenev 4e041362c1 Moved the code for adjusting sent buffers in a separate function. 2014-08-13 15:11:45 +04:00
Valentin Bartenev e8dd4c02ba Fixed writev() debug log message in ngx_darwin_sendfile_chain(). 2014-08-13 15:11:45 +04:00
Roman Arutyunyan 30491c6aaa Upstream: fixed file buffers reinit in ngx_http_upstream_reinit().
Previously, a file buffer start position was reset to the file start.
Now it's reset to the previous file buffer end.  This fixes
reinitialization of requests having multiple successive parts of a
single file.  Such requests are generated by fastcgi module.
2014-09-18 16:37:16 +04:00
Roman Arutyunyan 8d3f6bb56b FastCGI: fixed start pointers in request buffers.
The start pointers are used in ngx_http_upstream_reinit() to
reinit FastCGI requests.
2014-09-18 16:37:14 +04:00
Valentin Bartenev 615376266d Limit req: don't truncate key value to 255 bytes.
While the module allows to use values up to 65535 bytes as a key,
that actually never worked properly.
2014-09-16 21:12:51 +04:00
Valentin Bartenev 4a0f7f17ec Version bump. 2014-09-17 12:04:47 +04:00
Maxim Dounin d093fc4d9d release-1.7.5 tag 2014-09-16 16:19:03 +04:00
Maxim Dounin 5c2c7b5564 nginx-1.7.5-RELEASE 2014-09-16 16:19:03 +04:00
Maxim Dounin 0319876b17 Updated OpenSSL used for win32 builds. 2014-09-15 18:03:49 +04:00
Maxim Dounin 53b591ea67 SSL: session id context now includes certificate hash.
This prevents inappropriate session reuse in unrelated server{}
blocks, while preserving ability to restore sessions on other servers
when using TLS Session Tickets.

Additionally, session context is now set even if there is no session cache
configured.  This is needed as it's also used for TLS Session Tickets.

Thanks to Antoine Delignat-Lavaud and Piotr Sikora.
2014-09-15 17:59:47 +04:00
Valentin Bartenev 690f9c6beb Access log: fixed the "if=" parameter with buffering (ticket #625).
It might not work if there were more than one "access_log" directives
pointed to the same file and duplicate buffer parameters.
2014-09-13 21:47:13 +04:00
Roman Arutyunyan 15e01d1004 Upstream: limited next_upstream time and tries (ticket #544).
The new directives {proxy,fastcgi,scgi,uwsgi,memcached}_next_upstream_tries
and {proxy,fastcgi,scgi,uwsgi,memcached}_next_upstream_timeout limit
the number of upstreams tried and the maximum time spent for these tries
when searching for a valid upstream.
2014-09-12 18:50:47 +04:00
Roman Arutyunyan 67ce303415 Upstream: included backup peers into peer.tries.
Since peer.tries is never reset it can now be limited if required.
2014-09-12 18:50:46 +04:00
Maxim Dounin 9b6ada95a7 Upstream keepalive: removed "single" parameter remnants.
The "single" parameter is deprecated and ignored since 5b5c07dee156 (1.3.2).
2014-09-11 20:09:04 +04:00
Maxim Dounin ca7557baf7 Added warning about unset cache keys.
In fastcgi, scgi and uwsgi modules there are no default cache keys, and
using a cache without a cache key set is likely meaningless.
2014-09-11 20:08:52 +04:00
Maxim Dounin 3cc8001ed5 Style. 2014-09-11 20:08:45 +04:00
FengGu 42db7e5281 Upstream: avoided directly terminating the connection.
When memory allocation failed in ngx_http_upstream_cache(), the connection
would be terminated directly in ngx_http_upstream_init_request().
Return a INTERNAL_SERVER_ERROR response instead.
2014-08-13 14:53:55 +08:00
Maxim Dounin 9039bb52d8 Added ngx_init_setproctitle() return code check.
The ngx_init_setproctitle() function, as used on systems without
setproctitle(3), may fail due to memory allocation errors, and
therefore its return code needs to be checked.

Reported by Markus Linnala.
2014-09-08 21:36:09 +04:00
Maxim Dounin a09aacf2b0 Fixed ETag memory allocation error handling.
The etag->hash must be set to 0 to avoid an empty ETag header being
returned with the 500 Internal Server Error page after the memory
allocation failure.

Reported by Markus Linnala.
2014-09-08 21:36:03 +04:00
Maxim Dounin e87cb56698 Core: ngx_regex_compile() error handling fixes.
Now we actually return NGX_ERROR on errors, and provide an error
string for memory allocation errors.

Reported by Markus Linnala.
2014-09-08 21:35:53 +04:00
Piotr Sikora b2b1381cb6 SSL: guard use of all SSL options for bug workarounds.
Some of the OpenSSL forks (read: BoringSSL) started removing unused,
no longer necessary and/or not really working bug workarounds along
with the SSL options and defines for them.

Instead of fixing nginx build after each removal, be proactive
and guard use of all SSL options for bug workarounds.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-09-03 14:49:55 -07:00
Roman Arutyunyan a3703b9cfe Upstream: suppressed the file cache slab allocator error messages.
The messages "ngx_slab_alloc() failed: no memory in cache keys zone"
from the file cache slab allocator are suppressed since the allocation
is likely to succeed after the forced expiration of cache nodes.
The second allocation failure is reported.
2014-09-05 18:14:59 +04:00
Valentin Bartenev a5d6edf033 Events: processing of posted events changed from LIFO to FIFO.
In theory, this can provide a bit better distribution of latencies.

Also it simplifies the code, since ngx_queue_t is now used instead
of custom implementation.
2014-09-01 18:20:18 +04:00
Valentin Bartenev d5d69c3322 Events: removed broken thread support from posted events.
It's mostly dead code.  And the idea of thread support for this task has
been deprecated.
2014-09-01 18:20:03 +04:00
Valentin Bartenev 83a72de487 Mail: initialize the "signature" field of ngx_mail_session_t.
Currently it isn't used, but it can be suitable to distinguish
objects stored in c->data.
2014-09-01 17:50:59 +04:00
Ruslan Ermilov acea8f052e Upstream: improved configuration parser diagnostics.
Made it clear when the selected balancing method does not
support certain parameters of the "server" directive.
2014-09-01 12:27:38 +04:00
Sergey Kandaurov 39f8d589bc Headers filter: "add_header" with "always" parameter (ticket #98).
If specified, the header field is set regardless of the status code.
2014-08-29 18:00:10 +04:00
Maxim Dounin f9ba59739a Variables: updated list of prefixes in ngx_http_rewrite_set(). 2014-08-27 21:38:08 +04:00
Maxim Dounin 4d07be726f Variables: fixed non-indexed access of prefix vars (ticket #600).
Previously, a configuration like

    location / {
        ssi on;
        ssi_types *;
        set $http_foo "bar";
        return 200 '<!--#echo var="http_foo" -->\n';
    }

resulted in NULL pointer dereference in ngx_http_get_variable() as
the variable was explicitly added to the variables hash, but its
get_handler wasn't properly set in the hash.  Fix is to make sure
that get_handler is properly set by ngx_http_variables_init_vars().
2014-08-27 21:38:04 +04:00
Valentin Bartenev 144c192a35 SPDY: added a comment about handling stream with the timer set. 2014-08-18 13:23:45 +04:00
Valentin Bartenev 9b022a19bf SPDY: avoid setting timeout on stream events in ngx_http_writer().
The SPDY module doesn't expect timers can be set on stream events for reasons
other than delaying output.  But ngx_http_writer() could add timer on write
event if the delayed flag wasn't set and nginx is waiting for AIO completion.
That could cause delays in sending response over SPDY when file AIO was used.
2014-08-27 20:44:11 +04:00
Ruslan Ermilov 77e48aef64 Resolver: notify all waiting requests on timeout.
If a "resolver_timeout" occurs, only the first waiting request
was notified.  Other requests may hang forever.
2014-08-19 15:43:26 +04:00
Ruslan Ermilov 0f95935acc Stub status: corrected the "stub_status" directive.
The "stub_status" directive does not require an argument.
2014-08-26 17:35:23 +04:00
Valentin Bartenev 1ed59888ba Sub filter: fixed matching for a single character. 2014-08-25 16:08:55 +04:00
Valentin Bartenev 54130d70e6 Mail: fixed number of arguments allowed in the listen directive. 2014-08-20 13:13:27 +04:00
Valentin Bartenev a6bc36ffd6 Mail: fixed a comment.
There's no loc_conf in the mail module.
2014-08-20 13:13:27 +04:00
Roman Arutyunyan 13a04eec9d Mp4: use trak->smhd_size in ngx_http_mp4_read_smhd_atom().
Reported by Gang Li.
2014-08-19 14:13:39 +04:00
Sergey Kandaurov 0ceec98241 Image filter: downgrade strong etags to weak ones as needed. 2014-08-18 12:03:41 +04:00
Sergey Kandaurov c9a4828a3e Fixed typo. 2014-08-15 14:09:29 +04:00
Maxim Dounin 1bcc9884a9 Events: removed unused variable in ngx_poll_process_events(). 2014-08-10 17:44:46 +04:00
Yves Crespin bc85963789 Events: format specifier fixes. 2014-08-07 15:04:43 +02:00
Yves Crespin 842d6cdcbe Events: changed nevents type to unsigned in poll module. 2014-08-07 14:56:57 +02:00
Tatsuhiko Kubo 973a42a70b Style: use specified macro instead of magic-number. 2014-08-06 23:58:44 +09:00
Piotr Sikora 49683ce94e Perl: NULL-terminate argument list.
perl_parse() function expects argv/argc-style argument list,
which according to the C standard must be NULL-terminated,
that is: argv[argc] == NULL.

This change fixes a crash (SIGSEGV) that could happen because
of the buffer overrun during perl module initialization.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-06-19 04:16:36 -07:00
Maxim Dounin 2390f9ca59 Access log: allowed logs to syslog with "if=" (ticket #596). 2014-08-06 00:22:36 +04:00
Maxim Dounin 2c36a36728 Version bump. 2014-08-05 22:50:25 +04:00
Maxim Dounin 801816b8b8 release-1.7.4 tag 2014-08-05 15:13:05 +04:00
Maxim Dounin 20a5fbfca4 nginx-1.7.4-RELEASE 2014-08-05 15:13:04 +04:00
Maxim Dounin 31e6342552 Mail: discard pipelined commands after SMTP STARTTLS.
The bug had appeared in nginx 1.5.6 (04e43d03e153).

Reported by Chris Boulton.
2014-08-05 12:22:07 +04:00
Piotr Sikora 49d1ccb403 Core: exit on ngx_pnalloc() failure.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-08-01 20:39:22 -07:00
Tatsuhiko Kubo 6d6a529347 Style: use ngx_free() instead of free(). 2014-08-03 03:27:39 +09:00
Tatsuhiko Kubo 9a3e5369ca Core: improved ngx_pstrdup() error handling. 2014-08-01 20:04:14 +09:00
Sergey Kandaurov 119fe1a442 Status: indentation and style, no functional changes. 2014-08-01 18:36:35 +04:00
Piotr Sikora 011cea6337 Configure: remove outdated and unused patch.zlib.h.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-31 03:52:28 -07:00
FengGu 2259600108 Dav: ngx_http_map_uri_to_path() errors were not checked.
Once error occured, it could lead to use uninitialized variables to log,
even more segmentation fault.
2014-07-30 14:45:08 +08:00
Sergey Kandaurov c2d93973f9 Typos fixed. 2014-07-31 13:59:37 +04:00
Piotr Sikora b4dc99c6c3 SSL: let it build against LibreSSL.
LibreSSL developers decided that LibreSSL is OpenSSL-2.0.0, so tests
for OpenSSL-1.0.2+ are now passing, even though the library doesn't
provide functions that are expected from that version of OpenSSL.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-30 04:32:16 -07:00
Piotr Sikora 995faee182 SSL: let it build against BoringSSL.
This change adds support for using BoringSSL as a drop-in replacement
for OpenSSL without adding support for any of the BoringSSL-specific
features.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-30 04:32:15 -07:00
Piotr Sikora 7a4e1b2026 SSL: fix build with OPENSSL_NO_ENGINE and/or OPENSSL_NO_OCSP.
This is really just a prerequisite for building against BoringSSL,
which doesn't provide either of those features.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-28 12:27:57 -07:00
Maxim Dounin 4c54fe1103 Bigger iovec buffer in ngx_readv_chain().
This helps to reduce likelyhood of memory allocations in ngx_readv_chain(),
which are known to lead to noticeable effects in some cases, see
http://mailman.nginx.org/pipermail/nginx/2014-July/044512.html.
2014-07-28 18:30:19 +04:00
Maxim Dounin 403b8571b5 SSL: misplaced space in debug message. 2014-07-28 18:30:18 +04:00
Maxim Dounin 6d91f80cfd Upstream: SSL handshake timeouts.
Timeout may not be set on an upstream connection when we call
ngx_ssl_handshake() in ngx_http_upstream_ssl_init_connection(),
so make sure to arm it if it's not set.

Based on a patch by Yichun Zhang.
2014-07-28 18:30:14 +04:00
Yichun Zhang e0e3657952 GeoIP: not all variable fields were initialized.
The ngx_http_geoip_city_float_variable and
ngx_http_geoip_city_int_variable functions did not always initialize
all variable fields like "not_found", which could lead to empty values
for those corresponding nginx variables randomly.
2014-07-25 14:43:29 -07:00
Piotr Sikora 6473fcaede Core: use uppercase hexadecimal digits for percent-encoding.
RFC3986 says that, for consistency, URI producers and normalizers
should use uppercase hexadecimal digits for all percent-encodings.

This is also what modern web browsers and other tools use.

Using lowercase hexadecimal digits makes it harder to interact with
those tools in case when use of the percent-encoded URI is required,
for example when $request_uri is part of the cache key.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-06-26 23:39:23 -07:00
Vladimir Homutov 9ec4787c6a Core: fixed default log initialization.
The ngx_log_insert() function may invalidate pointer passed to it,
so make sure to don't use it after the ngx_log_insert() call.
2014-07-24 16:25:07 +04:00
Maxim Dounin 949f0b6101 Upstream: ngx_http_upstream_store() error handling fixes.
Previously, ngx_http_map_uri_to_path() errors were not checked in
ngx_http_upstream_store().  Moreover, in case of errors temporary
files were not deleted, as u->store was set to 0, preventing cleanup
code in ngx_http_upstream_finalize_request() from removing them.  With
this patch, u->store is set to 0 only if there were no errors.

Reported by Feng Gu.
2014-07-18 20:11:40 +04:00
Maxim Dounin 0ad24db986 Reset of r->uri.len on URI parsing errors.
This ensures that debug logging and the $uri variable (if used in
400 Bad Request processing) will not try to access uninitialized
memory.

Found by Sergey Bobrov.
2014-07-18 20:02:11 +04:00
Ruslan Ermilov b3da4cffab Resolver: fixed resend on malformed responses.
DNS request resend on malformed responses was broken in 98876ce2a7fd (1.5.8).

Reported by Pramod Korathota.
2014-07-16 10:21:28 +04:00
Piotr Sikora d87cae6655 SSL: fix build with recent OpenSSL.
X509_check_host() prototype changed recently:
- http://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=ced3d91
- http://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=297c67f

Bump version requirement, so that OpenSSL-1.0.2-beta1 uses fallback code.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-09 12:27:15 -07:00
Jianjun Zheng 967c02642f Core: bugfix for the ngx_slab_max_size case. 2014-06-18 16:39:59 +08:00
Tatsuhiko Kubo 643a0290d8 Style: use ngx_str_set(). 2014-07-09 23:23:59 +09:00
Tatsuhiko Kubo 436467c2d7 Style: use ngx_str_null(). 2014-07-09 23:22:14 +09:00
Tatsuhiko Kubo 0b5a602820 Style: use ngx_strlen() instead of strlen(). 2014-07-09 23:20:40 +09:00
Piotr Sikora e939a13b24 SPDY: fix support for headers with multiple values.
Split SPDY header with multiple, NULL-separated values:

    cookie: foo\0bar

into two separate HTTP headers with the same name:

    cookie: foo
    cookie: bar

Even though the logic for this behavior already existed
in the source code, it doesn't look that it ever worked
and SPDY streams with such headers were simply rejected.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-08 02:17:44 -07:00
Piotr Sikora 5f73f67523 Style: fix typo.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-08 03:03:14 -07:00
Piotr Sikora 3ba0bb56a5 Style: use ngx_memcpy() instead of memcpy().
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-08 03:03:14 -07:00
Piotr Sikora f552cc1e4f Style: keep return type and function name on different lines.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-08 03:03:14 -07:00
Piotr Sikora db21e902b9 Style: remove whitespace between function name and parentheses.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-08 03:03:14 -07:00
Piotr Sikora 58a5817fef Style: add whitespace between control statement and parentheses.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-08 03:03:13 -07:00
Piotr Sikora e55341c28a SSL: stop accessing SSL_SESSION's fields directly.
SSL_SESSION struct is internal part of the OpenSSL library and it's fields
should be accessed via API (when exposed), not directly.

The unfortunate side-effect of this change is that we're losing reference
count that used to be printed at the debug log level, but this seems to be
an acceptable trade-off.

Almost fixes build with -DOPENSSL_NO_SSL_INTERN.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-06 16:41:14 -07:00
Maxim Dounin a9b6e5ce4b SSL: fixed build with OPENSSL_NO_DEPRECATED defined.
The RSA_generate_key() is marked as deprecated and causes build to
fail.  On the other hand, replacement function, RSA_generate_key_ex(),
requires much more code.  Since RSA_generate_key() is only needed
for barely usable EXP ciphers, the #ifdef was added instead.

Prodded by Piotr Sikora.
2014-07-09 04:08:13 +04:00
Piotr Sikora 46492ca39d SSL: return temporary RSA key only when the key length matches.
This change is mostly cosmetic, because in practice this callback
is used only for 512-bit RSA keys.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-06 16:41:13 -07:00
Piotr Sikora 8302acb9c1 SSL: include correct OpenSSL headers.
Previously, <bn.h>, <dh.h>, <rand.h> and <rsa.h> were pulled in
by <engine.h> using OpenSSL's deprecated interface, which meant
that nginx couldn't have been built with -DOPENSSL_NO_DEPRECATED.

Both <x509.h> and <x509v3.h> are pulled in by <ocsp.h>, but we're
calling X509 functions directly, so let's include those as well.

<crypto.h> is pulled in by virtually everything, but we're calling
CRYPTO_add() directly, so let's include it as well.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-07-06 16:41:13 -07:00
Maxim Dounin de9fe6edf5 Version bump. 2014-07-09 03:15:00 +04:00
Maxim Dounin 61e08554c1 release-1.7.3 tag 2014-07-08 17:22:38 +04:00
Maxim Dounin bb195a2ea0 nginx-1.7.3-RELEASE 2014-07-08 17:22:38 +04:00
Maxim Dounin 43032d29c7 Win32: ngx_open_dir() and ngx_close_dir() fixes.
The ngx_open_dir() function changed to restore name passed to it.  This
fixes removing destination directory in dav module, as caught by dav.t.
The ngx_close_dir() function introduced to properly convert errors, as
FindClose() returns 0 on error.
2014-07-05 23:29:47 +04:00
Maxim Dounin eb39c8a5f3 Updated PCRE used for win32 builds. 2014-07-04 22:34:03 +04:00
Maxim Dounin e78b0625eb SSL: logging level of "peer closed connection in SSL handshake".
Previously, the NGX_LOG_INFO level was used unconditionally.  This is
correct for client SSL connections, but too low for connections to
upstream servers.  To resolve this, ngx_connection_error() now used
to log this error, it will select logging level appropriately.

With this change, if an upstream connection is closed during SSL
handshake, it is now properly logged at "error" level.
2014-07-04 22:14:36 +04:00
Maxim Dounin e6d6beb6e5 Upstream: p->downstream_error instead of closing connection.
Previously, nginx closed client connection in cases when a response body
from upstream was needed to be cached or stored but shouldn't be sent to
the client.  While this is normal for HTTP, it is unacceptable for SPDY.

Fix is to use instead the p->downstream_error flag to prevent nginx from
sending anything downstream.  To make this work, the event pipe code was
modified to properly cache empty responses with the flag set.
2014-07-04 20:47:16 +04:00
Valentin Bartenev 4e8ef22935 Upstream: fixed handling of write event after sending request.
The ngx_http_upstream_dummy_handler() must be set regardless of
the read event state.  This prevents possible additional call of
ngx_http_upstream_send_request_handler().
2014-07-01 20:52:08 +04:00
Valentin Bartenev 035b2b9706 SSL: the "ssl_password_file" directive. 2014-06-16 19:43:25 +04:00
Maxim Dounin 0301ed4d6c Configure: restored "nginx/" missed in 6e4bb1d6679d. 2014-06-26 05:08:59 +04:00
Maxim Dounin d55460d114 Core: removed meaningless check from ngx_palloc_block().
The check became meaningless after refactoring in 2a92804f4109.
With the loop currently in place, "current" can't be NULL, hence
the check can be dropped.

Additionally, the local variable "current" was removed to
simplify code, and pool->current now used directly instead.

Found by Coverity (CID 714236).
2014-06-26 03:34:19 +04:00
Maxim Dounin 037f75f886 Fixed wrong sizeof() in ngx_http_init_locations().
There is no real difference on all known platforms, but it's still wrong.

Found by Coverity (CID 400876).
2014-06-26 03:34:13 +04:00
Maxim Dounin bc915f5ed1 Core: plugged socket leak during configuration test.
This isn't really important as configuration testing shortly ends with
a process termination which will free all sockets, though Coverity
complains.

Prodded by Coverity (CID 400872).
2014-06-26 03:34:05 +04:00
Maxim Dounin 5fbb2c2c52 Configure: style. 2014-06-26 03:34:02 +04:00
Maxim Dounin df449a8c5c Upstream: cache revalidation using If-None-Match. 2014-06-26 02:35:01 +04:00
Maxim Dounin b393276eee Cache: ETag now saved into cache header. 2014-06-26 02:28:23 +04:00
Maxim Dounin 3e0eecc7a1 Cache: version in cache files.
This allows to change the structure of cache files without spamming logs
with false alerts.
2014-06-26 02:27:21 +04:00
Maxim Dounin 4f718ca939 Entity tags: explicit flag to skip not modified filter.
Previously, last_modified_time was tested against -1 to check if the
not modified filter should be skipped.  Notably, this prevented nginx
from additional If-Modified-Since (et al.) checks on proxied responses.
Such behaviour is suboptimal in some cases though, as checks are always
skipped on responses from a cache with ETag only (without Last-Modified),
resulting in If-None-Match being ignored in such cases.  Additionally,
it was not possible to return 412 from the If-Unmodified-Since if last
modification time was not known for some reason.

This change introduces explicit r->disable_not_modified flag instead,
which is set by ngx_http_upstream_process_headers().
2014-06-26 02:27:11 +04:00
Maxim Dounin 441dc49b97 Entity tags: weak comparison for If-None-Match. 2014-06-26 02:21:20 +04:00
Maxim Dounin fd96fae1df Entity tags: downgrade strong etags to weak ones as needed.
See http://mailman.nginx.org/pipermail/nginx-devel/2013-November/004523.html.
2014-06-26 02:21:01 +04:00
Maxim Dounin 5d82e10fa3 Upstream: fixed cache revalidation with SSI.
Previous code in ngx_http_upstream_send_response() used last modified time
from r->headers_out.last_modified_time after the header filter chain was
already called.  At this point, last_modified_time may be already cleared,
e.g., with SSI, resulting in incorrect last modified time stored in a
cache file.  Fix is to introduce u->headers_in.last_modified_time instead.
2014-06-26 02:20:09 +04:00
Maxim Dounin 6671f67e60 Upstream: removed unused offset to content_length.
It's not needed since introduction of ngx_http_upstream_content_length()
in 103b0d9afe07.
2014-06-26 02:20:05 +04:00
Maxim Dounin 5769a8be59 Upstream: no need to clear r->headers_out.last_modified_time.
Clearing of the r->headers_out.last_modified_time field if a response
isn't cacheable in ngx_http_upstream_send_response() was introduced
in 3b6afa999c2f, the commit to enable not modified filter for cacheable
responses.  It doesn't make sense though, as at this point header was
already sent, and not modified filter was already executed.  Therefore,
the line was removed to simplify code.
2014-06-26 02:19:58 +04:00
Maxim Dounin 4770a4f860 Not modified filter: debug log format fixed. 2014-06-26 02:19:55 +04:00
Ruslan Ermilov a6cb53208a Upstream: reduced diffs to the plus version of nginx.
No functional changes.
2014-06-20 12:55:41 +04:00
Sergey Kandaurov a21fdd087c FreeBSD has migrated to Bugzilla. 2014-06-19 13:55:59 +04:00
Ruslan Ermilov c21230c8ad Core: added ngx_slab_calloc() and ngx_slab_calloc_locked().
These functions return zeroed memory, analogous to ngx_pcalloc().
2014-06-04 15:09:19 +04:00
Ruslan Ermilov 4a8a1c9ae3 Version bump. 2014-06-18 13:39:20 +04:00
Maxim Dounin 6df4954bc7 release-1.7.2 tag 2014-06-17 16:51:25 +04:00
Maxim Dounin e3ac6b3aef nginx-1.7.2-RELEASE 2014-06-17 16:51:25 +04:00
Maxim Dounin 4f8d53957f Configure: workaround for system perl on OS X (ticket #576). 2014-06-17 12:07:06 +04:00
Maxim Dounin 9d4b05b085 Updated OpenSSL used for win32 builds. 2014-06-17 11:38:55 +04:00
Ruslan Ermilov 349045bfdd Upstream: simplified some code that accesses peers.
No functional changes.
2014-06-12 21:13:24 +04:00
Piotr Sikora 90ad417018 Access log: fix default value, broken by cb308813b453.
log->filter ("if" parameter) was uninitialized when the default value
was being used, which would lead to a crash (SIGSEGV) when access_log
directive wasn't specified in the configuration.

Zero-fill the whole structure instead of zeroing fields one-by-one
in order to prevent similar issues in the future.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-06-03 10:53:48 -07:00
Maxim Dounin 784ae16c2a Core: slab allocator free pages defragmentation.
Large allocations from a slab pool result in free page blocks being fragmented,
eventually leading to a situation when no further allocation larger than a page
size are possible from the pool.  While this isn't a problem for nginx itself,
it is known to be bad for various 3rd party modules.  Fix is to merge adjacent
blocks of free pages in the ngx_slab_free_pages() function.

Prodded by Wandenberg Peixoto and Yichun Zhang.
2014-06-03 17:53:03 +04:00
Roman Arutyunyan 3846484df1 Upstream: generic hash module. 2014-06-02 16:16:22 +04:00
Valentin Bartenev f9d13fce4c SPDY: fixed operator precedence in uint16/uint32 write macros.
Since the type cast has precedence higher than the bit shift operator,
all values were truncated to 8 bits.

These macros are used to construct header block for SYN_REPLY frame on
platforms with strict alignment requirements.  As a result, any response
that contains a header with name or value longer than 255 bytes was
corrupted on such platforms.
2014-05-29 21:15:19 +04:00
Sergey Kandaurov 5a897ea741 Fixed config parsing of the last try_files parameter.
Do not taste the last parameter against directory, as otherwise it would
result in the trailing slash being cut from the parameter value.

Notably, this prevents an internal redirect to an empty URI
if the parameter is set to the literal slash:

    location / { try_files $uri /; }
2014-05-28 20:18:05 +04:00
Maxim Dounin 109beffc45 Configure: added -Wno-deprecated-declarations on OS X.
Previous workaround to avoid warnings on OS X due to deprecated system
OpenSSL library (introduced in a3870ea96ccd) no longer works, as
the MAC_OS_X_VERSION_MIN_REQUIRED macro is ignored on OS X 10.9
if a compiler used supports __attribute__(availability).
2014-05-28 17:41:44 +04:00
Maxim Dounin d20fe0c90e Version bump. 2014-05-28 17:41:33 +04:00
Maxim Dounin ded1d2da40 release-1.7.1 tag 2014-05-27 17:58:09 +04:00
Maxim Dounin 24b9e41519 nginx-1.7.1-RELEASE 2014-05-27 17:58:08 +04:00
Maxim Dounin 7fc436a1e5 Sub filter: fixed subrequests handling.
In particular, properly output partial match at the end of a subrequest
response (much like we do at the end of a response), and reset/set the
last_in_chain flag as appropriate.

Reported by KAWAHARA Masashi.
2014-05-27 16:37:35 +04:00
Vladimir Homutov f562ab941c Syslog: fixed message sending on win32. 2014-05-27 15:42:34 +04:00
Vladimir Homutov 9b282558ab Syslog: fixed possible resource leak and more verbose logging.
Found by Coverity (CID 1215646).
2014-05-26 23:34:44 +04:00
Ruslan Ermilov d6fa79c68a Events: use eventfd() instead of syscall(SYS_eventfd) if possible.
This fixes --with-file-aio support on systems that lack eventfd()
syscall, notably aarch64 Linux.

The syscall(SYS_eventfd) may still be necessary on systems that
have eventfd() syscall in the kernel but lack it in glibc, e.g.
as seen in the current CentOS 5 release.
2014-05-23 16:37:05 +04:00
Roman Arutyunyan 1f5b73e644 Upstream: fix tries check in ip_hash.
Make two checks for maximum number of tries consistent.
The other one checks '>' condition.
2014-05-23 13:47:05 +04:00
Ruslan Ermilov dc9b6bd43b Mail: output client port number on client connects (ticket #531). 2014-05-22 00:16:17 +04:00
Ruslan Ermilov 7c1b279fae Core: output client port number when logging accept event. 2014-05-22 00:16:09 +04:00
Maxim Dounin 4071aae47a Mail: added a check for the number of arguments in MAIL/RCPT.
Missed during introduction of the SMTP pipelining support (04e43d03e153,
1.5.6).  Previously, the check wasn't needed as s->buffer was used directly
and the number of arguments didn't matter.

Reported by Svyatoslav Nikolsky.
2014-05-21 21:56:20 +04:00
Vladimir Homutov 4b60d6a406 Added syslog support for error_log and access_log directives. 2014-05-12 16:34:15 +04:00
Ruslan Ermilov b8950f0740 Configure: the --build= option.
If set, its value is output in "nginx -v" and in the error log.
2014-05-20 16:10:07 +04:00
Sergey Budnevitch 9120c620bb SSL: $ssl_client_fingerprint variable. 2014-05-20 14:03:03 +04:00
Maxim Dounin ee85516524 Setting $args now invalidates unparsed uri.
Prodded by Yichun Zhang.
2014-05-19 22:45:35 +04:00
Maxim Dounin 69e23d0917 Charset filter: fixed charset setting on encoded replies.
If response is gzipped we can't recode response, but in case it's not
needed we still can add charset to Content-Type.

The r->ignore_content_encoding is dropped accordingly, charset with gzip_static
now properly works without any special flags.
2014-05-19 22:45:34 +04:00
Maxim Dounin 078a4dce66 Fixed alias in regex locations with limit_except/if.
The ngx_http_map_uri_to_path() function used clcf->regex to detect if
it's working within a location given by a regular expression and have
to replace full URI with alias (instead of a part matching the location
prefix).  This is incorrect due to clcf->regex being false in implicit
locations created by if and limit_except.

Fix is to preserve relevant information in clcf->alias instead, by setting
it to NGX_MAX_SIZE_T_VALUE if an alias was specified in a regex location.
2014-05-16 17:42:24 +04:00
Valentin Bartenev 2423575dd4 SPDY: added protection from overrun of the receive buffer. 2014-04-30 20:34:20 +04:00
Valentin Bartenev b9eecee8be SPDY: added a debug point to the state buffer overflow protection. 2014-04-30 20:34:20 +04:00
Valentin Bartenev 4359ac4819 SPDY: refactored ngx_http_spdy_state_headers().
This change is similar to d2ac5cf4056d.  Special flag of completeness looks
surplus when there is also a counter of frame bytes left.
2014-04-30 20:34:20 +04:00
Valentin Bartenev a790ba6aa4 SPDY: improved logging. 2014-04-30 20:34:20 +04:00
Valentin Bartenev afda9c93b0 SPDY: set log action for PROXY protocol only while parsing it.
Handling of PROXY protocol for SPDY connection is currently implemented as
a SPDY state.  And while nginx waiting for PROXY protocol data it continues
to process SPDY connection: initializes zlib context, sends control frames.
2014-05-15 19:22:06 +04:00
Valentin Bartenev 33d63727c1 SPDY: ngx_http_spdy_state_headers() error handling cleanup.
- Specification-friendly handling of invalid header block or special headers.
   Such errors are not fatal for session and shouldn't lead to connection close;

 - Avoid mix of NGX_HTTP_PARSE_INVALID_REQUEST/NGX_HTTP_PARSE_INVALID_HEADER.
2014-04-30 20:34:20 +04:00
Valentin Bartenev 9994f10b6c SPDY: improved error handling of header block decompression.
Now cases when decompression failed due to internal error
and when a client sent corrupted data are distinguished.
2014-04-30 20:34:20 +04:00
Valentin Bartenev f4f4fe530d SPDY: removed ngx_http_spdy_state_headers_error().
The function just calls ngx_http_spdy_state_headers_skip() most of the time.
There was also an attempt of optimization to stop parsing if the client already
closed connection, but it looks strange and unfinished anyway.
2014-04-30 20:34:20 +04:00
Valentin Bartenev 7b2a6f21ae SPDY: prevented creation of RST_STREAM in protocol error state.
Previously, the frame wasn't sent anyway (and had a wrong status code).
2014-05-15 19:18:26 +04:00
Valentin Bartenev a1ed10a0ce SPDY: improved ngx_http_spdy_state_protocol_error().
Now ngx_http_spdy_state_protocol_error() is able to close stream,
so there is no need in a separate call for this.

Also fixed zero status code in logs for some cases.
2014-04-30 20:33:58 +04:00
Valentin Bartenev f4a88a915d SPDY: fixed one case of improper memory allocation error handling.
Now ngx_http_spdy_construct_request_line() doesn't try to finalize request
in case of failed memory allocation.
2014-04-30 02:16:21 +04:00
Ruslan Ermilov d455a580b3 Style: use %N instead of '\n' where appropriate. 2014-05-14 22:26:30 +04:00
Ruslan Ermilov b6e6fcb79e Core: use '\r' for CR and '\n' for LF definitions. 2014-05-14 22:26:05 +04:00
Filipe da Silva 942650c937 OCSP stapling: missing OCSP request free call. 2014-04-29 22:22:38 +02:00
Maxim Dounin 770133aa03 Upstream: restored workaround for "if".
The 7022564a9e0e changeset made ineffective workaround from 2464ccebdb52
to avoid NULL pointer dereference with "if".  It is now restored by
moving the u->ssl_name initialization after the check.

Found by Coverity (CID 1210408).
2014-04-30 19:16:55 +04:00
Maxim Dounin 24412a27a8 Core: improved ngx_conf_parse() error handling.
Previous code failed to properly restore cf->conf_file in case of
ngx_close_file() errors, potentially resulting in double free of
cf->conf_file->buffer->start.

Found by Coverity (CID 1087507).
2014-04-30 19:16:49 +04:00
Maxim Dounin 01d9a69fe8 Core: fixed error handling in ngx_reopen_files().
Found by Coverity (CID 1087509).
2014-04-30 19:16:40 +04:00
Maxim Dounin 169a17ef54 Cache: added ngx_quit check to ngx_http_file_cache_expire().
While managing big caches it is possible that expiring old cache items
in ngx_http_file_cache_expire() will take a while.  Added a check for
ngx_quit / ngx_terminate to make sure cache manager can be terminated
while in ngx_http_file_cache_expire().
2014-04-30 19:16:35 +04:00
Maxim Dounin 5746750a5d Configure: typo fixed. 2014-04-30 19:16:30 +04:00
Vladimir Homutov 99d319de9a Upstream: added the "$upstream_cookie_<name>" variables. 2014-04-29 12:28:41 +04:00
Valentin Bartenev 36fdd30560 Proxy: fixed possible uninitialized memory access.
The ngx_http_proxy_rewrite_cookie() function expects the value of the
"Set-Cookie" header to be null-terminated, and for headers obtained
from proxied server it is usually true.

Now the ngx_http_proxy_rewrite() function preserves the null character
while rewriting headers.

This fixes accessing memory outside of rewritten value if both the
"proxy_cookie_path" and "proxy_cookie_domain" directives are used in
the same location.
2013-11-18 03:06:45 +04:00
Valentin Bartenev 97112b6be4 Version bump. 2014-04-24 20:50:10 +04:00
Maxim Dounin b4beda1fcc release-1.7.0 tag 2014-04-24 16:54:23 +04:00
Maxim Dounin 14b7296d16 nginx-1.7.0-RELEASE 2014-04-24 16:54:22 +04:00
Maxim Dounin e0bf571690 SSL: explicit handling of empty names.
X509_check_host() can't handle non null-terminated names with zero length,
so make sure to fail before calling it.
2014-04-23 20:31:31 +04:00
Maxim Konovalov a7f81f83ee Missed comma fixed. A couple of Latin symbols plugged into
Russian text changed to Russian counterparts.
2014-04-23 16:00:59 +00:00
Ruslan Ermilov be2dc95766 Upstream: for ssl name, non-aligned memory allocation is enough. 2014-04-22 18:56:49 +04:00
Maxim Dounin 85ee306104 SSL: added explicit check for ngx_strlchr() result. 2014-04-22 14:02:45 +04:00
Valentin Bartenev de6ed06e5c SPDY: avoid sending RST_STREAM on WINDOW_UPDATE with unknown SID.
There's a race condition between closing a stream by one endpoint
and sending a WINDOW_UPDATE frame by another.  So it would be better
to just skip such frames for unknown streams, like is already done
for the DATA frames.
2014-04-21 19:21:17 +04:00
Valentin Bartenev 9e2a86bfdd SPDY: Stream-ID restrictions according to specification. 2014-04-21 18:59:53 +04:00
Ruslan Ermilov 2e1e9f9b32 Documented the switch from java XSLScript to xslscript.pl. 2014-04-21 13:48:41 +04:00
Maxim Dounin 7ed9555d60 Upstream: uwsgi_ssl_name, uwsgi_ssl_verify, and so on.
Just a merge of proxy_ssl_name, proxy_ssl_verify commits into uwsgi module,
code is identical.
2014-04-18 20:13:32 +04:00
Maxim Dounin 889c71b8a7 Upstream: proxy_ssl_verify and friends. 2014-04-18 20:13:30 +04:00
Maxim Dounin edacc6329f Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
These directives allow to switch on Server Name Indication (SNI) while
connecting to upstream servers.

By default, proxy_ssl_server_name is currently off (that is, no SNI) and
proxy_ssl_name is set to a host used in the proxy_pass directive.
2014-04-18 20:13:28 +04:00
Maxim Dounin c2413a5363 Upstream: plugged potential memory leak on reload.
The SSL_CTX_set_cipher_list() may fail if there are no valid ciphers
specified in proxy_ssl_ciphers / uwsgi_ssl_ciphers, resulting in
SSL context leak.

In theory, ngx_pool_cleanup_add() may fail too, but this case is
intentionally left out for now as it's almost impossible and proper fix
will require changes to http ssl and mail ssl code as well.
2014-04-18 20:13:24 +04:00
Maxim Dounin 01b7ea25b6 SSL: $ssl_server_name variable. 2014-04-18 20:13:21 +04:00
Maxim Dounin 74363a575d SSL: fixed misuse of NGX_LOG_DEBUG_HTTP. 2014-04-18 20:13:14 +04:00
Maxim Dounin 35890ef249 Version bump. 2014-04-18 20:12:53 +04:00
Sergey Kandaurov 3c3ed13fb2 Access log: the "if" parameter of the "access_log" directive.
The parameter value specifies a condition under which the request is logged.
2014-04-15 21:32:56 +04:00
Valentin Bartenev 26388db5f8 SPDY: fixed typo in log message. 2014-04-16 11:40:42 +04:00
Valentin Bartenev 4a15f81d1b Fixed missing "static" in declaration of ngx_http_gzip_quantity(). 2014-04-16 11:40:38 +04:00
Valentin Bartenev f36ddeca83 SPDY: moved a variable initialization near to its check.
This should prevent attempts of using pointer before it was checked, since
all modern compilers are able to spot access to uninitialized variable.

No functional changes.
2014-04-09 18:15:32 +04:00
Valentin Bartenev 0c82291660 SPDY: fixed arguments supplied for an error message. 2014-04-08 20:12:30 +04:00
Valentin Bartenev 9d1d0157fe Version bump. 2014-04-08 20:11:31 +04:00
Maxim Dounin a8960fa7b0 release-1.5.13 tag 2014-04-08 18:15:22 +04:00
Maxim Dounin c03aa237a7 nginx-1.5.13-RELEASE 2014-04-08 18:15:21 +04:00
Maxim Dounin d84452afcd Updated OpenSSL used for win32 builds. 2014-04-08 17:48:03 +04:00
Valentin Bartenev e1467c0ab2 SPDY: avoid creating flush frames.
Previously, an empty frame object was created for an output chain that contains
only sync or flush empty buffers.  But since 39d7eef2e332 every DATA frame has
the flush flag set on its last buffer, so there's no need any more in additional
flush buffers in the output queue and they can be skipped.

Note that such flush frames caused an incorrect $body_bytes_sent value.
2014-04-07 23:35:33 +04:00
Valentin Bartenev 02c65b2456 SPDY: consistently handle control frames with unknown type.
The SPDY draft 2 specification requires that if an endpoint receives a
control frame for a type it does not recognize, it must ignore the frame.
But the 3 and 3.1 drafts don't seem to declare any behavior for such case.
Then sticking with the previous draft in this matter looks to be right.

But previously, only 8 least significant bits of the type field were
parsed while the rest of 16 bits of the field were checked against zero.
Though there are no known frame types bigger than 255, this resulted in
inconsistency in handling of such frames: they were not recognized as
valid frames at all, and the connection was closed.
2014-04-07 19:27:56 +04:00
Valentin Bartenev 2fdaec779b SPDY: refactored ngx_http_spdy_state_read_data().
There's no more need in a separate indicator of frame completeness
after d74889fbf06d.
2014-04-07 19:27:56 +04:00
Valentin Bartenev dd39562802 SPDY: better detect premature closing of stream.
Following a24f88eff684, now the case when the FIN flag is set in SYN_STREAM
is also covered.
2014-04-07 19:27:56 +04:00
Maxim Dounin 5377a89133 Win32: fixed shared ssl_session_cache (ticket #528).
In a worker process shm_zone->data was set to NULL instead of a proper value
extracted from shared memory.
2014-04-07 18:55:57 +04:00
Maxim Dounin a19c448939 Win32: fixed link flags with MSVC, broken by bfe536716dbf.
Notably, "-debug" was omitted, resulting in an executable without debug
symbols.
2014-04-07 18:29:05 +04:00
Roman Arutyunyan 580c89edeb Mp4: allow end values bigger than track duration.
If start time is within the track but end time is out of it, error
"end time is out mp4 stts samples" is generated.  However it's
better to ignore the error and output the track until its end.
2014-04-01 20:53:18 +04:00
Maxim Dounin 03c8d9dbc8 Adjusted default value of types_hash_bucket_size (ticket #352).
The ngx_cacheline_size may be too low on some platforms, resulting
in unexpected hash build problems (as no collisions are tolerated due
to low bucket_size, and max_size isn't big enough to build a hash without
collisions).  These problems aren't fatal anymore but nevertheless
need to be addressed.
2014-03-31 22:47:42 +04:00
Maxim Dounin 9470666aab Core: fixed hash to actually try max_size.
Previously, maximum size of a hash table built was (max_size - 1).
2014-03-31 21:40:35 +04:00
Maxim Dounin 0c10c9a407 Core: hash now ignores bucket_size if it hits max_size limit. 2014-03-31 21:40:31 +04:00
Maxim Dounin 06de6927f8 Core: slab log_nomem flag.
The flag allows to suppress "ngx_slab_alloc() failed: no memory" messages
from a slab allocator, e.g., if an LRU expiration is used by a consumer
and allocation failures aren't fatal.

The flag is now used in the SSL session cache code, and in the limit_req
module.
2014-03-31 21:38:30 +04:00
Maxim Dounin 7a404a5ca1 Win32: fixed cpu hog by cache manager on exit (ticket #514).
The "ngx_quit" may be reset by the worker thread before it's seen
by a ngx_cache_manager_thread(), resulting in an infinite loop.  Make
sure to test ngx_exiting as well.
2014-03-31 21:38:28 +04:00
Maxim Dounin 3d9133e8f7 Mail: fixed ngx_mail_send() (ticket #519). 2014-03-31 21:38:27 +04:00
Maxim Dounin b75fd1bbfa Added #ifndef around NGX_HAVE_CASELESS_FILESYSTEM define.
This brings Cygwin compilation in line with other case-insensitive
systems (notably win32 and OS X) where one can force case sensitivity
using -DNGX_HAVE_CASELESS_FILESYSTEM=0.
2014-03-31 21:38:25 +04:00
Roman Arutyunyan b785090398 Mp4: improved logging after adding "end" support.
Despite introducing start and end crop operations existing log
messages still mostly refer only to start.  Logging is improved
to match both cases.

New debug logging is added to track entry count in atoms after
cropping.

Two format type mismatches are fixed as well.
2014-03-31 20:05:53 +04:00
Roman Arutyunyan 2ebc24d760 Mp4: fixed seeking to a track end.
When "start" value is equal to a track duration the request
fails with "time is out mp4 stts" like it did before track
duration check was added.  Now such tracks are considered
short and skipped.
2014-03-31 19:52:17 +04:00
Valentin Bartenev 1952fc8721 SPDY: detect premature closing of stream.
The SPDY/3.1 specification requires that the server must respond with
a 400 "Bad request" error if the sum of the data frame payload lengths
does not equal the size of the Content-Length header.

This also fixes "zero size buf in output" alert, that might be triggered
if client sends a greater than zero Content-Length header and closes
stream using the FIN flag with an empty request body.
2014-03-28 20:22:57 +04:00
Valentin Bartenev 6099267274 SPDY: fixed the DATA frame length handling in case of some errors.
There are a few cases in ngx_http_spdy_state_read_data() related to error
handling when ngx_http_spdy_state_skip() might be called with an inconsistent
state between *pos and sc->length, that leads to violation of frame layout
parsing and resuted in corruption of spdy connection.

Based on a patch by Xiaochen Wang.
2014-03-28 20:05:07 +04:00
Valentin Bartenev ebbfed12e1 SPDY: better detect if headers block has wrong entries count.
Previously, only one case was checked: if there's more data to parse
in a r->header_in buffer, but the buffer can be filled to the end by
the last parsed entry, so we also need to check that there's no more
data to inflate.
2014-03-26 18:01:11 +04:00
Valentin Bartenev e90a76a169 SPDY: detect premature end of frame while start parsing headers. 2014-03-26 17:43:39 +04:00
Piotr Sikora 2737a82d18 Apply underscores_in_headers also to the first character.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-03-24 16:35:44 -07:00
Andrei Belov 56e8a271c5 Increased default value of variables_hash_max_size. 2014-03-25 18:49:28 +04:00
Sergey Kandaurov a65486741c Mp4: skipped empty stss atom table in output.
The atom may have no data entries after cropping.

This fixes "zero size buf in output" alerts.
2014-03-24 17:55:10 +04:00
Maxim Dounin 01f60c1e7e Range filter: single_range flag in request.
If set, it means that response body is going to be in more than one buffer,
hence only range requests with a single range should be honored.

The flag is now used by mp4 and cacheable upstream responses, thus allowing
range requests of mp4 files with start/end, as well as range processing
on a first request to a not-yet-cached files with proxy_cache.

Notably this makes it possible to play mp4 files (with proxy_cache, or with
mp4 module) on iOS devices, as byte-range support is required by Apple.
2014-03-21 19:33:21 +04:00
Roman Arutyunyan d481e4278b Mp4: added "end" argument support. 2014-03-20 16:05:19 +04:00
Roman Arutyunyan 108ab70714 Mp4: moved atom cropping code out of update functions.
It can now be reused for implementing mp4 end.
2014-03-20 16:05:18 +04:00
Maxim Dounin 9b89fccf95 SPDY: improved ngx_http_spdy_state_save() again. 2014-03-19 19:30:09 +04:00
Maxim Dounin 93c521ba34 Macros used for initialization in ngx_http_core_init_main_conf(). 2014-03-19 12:57:40 +04:00
Maxim Dounin c42e01bef0 SPDY: improved ngx_http_spdy_state_save() check. 2014-03-19 12:57:39 +04:00
Maxim Dounin 1aa3ac0f21 SPDY: macro used for recv_buffer_size initialization. 2014-03-19 12:57:32 +04:00
Maxim Dounin f0f241438c Version bump. 2014-03-18 22:05:05 +04:00
Maxim Dounin e81eb56512 release-1.5.12 tag 2014-03-18 17:08:35 +04:00
Maxim Dounin 449bd12408 nginx-1.5.12-RELEASE 2014-03-18 17:08:35 +04:00
Maxim Dounin 405a8a0285 SPDY: always check size of data to be saved into state buffer. 2014-03-18 17:00:19 +04:00
Roman Arutyunyan db53bb57ad Added server-side support for PROXY protocol v1 (ticket #355).
Client address specified in the PROXY protocol header is now
saved in the $proxy_protocol_addr variable and can be used in
the realip module.

This is currently not implemented for mail.
2014-03-17 17:41:24 +04:00
Maxim Dounin 6ba16c8d38 FastCGI: f->split_parts reset on request start.
Additionally, make sure to check for errors from ngx_http_parse_header_line()
call after joining saved parts.  There shouldn't be any errors, though
check may help to catch bugs like missing f->split_parts reset.

Reported by Lucas Molas.
2014-03-17 15:34:36 +04:00
Maxim Dounin 341cea3911 Core: fixed wrong indices in listening sockets compare loops.
Proper use is "ls[i]" and "nls[n]".  Previous code used it wrong in
several places, likely due to cut-n-paste errors.
2014-03-07 15:17:38 +04:00
Filipe da Silva d9be39f6e8 MIME: added application/xspf+xml MIME type (ticket #479). 2014-03-06 10:51:08 +01:00
Sergey Kandaurov d46029f8e4 Added connection serial number in logging of left open sockets. 2014-03-06 23:15:10 +04:00
Sergey Kandaurov b4130d37a9 Fixed format specifier in logging of "c->number". 2014-03-06 18:25:59 +04:00
Roman Arutyunyan 4fc29dd65d MIME: added video/mp2t and application/vnd.apple.mpegurl types.
Both types are used by HLS.  The values are taken from RFC 3555
and HLS specification respectively.
2014-03-04 23:40:35 +04:00
Roman Arutyunyan 7ae7c9ae2c Version bump. 2014-03-04 23:38:31 +04:00
Maxim Dounin 61dd459ffb release-1.5.11 tag 2014-03-04 15:39:23 +04:00
Maxim Dounin f25bbfefa1 nginx-1.5.11-RELEASE 2014-03-04 15:39:23 +04:00
Valentin Bartenev 7322de2467 SPDY: fixed potential integer overflow while parsing headers.
Previously r->header_size was used to store length for a part of
value that represents an individual already parsed HTTP header,
while r->header_end pointed to the end of the whole value.

Instead of storing length of a following name or value as pointer
to a potential end address (r->header_name_end and r->header_end)
that might be overflowed, now r->lowercase_index counter is used
to store remaining length of a following unparsed field.

It also fixes incorrect $body_bytes_sent value if a request is
closed while parsing of the request header.  Since r->header_size
is intended for counting header size, thus abusing it for header
parsing purpose was certainly a bad idea.
2014-03-03 19:24:55 +04:00
Valentin Bartenev ef77bc359f SPDY: constant number of preallocated structures for headers. 2014-03-03 19:24:54 +04:00
Maxim Dounin 47a871f20a Request body: avoid potential overflow. 2014-03-03 17:39:53 +04:00
Valentin Bartenev 48a67e63f4 Gzip static: fixed NGX_CONF_FLAG misuse. 2014-03-03 17:17:25 +04:00
Maxim Dounin 04d5efb8df Docs: xslt regenerated. 2014-02-28 20:17:01 +04:00
Maxim Dounin 2ffeef9563 Docs: switched from java XSLScript to xslscript.pl.
Latter is available from http://hg.nginx.org/xslscript.
2014-02-28 20:17:00 +04:00
Maxim Dounin e154edc535 Disabled redirects to named locations if URI is not set.
If something like "error_page 400 @name" is used in a configuration,
a request could be passed to a named location without URI set, and this
in turn might result in segmentation faults or other bad effects
as most of the code assumes URI is set.

With this change nginx will catch such configuration problems in
ngx_http_named_location() and will stop request processing if URI
is not set, returning 500.
2014-02-27 20:36:35 +04:00
Ruslan Ermilov ac5637053b Core: allocate enough memory to hold IPv6 text address plus port. 2014-02-22 12:08:31 +04:00
Ruslan Ermilov 11e2bb1728 Resolver: properly handle connect() failures.
If initial attempt to connect() the UDP socket failed, e.g.
due to network unreachable, no further attempts were made.
2014-02-20 17:27:09 +04:00
Konstantin Pavlov 13c533bcb6 Upstream: fixed error message wording. 2014-02-20 13:48:40 +04:00
Ruslan Ermilov f39be31557 Access: supplemented the obfuscated code with a comment. 2014-02-19 21:45:27 +04:00
Maxim Dounin 252eb39e58 Upstream: ngx_post_event() instead of upgraded call (ticket #503).
If a request is finalized in the first call to the
ngx_http_upstream_process_upgraded() function, e.g., because upstream
server closed the connection for some reason, in the second call
the u->peer.connection pointer will be null, resulting in segmentation
fault.

Fix is to avoid second direct call, and post event instead.  This ensures
that ngx_http_upstream_process_upgraded() won't be called again if
a request is finalized.
2014-02-18 17:30:40 +04:00
Roman Arutyunyan 938885431d Mp4: remove useless leading stsc entry in result mp4.
The fix removes useless stsc entry in result mp4.
If start_sample == n then current stsc entry should be skipped
and the result stsc should start with the next entry.
The reason for that is start_sample starts from 0, not 1.
2014-02-14 15:14:48 +04:00
Maxim Dounin b0d01ba522 Win32: MSVC 2013 compatibility.
Warnings about GetVersionEx() deprecation silenced.  Precompiled object
linked in.
2014-02-13 16:54:00 +04:00
Valentin Bartenev 8ad68efadd SPDY: fixed reversed priority order in window waiting queue. 2014-02-12 21:02:29 +04:00
Piotr Sikora 95989ca208 Upstream: fix $upstream_status variable.
Previously, upstream's status code was overwritten with
cached response's status code when STALE or REVALIDATED
response was sent to the client.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-02-11 21:54:42 -08:00
Xiaochen Wang 34d18defcc SPDY: fixed parsing of http version.
There is an error while parsing multi-digit minor version numbers (e.g.
"HTTP/1.10").
2014-02-11 20:54:16 +08:00
Maxim Dounin 79fc8df2a3 SSL: the $ssl_session_reused variable. 2014-02-11 19:20:25 +04:00
Ruslan Ermilov a2e8837b09 Range filter: fixed duplicate charset.
If a proxied response had charset in Content-Type, the
charset was duplicated in a response to client request
with byte ranges.
2014-02-04 17:13:35 +04:00
Piotr Sikora c4c821abdf Use ngx_socket_errno where appropriate.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-02-03 14:17:17 -08:00
Maxim Dounin df015ade2b Version bump. 2014-02-05 18:51:30 +04:00
Maxim Dounin efd75c0c02 release-1.5.10 tag 2014-02-04 16:26:46 +04:00
Maxim Dounin 64a83cf639 nginx-1.5.10-RELEASE 2014-02-04 16:26:46 +04:00
Shigeki Ohtsu fbb0b5b2f2 SPDY: fixed parsing of the priority field.
The size of the priority field is increased by one bit in spdy/3,
and now it's a 3-bit field followed by 5 bits of unused space.
But a shift of these bits hasn't been adjusted in 39d7eef2e332
accordingly.
2014-02-04 14:06:23 +09:00
Maxim Dounin 2ac3db08c6 Updated PCRE used for win32 builds. 2014-02-04 07:45:33 +04:00
Maxim Dounin 70c40437eb Core: added ngx_encode_base64url(). 2014-02-04 04:59:21 +04:00
Piotr Sikora 03102b3350 Core: handle getsockopt(TCP_FASTOPEN) failures.
Linux returns EOPNOTSUPP for non-TCP sockets and ENOPROTOOPT for TCP
sockets, because getsockopt(TCP_FASTOPEN) is not implemented so far.

While there, lower the log level from ALERT to NOTICE to match other
getsockopt() failures.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-01-30 14:58:21 -08:00
Valentin Bartenev b418b56c38 SPDY: protocol implementation switched to spdy/3.1. 2014-01-31 19:17:26 +04:00
Vladimir Homutov 790ae59839 Fixed false compiler warning.
Newer gcc versions (4.7+) report possible use of uninitialized variable if
nginx is being compiled with -O3.
2014-01-31 14:18:52 +04:00
Ruslan Ermilov cbde76ba5a Fixed a compile warning introduced by 01e2a5bcdd8f.
On systems with OpenSSL that has NPN support but lacks
ALPN support, some compilers emitted a warning about
possibly uninitialized "data" variable.
2014-01-30 19:13:12 +04:00
Ruslan Ermilov f91d550eeb Proxy: fixed upstream search by proxy_pass with variables.
If "proxy_pass" is specified with variables, the resulting
hostname is looked up in the list of upstreams defined in
configuration.  The search was case-sensitive, as opposed
to the case of "proxy_pass" specified without variables.
2014-01-30 18:57:11 +04:00
Piotr Sikora 3be4fa0b9b SSL: support ALPN (IETF's successor to NPN).
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-01-28 15:33:49 -08:00
Roman Arutyunyan 9c08f2817c Mp4: fix seeks to standalone last chunk.
If seek position is within the last track chunk
and that chunk is standalone (stsc entry describes only
this chunk) such seek generates stsc seek error. The
problem is that chunk numbers start with 1, not with 0.
2014-01-29 13:44:15 +04:00
Roman Arutyunyan 9ff3f5c332 Mp4: skip tracks shorter than seek position (ticket #414).
Mp4 module does not check movie and track durations when reading
file.  Instead it generates errors when track metadata is shorter
than seek position.  Now such tracks are skipped and movie duration
check is performed at file read stage.
2014-01-29 13:33:45 +04:00
Roman Arutyunyan 94197fe613 Mp4: fix seeks after the last key frame.
Mp4 module does not allow seeks after the last key frame.  Since
stss atom only contains key frames it's usually shorter than
other track atoms.  That leads to stss seek error when seek
position is close to the end of file.  The fix outputs empty
stss frame instead of generating error.
2014-01-29 13:30:36 +04:00
Maxim Dounin 45bdf551ac Fixed TCP_DEFER_ACCEPT handling (ticket #353).
Backed out 05a56ebb084a, as it turns out that kernel can return connections
without any delay if syncookies are used.  This basically means we can't
assume anything about connections returned with deferred accept set.

To solve original problem the 05a56ebb084a tried to solve, i.e. to don't
wait longer than needed if a connection was accepted after deferred accept
timeout, this patch changes a timeout set with setsockopt(TCP_DEFER_ACCEPT)
to 1 second, unconditionally.  This is believed to be enough for speed
improvements, and doesn't imply major changes to timeouts used.

Note that before 2.6.32 connections were dropped after a timeout.  Though
it is believed that 1s is still appropriate for kernels before 2.6.32,
as previously tcp_synack_retries controlled the actual timeout and 1s results
in more than 1 minute actual timeout by default.
2014-01-28 15:40:46 +04:00
Maxim Dounin 8ee01e6040 SSI: fixed $date_local and $date_gmt without SSI (ticket #230).
If there is no SSI context in a given request at a given time,
the $date_local and $date_gmt variables used "%s" format, instead
of "%A, %d-%b-%Y %H:%M:%S %Z" documented as the default and used
if there is SSI module context and timefmt wasn't modified using
the "config" SSI command.

While use of these variables outside of the SSI evaluation isn't strictly
valid, previous behaviour is certainly inconsistent, hence the fix.
2014-01-28 15:40:45 +04:00
Ruslan Ermilov e3242cbdb1 Configure: enabled -Werror for clang.
Modern clang versions seem to no longer produce warnings for
system headers on Linux (at least clang 3.3 works), hence the
change.  For older versions --with-cc-opt="-Wno-error" can be
used as a workaround.
2014-01-28 00:31:31 +04:00
Tatsuhiko Kubo 6c1faab6f3 Typo fixed. 2014-01-23 22:09:59 +09:00
Maxim Dounin c91e3952bc SSL: fixed $ssl_session_id possible segfault after 97e3769637a7.
Even during execution of a request it is possible that there will be
no session available, notably in case of renegotiation.  As a result
logging of $ssl_session_id in some cases caused NULL pointer dereference
after revision 97e3769637a7 (1.5.9).  The check added returns an empty
string if there is no session available.
2014-01-23 18:32:26 +04:00
Maxim Dounin a843957e99 Version bump. 2014-01-23 18:32:25 +04:00
Maxim Dounin d93aced622 release-1.5.9 tag 2014-01-22 17:42:59 +04:00
Maxim Dounin d74797a0ff nginx-1.5.9-RELEASE 2014-01-22 17:42:59 +04:00
Maxim Dounin 502525879a Updated OpenSSL used for win32 builds. 2014-01-22 16:10:13 +04:00
Maxim Dounin 5f15656abf Upstream: reading from a client after connection upgrade.
Read event on a client connection might have been disabled during
previous processing, and we at least need to handle events.  Calling
ngx_http_upstream_process_upgraded() is a simpliest way to do it.

Notably this change is needed for select, poll and /dev/poll event
methods.

Previous version of this patch was posted here:
http://mailman.nginx.org/pipermail/nginx/2014-January/041839.html
2014-01-22 16:05:07 +04:00
Maxim Dounin 94ef9cee50 SSL: fixed $ssl_session_id variable.
Previously, it used to contain full session serialized instead of just
a session id, making it almost impossible to use the variable in a safe
way.

Thanks to Ivan Ristić.
2014-01-22 16:05:06 +04:00
Valentin Bartenev e4c99d7096 SPDY: use ngx_queue_t to queue streams for post processing.
It simplifies the code and allows easy reuse the same queue pointer to store
streams in various queues with different requirements.  Future implementation
of SPDY/3.1 will take advantage of this quality.
2014-01-20 20:56:49 +04:00
Valentin Bartenev a3f242bebf SPDY: store the length of frame instead of its whole size.
The "length" value better corresponds with the specification and reduces
confusion about whether frame's header is included in "size" or not.

Also this change simplifies some parts of code, since in more cases the
length of frame is more useful than its actual size, especially considering
that the size of frame header is constant.
2014-01-22 04:58:19 +04:00
Valentin Bartenev b6fb0e5a82 SPDY: use frame->next pointer to chain free frames.
There is no need in separate "free" pointer and like it is for ngx_chain_t
the "next" pointer can be used.  But after this change successfully handled
frame should not be accessed, so the frame handling cycle was improved to
store pointer to the next frame before processing.

Also worth noting that initializing "free" pointer to NULL in the original
code was surplus.
2014-01-22 04:58:19 +04:00
Valentin Bartenev fada62cc93 SPDY: proper handling of all RST_STREAM statuses.
Previously, only stream CANCEL and INTERNAL_ERROR were handled right.
2014-01-22 04:58:19 +04:00
Valentin Bartenev 8535eb8ef8 SPDY: removed state to check first SETTINGS frame.
That code was based on misunderstanding of spdy specification about
configuration applicability in the SETTINGS frames.  The original
interpretation was that configuration is assigned for the whole
SPDY connection, while it is only for the endpoint.

Moreover, the strange thing is that specification forbids multiple
entries in the SETTINGS frame with the same ID even if flags are
different.  As a result, Chrome sends two SETTINGS frames: one with
its own configuration, and another one with configuration stored
for a server (when the FLAG_SETTINGS_PERSIST_VALUE flags were used
by the server).

To simplify implementation we refuse to use the persistent settings
feature and thereby avoid all the complexity related with its proper
support.
2014-01-22 04:58:19 +04:00
Valentin Bartenev a2c80c5807 SPDY: better name for frame entries counter.
The "headers" is not a good term, since it is used not only to count
name/value pairs in the HEADERS block but to count SETTINGS entries too.

Moreover, one name/value pair in HEADERS can contain multiple http headers
with the same name.

No functional changes.
2014-01-22 04:58:19 +04:00
Valentin Bartenev 092faed9ba SPDY: fixed possible segfault.
While processing a DATA frame, the link to related stream is stored in spdy
connection object as part of connection state.  But this stream can be closed
between receiving parts of the frame.
2014-01-22 04:58:19 +04:00
Maxim Dounin 91a008fcce Typo fixed. 2014-01-21 17:39:49 +04:00
Ruslan Ermilov 13ff48812d Mail: fixed passing of IPv6 client address in XCLIENT. 2014-01-17 22:06:04 +04:00
Maxim Dounin 342927ca31 Core: improved ngx_reset_pool() (ticket #490).
Previously pool->current wasn't moved back to pool, resulting in blocks
not used for further allocations if pool->current was already moved at the
time of ngx_reset_pool().  Additionally, to preserve logic of moving
pool->current, the p->d.failed counters are now properly cleared.  While
here, pool->chain is also cleared.

This change is essentially a nop with current code, but generally improves
things.
2014-01-17 06:24:53 +04:00
Valentin Bartenev d62bcfe106 SPDY: send output queue after processing of read event.
During the processing of input some control frames can be added to the queue.
And if there were no writing streams at the moment, these control frames might
be left unsent for a long time (or even forever).

This long delay is especially critical for PING replies since a client can
consider connection as broken and then resend exactly the same request over
a new connection, which is not safe in case of non-idempotent HTTP methods.
2014-01-15 17:16:38 +04:00
Valentin Bartenev 6f435a53fe SPDY: the SETTINGS frame should be allocated from sc->pool.
There is no reason to allocate it from connection pool that more like just
a bug especially since ngx_http_spdy_settings_frame_handler() already uses
sc->pool to free a chain.
2014-01-15 17:16:38 +04:00
Valentin Bartenev 46438a9a15 SPDY: fixed possible uninitialized memory access.
The frame->stream pointer should always be initialized for control frames since
the check against it can be performed in ngx_http_spdy_filter_cleanup().
2014-01-15 17:16:38 +04:00
Valentin Bartenev 90ded8068c SPDY: fixed off_t/size_t type conversions on 32 bits platforms.
Parameters of ngx_http_spdy_filter_get_shadow() are changed from size_t to off_t
since the last call of the function may get size and offset from the rest of a
file buffer.  This fixes possible data loss rightfully complained by MSVC on 32
bits systems where off_t is 8 bytes long while size_t is only 4 bytes.

The other two type casts are needed just to suppress warnings about possible
data loss also complained by MSVC but false positive in these cases.
2014-01-15 13:23:31 +04:00
Valentin Bartenev 58c436e631 SPDY: fixed build, broken by b7ee1bae0ffa.
False positive warning about the "cl" variable may be uninitialized in
the ngx_http_spdy_filter_get_data_frame() call was suppressed.

It is always initialized either in the "while" cycle or in the following
"if" condition since frame_size cannot be zero.
2014-01-15 01:44:52 +04:00
Valentin Bartenev 1a972e9828 SPDY: added the "spdy_chunk_size" directive. 2014-01-14 16:24:45 +04:00
Valentin Bartenev b1a0b5644a SPDY: implemented buffers chain splitting.
It fixes "chain too big in spdy filter" alerts, and adds full support for rate
limiting of SPDY streams.
2014-01-14 16:24:45 +04:00
Valentin Bartenev 51347035ea SPDY: body filter was replaced by c->send_chain() function.
It allows to use ngx_http_write_filter() and all its rate limiting logic.
2014-01-14 16:24:45 +04:00
Valentin Bartenev db69888b48 SPDY: fixed possible premature close of stream.
The "delayed" flag always should be set if there are unsent frames,
but this might not be the case if ngx_http_spdy_body_filter() was
called with NULL chain.

As a result, the "send_timeout" timer could be set on a stream in
ngx_http_writer().  And if the timeout occurred before all the stream
data has been sent, then the request was finalized with the "client
timed out" error.
2014-01-14 16:24:45 +04:00
Valentin Bartenev 3a21e33ace SPDY: refactored ngx_http_spdy_body_filter().
A local pointer to fake connection is introduced
to slightly reduce further patches.

No functional changes.
2014-01-14 16:24:45 +04:00
Valentin Bartenev db5af0e702 SPDY: elimination of r->blocked counter usage for queuing frames.
It was used to prevent destroying of request object when there are unsent
frames in queue for the stream.  Since it was incremented for each frame
and is only 8 bits long, so it was not very hard to overflow the counter.

Now the stream->queued counter is checked instead.
2014-01-14 16:24:45 +04:00
Valentin Bartenev c53be33474 SPDY: better name for flag that indicates incomplete frame state.
No functional changes.
2014-01-14 16:24:45 +04:00
Valentin Bartenev addfe6d864 SPDY: better name for queued frames counter.
No functional changes.
2014-01-14 16:24:45 +04:00
Valentin Bartenev 466023cfa7 SPDY: fixed format specifiers in logging. 2014-01-14 16:24:45 +04:00
Valentin Bartenev c8d90b319d Year 2014. 2014-01-14 16:24:02 +04:00
Yichun Zhang cd4163e468 Resolver: added support for domain names with a trailing dot. 2014-01-10 11:22:14 -08:00
Maxim Dounin db0b20791f SSL: fixed ssl_verify_depth to take only one argument. 2014-01-14 15:56:40 +04:00
Dirkjan Bussink b804b230d8 SSL: ssl_session_tickets directive.
This adds support so it's possible to explicitly disable SSL Session
Tickets. In order to have good Forward Secrecy support either the
session ticket key has to be reloaded by using nginx' binary upgrade
process or using an external key file and reloading the configuration.
This directive adds another possibility to have good support by
disabling session tickets altogether.

If session tickets are enabled and the process lives for a long a time,
an attacker can grab the session ticket from the process and use that to
decrypt any traffic that occured during the entire lifetime of the
process.
2014-01-10 16:12:40 +01:00
Maxim Dounin f9c93e5e25 Fixed "zero size buf in output" alerts.
If a request had an empty request body (with Content-Length: 0), and there
were preread data available (e.g., due to a pipelined request in the buffer),
the "zero size buf in output" alert might be logged while proxying the
request to an upstream.

Similar alerts appeared with client_body_in_file_only if a request had an
empty request body.
2014-01-04 03:32:22 +04:00
Maxim Dounin 54016a7bb8 Win32: support for UTF-16 surrogate pairs (ticket #457). 2014-01-04 03:32:15 +04:00
Maxim Dounin 38579e5776 Upstream: Cache-Control preferred over Expires.
Not really a strict check (as X-Accel-Expires might be ignored or
contain invalid value), but quite simple to implement and better
than what we have now.
2014-01-04 03:32:10 +04:00
Maxim Dounin bfc6a5ff3f Added per-process random seeding (ticket #456). 2014-01-04 03:32:06 +04:00
Maxim Dounin 03537e1743 Allowed up to two EBUSY errors from sendfile().
Fallback to synchronous sendfile() now only done on 3rd EBUSY without
any progress in a row.  Not falling back is believed to be better
in case of occasional EBUSY, though protection is still needed to
make sure there will be no infinite loop.
2014-01-04 03:31:58 +04:00
Ruslan Ermilov 8bd3ee4e3c Fixed setting of content type in some cases.
This fixes content type set in stub_status and autoindex responses
to be usable in content type checks made by filter modules, such
as charset and sub filters.
2013-12-27 19:40:04 +04:00
Valentin Bartenev 34c2b11f0e Style: removed surplus semicolons. 2013-12-27 18:47:42 +04:00
Valentin Bartenev ea4b084b12 SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
There is no need to pass FLAG_FIN as a separate argument since it can always be
detected from the last_buf flag of the last frame buffer.

No functional changes.
2013-12-26 17:03:16 +04:00
Valentin Bartenev fb64d10af1 SPDY: refactored loop in ngx_http_spdy_body_filter().
No functional changes.
2013-12-26 17:03:16 +04:00
Valentin Bartenev bb1d72eedb SPDY: fixed possible request hang.
Processing events from upstream connection can result in sending queued frames
from other streams.  In this case such streams were not added to handling queue
and properly handled.

A global per connection flag was replaced by a per stream flag that indicates
currently sending stream while all other streams can be added to handling
queue.
2013-12-26 17:03:16 +04:00
Ruslan Ermilov 440b0c45ba Dav: emit a warning about unsafe URI. 2013-12-23 18:12:03 +04:00
Ruslan Ermilov 1a1c09d0f9 Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
This fixes handling of escaped URIs in X-Accel-Redirect (ticket #316),
SSI (ticket #240), and DAV.
2013-12-23 18:12:00 +04:00
Ruslan Ermilov 293154bd77 Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
The following URIs were considered safe: "..", "../foo", and "/foo/..".
2013-12-23 18:11:56 +04:00
Ruslan Ermilov ed7bedd6f9 Upstream: keep $upstream_http_x_accel_redirect intact.
When processing the X-Accel-Redirect header, the value of the
$upstream_http_x_accel_redirect variable was also overwritten.
2013-12-23 18:11:46 +04:00
Ruslan Ermilov fd94676d25 Fixed the first argument to getsockopt().
While here, always initialize the last argument.
2013-12-19 13:43:18 +04:00
Maxim Dounin 8b8850d193 SSL: ssl_buffer_size directive. 2013-12-20 16:18:25 +04:00
Vladimir Homutov 9aac58185f Upstream: simplified peer selection loop in the "ip_hash" module.
Conditions for skipping ineligible peers are rewritten to make adding of new
conditions simpler and be in line with the "round_robin" and "least_conn"
modules.  No functional changes.
2013-12-09 13:43:27 +04:00
Ruslan Ermilov a3a7964a94 Resolver: use minimum TTL for caching (ticket #329). 2013-12-16 19:12:23 +04:00
Maxim Dounin 48eef2312b Typo fixed. 2013-12-19 13:50:23 +04:00
Valentin Bartenev 7d17cba45d SPDY: use predefined constant for size of the Stream-ID field.
No functional changes.
2013-12-18 18:39:29 +04:00
Valentin Bartenev 45423b7ec8 Version bump. 2013-12-18 18:37:48 +04:00
Maxim Dounin ac55528901 release-1.5.8 tag 2013-12-17 17:46:26 +04:00
Maxim Dounin 0456eda184 nginx-1.5.8-RELEASE 2013-12-17 17:46:26 +04:00
Ruslan Ermilov 72d1ba17b4 Resolver: lookups are case-insensitive. 2013-12-13 20:49:52 +04:00
Ruslan Ermilov 1f7918b0f4 The "ipv6=" boolean parameter of the "resolver" directive.
When set to "off", only IPv4 addresses will be resolved,
and no AAAA queries are ever sent.
2013-12-09 10:53:30 +04:00
Ruslan Ermilov eae634973e Resolver: implemented IPv6 name to address resolving. 2013-12-09 10:53:28 +04:00
Ruslan Ermilov 813e15260f Resolver: implemented IPv6 address to name resolving. 2013-12-06 14:30:28 +04:00
Ruslan Ermilov 66ab1600f8 Changed resolver API to use ngx_addr_t. 2013-12-06 14:30:27 +04:00
Ruslan Ermilov 5958802463 Resolver: fixed indentation. 2013-12-13 19:22:44 +04:00
Ruslan Ermilov d12e6e2aac Core: externalized ngx_cmp_sockaddr().
It's also extended with the "cmp_port" argument to indicate
whether ports should be compared as well, or only addresses.
2013-12-06 14:30:27 +04:00
Ruslan Ermilov 62c3c806cc Resolver: fixes in PTR processing.
Verify that class of RR is "IN".
Verify that RR data length is non-zero.
2013-12-06 14:30:27 +04:00
Ruslan Ermilov ffb9bdb574 Resolver: fixes in A processing.
Verify that class of RR is "IN".
Verify that RR data length is exactly four octets.
Correctly shift to the next RR if RR type is unknown.
2013-12-06 14:30:27 +04:00
Ruslan Ermilov 757516ce14 Resolver: fixed response processing.
Stricten response header checks: ensure that reserved bits are zeroes,
and that the opcode is "standard query".

Fixed the "zero-length domain name in DNS response" condition.
2013-12-06 14:30:27 +04:00
Ruslan Ermilov 0fce5c8145 Resolver: removed unnecessary casts. 2013-12-06 14:30:27 +04:00
Ruslan Ermilov 878a57b383 Resolver: improved code readability.
Renamed ngx_resolver_query_t to ngx_resolver_hdr_t as it describes
the header that is common to DNS queries and answers.

Replaced the magic number 12 by the size of the header structure.

The other changes are self-explanatory.
2013-12-06 14:30:27 +04:00
Maxim Dounin 4fee3d87ea Trailing whitespace fix. 2013-12-12 20:28:48 +04:00
Valentin Bartenev 4645657b20 Use ngx_chain_get_free_buf() in pipe input filters.
No functional changes.
2013-12-11 21:30:38 +04:00
Valentin Bartenev 9f143cd0fe SPDY: drop the "delayed" flag when finalizing connection.
This flag in SPDY fake write events serves the same purposes as the "ready"
flag in real events, and it must be dropped if request needs to be handled.
Otherwise, it can prevent the request from finalization if ngx_http_writer()
was set, which results in a connection leak.

Found by Xiaochen Wang.
2013-12-10 20:27:33 +04:00
Ruslan Ermilov ada3a4845f Fixed handling of UNIX-domain sockets.
When evaluating $local_port, $server_port, and $server_addr,
UNIX-domain sockets were mistakenly interpreted as IPv4 sockets.
2013-12-09 10:16:44 +04:00
Ruslan Ermilov 561b7ca713 Core: keep the length of the local sockaddr. 2013-12-09 10:14:51 +04:00
Piotr Sikora ae71764222 Fixed incorrect ngx_str_set() usage, broken in c82b2e020b9f.
Found by Coverity Scan CID 1135525.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-12-06 16:00:49 -08:00
Maxim Dounin 4a356a434c Contrib: added vim to README. 2013-12-06 19:58:27 +04:00
Evan Miller b736deb882 Contrib: add vim scripts to contrib/ directory.
I've been maintaining these scripts independently for a while now, even though
I'm no longer active in the community. Seems to me that contrib/ is a good
long-term home for the scripts.
2013-12-04 14:45:44 -08:00
Ruslan Ermilov 97ef1e5308 Configure: enable -Wconditional-uninitialized with clang. 2013-12-06 13:16:56 +04:00
Maxim Dounin 67d71fe514 Fixed build without SSL, broken by c82b2e020b9f. 2013-12-04 23:13:13 +04:00
Maxim Dounin 1cdeb3d629 SSL support in the uwsgi module.
Based on patch by Roberto De Ioris.
2013-12-04 23:01:27 +04:00
Mathew Rodley eb320c97bd Added support for TCP_FASTOPEN supported in Linux >= 3.7.1.
---
 auto/unix                       | 12 ++++++++++++
 src/core/ngx_connection.c       | 32 ++++++++++++++++++++++++++++++++
 src/core/ngx_connection.h       |  4 ++++
 src/http/ngx_http.c             |  4 ++++
 src/http/ngx_http_core_module.c | 21 +++++++++++++++++++++
 src/http/ngx_http_core_module.h |  3 +++
 6 files changed, 76 insertions(+)
2013-12-03 22:07:03 +04:00
Maxim Dounin 252a0fe77a Fixed "setfib=" on non-first listening socket. 2013-12-03 21:44:08 +04:00
Vladimir Homutov 6dd2db6c39 Improved code readablity in ngx_http_upstream_init_round_robin().
Changed initialization order of the peer structure in one of the
cases to be in line with the rest.

No functional changes.
2013-12-03 17:12:16 +04:00
Ruslan Ermilov f6f3af3fdc Fixed null pointer dereference with $upstream_cache_last_modified. 2013-12-03 15:11:24 +04:00
Maxim Dounin 8c560ecb66 Win32: fixed init_process without master process (ticket #453).
Init process callbacks are called by ngx_worker_thread(), there is no
need to call them in ngx_single_process_cycle().
2013-11-29 17:23:47 +04:00
Maxim Dounin 5aabeb3b7b Upstream: skip empty cache headers.
Notably this fixes HTTP_IF_MODIFIED_SINCE which was always sent with
cache enabled in fastcgi/scgi/uwsgi after 43ccaf8e8728.
2013-11-29 17:23:38 +04:00
Maxim Dounin 90e57047c3 SSL: fixed c->read->ready handling in ngx_ssl_recv().
If c->read->ready was reset, but later some data were read from a socket
buffer due to a call to ngx_ssl_recv(), the c->read->ready flag should
be restored if not all data were read from OpenSSL buffers (as kernel
won't notify us about the data anymore).

More details are available here:
http://mailman.nginx.org/pipermail/nginx/2013-November/041178.html
2013-11-29 17:16:06 +04:00
Maxim Dounin 5e2d01c6c9 Version bump. 2013-11-29 17:11:36 +04:00
Maxim Dounin ede888dd53 release-1.5.7 tag 2013-11-19 14:03:47 +04:00
Maxim Dounin 4b2a7bf7c7 nginx-1.5.7-RELEASE 2013-11-19 14:03:47 +04:00
Ruslan Ermilov ebdda387f3 Proper backtracking after space in a request line. 2013-11-19 06:57:58 +04:00
Maxim Dounin 0c1b92a1c5 Upstream: cache revalidation with conditional requests.
The following new directives are introduced: proxy_cache_revalidate,
fastcgi_cache_revalidate, scgi_cache_revalidate, uwsgi_cache_revalidate.
Default is off.  When set to on, they enable cache revalidation using
conditional requests with If-Modified-Since for expired cache items.

As of now, no attempts are made to merge headers given in a 304 response
during cache revalidation with headers previously stored in a cache item.
Headers in a 304 response are only used to calculate new validity time
of a cache item.
2013-11-18 20:48:22 +04:00
Valentin Bartenev b14f0d6e96 SPDY: fixed request hang with the auth request module.
We should just call post_handler() when subrequest wants to read body, like
it happens for HTTP since rev. f458156fd46a.  An attempt to init request body
for subrequests results in hang if the body was not already read.
2013-11-11 18:49:35 +04:00
Piotr Sikora 3e5ae310c3 Configure: call "make distclean" for libatomic.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-11-11 01:59:47 -08:00
Piotr Sikora cf2c707667 Configure: call "make clean" for OpenSSL only if Makefile exists.
This change allows to build nginx against git checkout of OpenSSL.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-11-04 17:00:25 -08:00
Maxim Dounin b92aea581c Win32: plugged memory leak. 2013-10-31 18:23:49 +04:00
Maxim Dounin f838db35df Gunzip: proper error handling on gunzipping an empty response.
With previous code, an empty (malformed) response resulted in a request
finalized without sending anything to a client.
2013-10-31 04:16:20 +04:00
Maxim Dounin c6dd6753d1 Gunzip: "error" logging level on inflate() errors.
Errors can easily happen due to broken upstream responses, there is no
need to log them at "alert" level.
2013-10-31 04:12:53 +04:00
Maxim Dounin b4f1a48652 Removed extra allocation for $sent_http_last_modified.
There is no need to allocate memory for "Last-Modified: " string,
the variable only contains date itself.
2013-10-31 04:02:59 +04:00
Maxim Dounin bd464666a5 Auth basic: "info" logging level on no user/password.
This isn't an exceptional condition and normally happens on
first request from a client.
2013-10-31 04:02:21 +04:00
Yichun Zhang 1cd8d9a184 Gzip, gunzip: flush pending data when incoming chain is NULL. 2013-10-28 15:01:36 -07:00
Maxim Dounin c950c638b8 Core: handling of getsockopt(TCP_DEFER_ACCEPT) failures.
Recent Linux versions started to return EOPNOTSUPP to getsockopt() calls
on unix sockets, resulting in log pollution on binary upgrade.  Such errors
are silently ignored now.
2013-10-31 04:00:37 +04:00
Piotr Sikora 199050b638 Core: apply missed options to sockets added during binary upgrade.
The accept_filter and deferred options were not applied to sockets
that were added to configuration during binary upgrade cycle.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-10-24 14:18:37 -07:00
Xiaochen Wang 99be533e4d Upstream: optimize loops in ngx_http_upstream_init_round_robin(). 2013-10-21 18:20:32 +08:00
Maxim Dounin 17ec4ca498 Fixed "satisfy any" if 403 is returned after 401 (ticket #285).
The 403 (Forbidden) should not overwrite 401 (Unauthorized) as the
latter should be returned with the WWW-Authenticate header to request
authentication by a client.

The problem could be triggered with 3rd party modules and the "deny"
directive, or with auth_basic and auth_request which returns 403
(in 1.5.4+).

Patch by Jan Marc Hoffmann.
2013-10-18 18:13:49 +04:00
Maxim Dounin 3fbcc15ddd Headers filter: empty Cache-Control is no longer added.
Much like with other headers, "add_header Cache-Control $value;" no longer
results in anything added to response headers if $value evaluates to an
empty string.
2013-10-18 18:13:44 +04:00
Maxim Dounin d4d68a27ec Style. 2013-10-18 18:13:35 +04:00
Piotr Sikora 11cbc3162d SSL: added ability to set keys used for Session Tickets (RFC5077).
In order to support key rollover, ssl_session_ticket_key can be defined
multiple times. The first key will be used to issue and resume Session
Tickets, while the rest will be used only to resume them.

    ssl_session_ticket_key  session_tickets/current.key;
    ssl_session_ticket_key  session_tickets/prev-1h.key;
    ssl_session_ticket_key  session_tickets/prev-2h.key;

Please note that nginx supports Session Tickets even without explicit
configuration of the keys and this feature should be only used in setups
where SSL traffic is distributed across multiple nginx servers.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-10-11 16:05:24 -07:00
Maxim Dounin 316fed2254 SSL: SSL_CTX_set_timeout() now always called.
The timeout set is used by OpenSSL as a hint for clients in TLS Session
Tickets.  Previous code resulted in a default timeout (5m) used for TLS
Sessions Tickets if there was no session cache configured.

Prodded by Piotr Sikora.
2013-10-14 13:59:35 +04:00
Maxim Dounin 9588dccab4 SSL: fixed build with OpenSSL 0.9.7.
SSL_get_rbio() and SSL_get_wbio() functions used to get non-const pointer
in OpenSSL 0.9.7, hence an explicit cast added to drop const qualifier.
2013-10-14 13:44:09 +04:00
Maxim Dounin d58475b6d1 Limit req: fixed "nodelay" parsing.
Previously arguments starting with "nodelay" were considered valid,
e.g. "limit_req ... nodelayFOO;".
2013-10-02 15:07:17 +04:00
Maxim Dounin c8ee056b84 Upstream: fixed "down" and "backup" parsing.
Previously arguments starting with "down" or "backup" were considered
valid, e.g. "server ... downFOO;".
2013-10-02 15:07:15 +04:00
Sergey Kandaurov bae1f49c13 Unused macro and variable removed.
The macro NGX_HTTP_DAV_COPY_BLOCK is not used since 8101d9101ed8 (0.8.9).
The variable ngx_accept_mutex_lock_file was never used.
2013-10-02 11:51:04 +04:00
Sergey Kandaurov fce8f6755a Version bump. 2013-10-02 11:50:56 +04:00
Maxim Dounin c15e5b2c85 release-1.5.6 tag 2013-10-01 17:44:51 +04:00
Maxim Dounin a6622bc89d nginx-1.5.6-RELEASE 2013-10-01 17:44:51 +04:00
Valentin Bartenev 3a11ba49c9 SPDY: ignore priority when queuing blocked frames.
With this change all such frames will be added in front of the output queue, and
will be sent first.  It prevents HOL blocking when response with higher priority
is blocked by response with lower priority in the middle of the queue because
the order of their SYN_REPLY frames cannot be changed.

Proposed by Yury Kirpichev.
2013-10-01 00:14:37 +04:00
Valentin Bartenev 9f3d161ba9 SPDY: set empty write handler during connection finalization.
While ngx_http_spdy_write_handler() should not make any harm with current code,
calling it during finalization of SPDY connection was not intended.
2013-10-01 00:12:30 +04:00
Valentin Bartenev b6aa3459b9 SPDY: fixed connection leak while waiting for request headers.
If an error occurs in a SPDY connection, the c->error flag is set on every fake
request connection, and its read or write event handler is called, in order to
finalize it.  But while waiting for request headers, it was a no-op since the
read event handler had been set to ngx_http_empty_handler().
2013-10-01 00:04:00 +04:00
Valentin Bartenev 9433b1d7f6 SPDY: fixed connection leak while waiting for request body.
If an error occurs in a SPDY connection, the c->error flag is set on every fake
request connection, and its read or write event handler is called, in order to
finalize it.  But while waiting for a request body, it was a no-op since the
read event handler ngx_http_request_handler() calls r->read_event_handler that
had been set to ngx_http_block_reading().
2013-10-01 00:00:57 +04:00
Maxim Dounin 2e091c0366 Mail: fixed segfault with ssl/starttls at mail{} level and no cert.
A configuration like "mail { starttls on; server {}}" triggered NULL
pointer dereference in ngx_mail_ssl_merge_conf() as conf->file was not set.
2013-09-30 22:10:13 +04:00
Maxim Dounin 065f55f7de Mail: fixed overrun of allocated memory (ticket #411).
Reported by Markus Linnala.
2013-09-30 22:10:08 +04:00
Maxim Dounin b6f4c0dca6 Mail: handle smtp multiline replies.
See here for details:

http://nginx.org/pipermail/nginx/2010-August/021713.html
http://nginx.org/pipermail/nginx/2010-August/021784.html
http://nginx.org/pipermail/nginx/2010-August/021785.html
2013-09-30 22:10:03 +04:00
Maxim Dounin d92813e6c8 Mail: smtp pipelining support.
Basically, this does the following two changes (and corresponding
modifications of related code):

1. Does not reset session buffer unless it's reached it's end, and always
wait for LF to terminate command (even if we detected invalid command).

2. Record command name to make it available for handlers (since now we
can't assume that command starts from s->buffer->start).
2013-09-30 22:09:57 +04:00
Maxim Dounin f59a52b756 Mail: mail dependencies are now honored while building addons. 2013-09-30 22:09:54 +04:00
Maxim Dounin 7b469f9232 Mail: added session close on smtp_greeting_delay violation.
A server MUST send greeting before other replies, while before this
change in case of smtp_greeting_delay violation the 220 greeting was
sent after several 503 replies to commands received before greeting,
resulting in protocol synchronization loss.  Moreover, further commands
were accepted after the greeting.

While closing a connection isn't strictly RFC compliant (RFC 5321
requires servers to wait for a QUIT before closing a connection), it's
probably good enough for practial uses.
2013-09-30 22:09:50 +04:00
Maxim Dounin 9bc1f48a87 SSL: adjust buffer used by OpenSSL during handshake (ticket #413). 2013-09-27 19:39:33 +04:00
Maxim Dounin 5eedd56264 FastCGI: non-buffered mode support. 2013-09-27 16:50:40 +04:00
Maxim Dounin 3027634f2c Upstream: subrequest_in_memory support for SCGI and uwsgi enabled.
This was missed in 9d59a8eda373 when non-buffered support was added to SCGI
and uwsgi.
2013-09-27 16:50:34 +04:00
Maxim Dounin 70030dca84 Upstream: subrequest_in_memory fix.
With previous code only part of u->buffer might be emptied in case
of special responses, resulting in partial responses seen by SSI set
in case of simple protocols, or spurious errors like "upstream sent
invalid chunked response" in case of complex ones.
2013-09-27 16:50:26 +04:00
Maxim Dounin 1c437d9242 Upstream: proxy_no_cache, fastcgi_no_cache warnings removed. 2013-09-27 16:50:13 +04:00
Piotr Sikora 53a19e069f Proxy: added the "proxy_ssl_ciphers" directive.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-09-23 15:58:28 -07:00
Maxim Dounin 33e967095c Added ngx_filename_cmp() with "/" sorted to the left.
This patch fixes incorrect handling of auto redirect in configurations
like:

    location /0  { }
    location /a- { }
    location /a/ { proxy_pass ... }

With previously used sorting, this resulted in the following locations
tree (as "-" is less than "/"):

        "/a-"
    "/0"    "/a/"

and a request to "/a" didn't match "/a/" with auto_redirect, as it
didn't traverse relevant tree node during lookup (it tested "/a-",
then "/0", and then falled back to null location).

To preserve locale use for non-ASCII characters on case-insensetive
systems, libc's tolower() used.
2013-09-23 19:37:13 +04:00
Maxim Dounin f0b8308549 Caseless location tree construction (ticket #90).
Location tree was always constructed using case-sensitive comparison, even
on case-insensitive systems.  This resulted in incorrect operation if
uppercase letters were used in location directives.  Notably, the
following config:

    location /a { ... }
    location /B { ... }

failed to properly map requests to "/B" into "location /B".
2013-09-23 19:37:06 +04:00
Piotr Sikora 25a013919a SSL: stop loading configs with invalid "ssl_ciphers" values.
While there, remove unnecessary check in ngx_mail_ssl_module.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-09-22 22:36:11 -07:00
Markus Linnala 2e6f72160e Core: fix misallocation at ngx_crypt_apr1 (ticket #412).
Found by using auth_basic.t from mdounin nginx-tests under valgrind.

==10470== Invalid write of size 1
==10470==    at 0x43603D: ngx_crypt_to64 (ngx_crypt.c:168)
==10470==    by 0x43648E: ngx_crypt (ngx_crypt.c:153)
==10470==    by 0x489D8B: ngx_http_auth_basic_crypt_handler (ngx_http_auth_basic_module.c:297)
==10470==    by 0x48A24A: ngx_http_auth_basic_handler (ngx_http_auth_basic_module.c:240)
==10470==    by 0x44EAB9: ngx_http_core_access_phase (ngx_http_core_module.c:1121)
==10470==    by 0x44A822: ngx_http_core_run_phases (ngx_http_core_module.c:895)
==10470==    by 0x44A932: ngx_http_handler (ngx_http_core_module.c:878)
==10470==    by 0x455EEF: ngx_http_process_request (ngx_http_request.c:1852)
==10470==    by 0x456527: ngx_http_process_request_headers (ngx_http_request.c:1283)
==10470==    by 0x456A91: ngx_http_process_request_line (ngx_http_request.c:964)
==10470==    by 0x457097: ngx_http_wait_request_handler (ngx_http_request.c:486)
==10470==    by 0x4411EE: ngx_epoll_process_events (ngx_epoll_module.c:691)
==10470==  Address 0x5866fab is 0 bytes after a block of size 27 alloc'd
==10470==    at 0x4A074CD: malloc (vg_replace_malloc.c:236)
==10470==    by 0x43B251: ngx_alloc (ngx_alloc.c:22)
==10470==    by 0x421B0D: ngx_malloc (ngx_palloc.c:119)
==10470==    by 0x421B65: ngx_pnalloc (ngx_palloc.c:147)
==10470==    by 0x436368: ngx_crypt (ngx_crypt.c:140)
==10470==    by 0x489D8B: ngx_http_auth_basic_crypt_handler (ngx_http_auth_basic_module.c:297)
==10470==    by 0x48A24A: ngx_http_auth_basic_handler (ngx_http_auth_basic_module.c:240)
==10470==    by 0x44EAB9: ngx_http_core_access_phase (ngx_http_core_module.c:1121)
==10470==    by 0x44A822: ngx_http_core_run_phases (ngx_http_core_module.c:895)
==10470==    by 0x44A932: ngx_http_handler (ngx_http_core_module.c:878)
==10470==    by 0x455EEF: ngx_http_process_request (ngx_http_request.c:1852)
==10470==    by 0x456527: ngx_http_process_request_headers (ngx_http_request.c:1283)
==10470==
2013-09-20 17:57:21 +03:00
Andrei Belov a819d4dd47 Proxy: added the "proxy_ssl_protocols" directive. 2013-09-19 18:30:33 +04:00
Piotr Sikora 9e7bbd42ac SSL: fixed possible memory and file descriptor leak on HUP signal.
The problem appeared in 386a06a22c40 (1.3.7).

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-09-18 16:51:30 -07:00
Piotr Sikora 1045b7d7b7 MIME: added application/json MIME type.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-09-18 12:59:47 -07:00
Sergey Kandaurov 96c48e1536 Fixed response line formatting with empty reason phrase.
As per RFC 2616 sec 6.1 the response status code is always followed by SP.
2013-09-18 18:53:26 +04:00
Sergey Kandaurov c8a56732e8 Version bump. 2013-09-18 18:53:24 +04:00
Maxim Dounin 2d874d975a release-1.5.5 tag 2013-09-17 17:31:00 +04:00
Maxim Dounin 9ff1cca0fd nginx-1.5.5-RELEASE 2013-09-17 17:31:00 +04:00
Piotr Sikora f836257ce7 SSL: guard use of SSL_OP_MSIE_SSLV2_RSA_PADDING.
This option had no effect since 0.9.7h / 0.9.8b and it was removed
in recent OpenSSL.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-09-16 14:24:38 -07:00
Valentin Bartenev 732466f71b Improved check for duplicate path names in ngx_add_path().
The same path names with different "data" context should not be allowed.

In particular it rejects configurations like this:

    proxy_cache_path /var/cache/ keys_zone=one:10m max_size=1g inactive=5m;
    proxy_cache_path /var/cache/ keys_zone=two:20m max_size=4m inactive=30s;
2013-09-16 18:49:23 +04:00
Valentin Bartenev 179cdccc85 Removed surplus initializations from ngx_conf_set_path_slot().
An instance of ngx_path_t is already zeroed by ngx_pcalloc().
2013-09-16 18:49:22 +04:00
Valentin Bartenev 78e75480f4 Use ngx_pcalloc() in ngx_conf_merge_path_value().
It initializes the "data" pointer of ngx_path_t that will be checked after
subsequent changes.
2013-09-16 18:49:10 +04:00
Valentin Bartenev 4b2d7081ea Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
This allows to detect client connection close with pending data when
the ngx_http_test_reading() request event handler is set.
2013-09-16 18:33:39 +04:00
Valentin Bartenev 8bdeef9598 Upstream: use EPOLLRDHUP to check broken connections (ticket #320).
This allows to detect client connection close with pending data on Linux
while processing upstream.
2013-09-16 18:33:39 +04:00
Valentin Bartenev 6a0ea01e0c Events: support for EPOLLRDHUP (ticket #320).
Since Linux 2.6.17, epoll is able to report about peer half-closed connection
using special EPOLLRDHUP flag on a read event.
2013-07-12 14:51:07 +04:00
Valentin Bartenev 50add4e00f Events: removed unused flags from the ngx_event_s structure.
They are not used since 708f8bb772ec (pre 0.0.1).
2013-09-05 16:53:02 +04:00
Valentin Bartenev 587c51d5c9 Fixed handling of the ready flag with kqueue.
There is nothing to do more when recv() has returned 0,
so we should drop the flag.
2013-09-05 16:53:02 +04:00
Valentin Bartenev 038d47fdeb Return reason phrase for 414.
After 62be77b0608f nginx can return this code.
2013-09-03 21:07:19 +04:00
Maxim Dounin 089de975ea Upstream: fixed $upstream_response_time format specifiers. 2013-09-04 21:30:09 +04:00
Maxim Dounin 77e2279f47 Configure: TCP_KEEPIDLE test name simplified. 2013-09-04 21:17:05 +04:00
Maxim Dounin bcfe2e80bb Configure: fixed building with Sun C if CFLAGS set (ticket #65). 2013-09-04 21:17:03 +04:00
Maxim Dounin 0a33f34edd SSL: clear error queue after SSL_CTX_load_verify_locations().
The SSL_CTX_load_verify_locations() may leave errors in the error queue
while returning success (e.g. if there are duplicate certificates in the file
specified), resulting in "ignoring stale global SSL error" alerts later
at runtime.
2013-09-04 21:17:02 +04:00
Maxim Dounin e7b25cfb5a Fixed incorrect response line on "return 203".
Reported by Weibin Yao,
http://mailman.nginx.org/pipermail/nginx-devel/2013-April/003607.html.
2013-09-04 21:17:01 +04:00
Maxim Dounin 3391b24ae0 Request cleanup code unified, no functional changes.
Additionally, detaching a cleanup chain from a request is a bit more resilent
to various bugs if any.
2013-09-04 21:17:00 +04:00
Maxim Dounin d64e6560e1 Handling of ngx_int_t != intptr_t case.
Casts between pointers and integers produce warnings on size mismatch.  To
silence them, cast to (u)intptr_t should be used.  Prevoiusly, casts to
ngx_(u)int_t were used in some cases, and several ngx_int_t expressions had
no casts.

As of now it's mostly style as ngx_int_t is defined as intptr_t.
2013-09-04 21:16:59 +04:00
Maxim Dounin dc8bde53c7 Win32: $request_time fixed.
On win32, time_t is 64 bits wide by default, and passing an ngx_msec_int_t
argument for %T format specifier doesn't work.  This doesn't manifest itself
on other platforms as time_t and ngx_msec_int_t are usually of the same size.
2013-09-04 20:48:30 +04:00
Maxim Dounin 98f40476ad Win32: MinGW GCC compatibility.
Several warnings silenced, notably (ngx_socket_t) -1 is now checked
on socket operations instead of -1, as ngx_socket_t is unsigned on win32
and gcc complains on comparison.

With this patch, it's now possible to compile nginx using mingw gcc,
with options we normally compile on win32.
2013-09-04 20:48:28 +04:00
Maxim Dounin c3113c2b30 Win32: Borland C compatibility fixes.
Several false positive warnings silenced, notably W8012 "Comparing
signed and unsigned" (due to u_short values promoted to int), and
W8072 "Suspicious pointer arithmetic" (due to large type values added
to pointers).

With this patch, it's now again possible to compile nginx using bcc32,
with options we normally compile on win32 minus ipv6 and ssl.
2013-09-04 20:48:23 +04:00
Maxim Dounin 8c6d551127 Win32: Open Watcom C compatibility fixes.
Precompiled headers are disabled as they lead to internal compiler errors
with long configure lines.  Couple of false positive warnings silenced.
Various win32 typedefs are adjusted to work with Open Watcom C 1.9 headers.

With this patch, it's now again possible to compile nginx using owc386,
with options we normally compile on win32 minus ipv6 and ssl.
2013-09-04 20:48:22 +04:00
Valentin Bartenev 6ac81c18e4 Disable symlinks: removed recursive call of ngx_file_o_path_info().
It is surplus.
2013-09-02 20:06:03 +04:00
Valentin Bartenev 51a7051795 Disable symlinks: use O_PATH to open path components.
It was introduced in Linux 2.6.39, glibc 2.14 and allows to obtain
file descriptors without actually opening files.  Thus made it possible
to traverse path with openat() syscalls without the need to have read
permissions for path components.  It is effectively emulates O_SEARCH
which is missing on Linux.

O_PATH is used in combination with O_RDONLY.  The last one is ignored
if O_PATH is used, but it allows nginx to not fail when it was built on
modern system (i.e. glibc 2.14+) and run with a kernel older than 2.6.39.
Then O_PATH is unknown to the kernel and ignored, while O_RDONLY is used.

Sadly, fstat() is not working with O_PATH descriptors till Linux 3.6.
As a workaround we fallback to fstatat() with the AT_EMPTY_PATH flag
that was introduced at the same time as O_PATH.
2013-09-02 08:07:59 +04:00
Valentin Bartenev 28262c0990 Added the NGX_EBADF define. 2013-09-02 08:07:44 +04:00
Valentin Bartenev 08b929260b Assume the HTTP/1.0 version by default.
It is believed to be better than fallback to HTTP/0.9, because most of
the clients at present time support HTTP/1.0.  It allows nginx to return
error response code for them in cases when it fail to parse request line,
and therefore fail to detect client protocol version.

Even if the client does not support HTTP/1.0, this assumption should not
cause any harm, since from the HTTP/0.9 point of view it still a valid
response.
2013-09-02 03:45:14 +04:00
Maxim Dounin e5679e6a87 Upstream: setting u->header_sent before ngx_http_upstream_upgrade().
Without u->header_sent set a special response might be generated following
an upgraded connection.  The problem appeared in 1ccdda1f37f3 (1.5.3).
Catched by "header already sent" alerts in 1.5.4 after upstream timeouts.
2013-08-30 21:44:16 +04:00
Valentin Bartenev 4db2d4938c Referer: fixed hostname buffer overflow check.
Because of premature check the effective buffer size was 255 symbols
while the buffer is able to handle 256.
2013-08-29 22:35:54 +04:00
Sergey Kandaurov b90a7262fa Referer: "server_names" parsing deferred to merge phase.
This allows to approach "server_name" values specified below the
"valid_referers" directive when used within the "server_names" parameter, e.g.:

    server_name  example.org;
    valid_referers server_names;
    server_name  example.com;

As a bonus, this fixes bogus error with "server_names" specified several times.
2013-08-29 22:35:27 +04:00
Sergey Kandaurov 11ab9bb8f0 Referer: fixed server_name regex matching.
The server_name regexes are normally compiled for case-sensitive matching.
This violates case-insensitive obligations in the referer module.  To fix
this, the host string is converted to lower case before matching.

Previously server_name regex was executed against the whole referer string
after dropping the scheme part.  This could led to an improper matching, e.g.:

    server_name ~^localhost$;
    valid_referers server_names;

    Referer: http://localhost/index.html

It was changed to look only at the hostname part.

The server_name regexes are separated into another array to not clash with
regular regexes.
2013-08-29 22:35:26 +04:00
Sergey Kandaurov e0bd55e4ca Referer: fixed error type usage inconsistency for ngx_http_add*(). 2013-08-29 22:35:26 +04:00
Lanshun Zhou be9d517308 Image filter: large image handling.
If Content-Length header is not set, and the image size is larger than the
buffer size, client will hang until a timeout occurs.

Now NGX_HTTP_UNSUPPORTED_MEDIA_TYPE is returned immediately.

diff -r d1403de41631 -r 4fae04f332b4
src/http/modules/ngx_http_image_filter_module.c
2013-08-28 00:19:07 +08:00
Maxim Dounin d60b3d914c Typo fixed. 2013-08-28 02:34:30 +04:00
Maxim Dounin 23b17cbc02 Version bump. 2013-08-28 02:34:21 +04:00
Maxim Dounin 29caba9669 release-1.5.4 tag 2013-08-27 17:37:15 +04:00
Maxim Dounin 27c2b02591 nginx-1.5.4-RELEASE 2013-08-27 17:37:15 +04:00
Maxim Dounin a5ab953b84 Updated PCRE used for win32 builds.
As of PCRE 8.33, config.h.generic no longer contains boolean macros.  Two
of them (SUPPORT_PCRE8 and HAVE_MEMMOVE) were added to appropriate makefiles.
This allows PCRE 8.33 to compile and don't change anything for previous
versions.
2013-08-23 22:54:08 +04:00
Maxim Dounin 3b7444463f Configure: pcre.lib dependencies fix.
Previously, an attempt to build pcre.lib on win32 before anything else
failed due to no pcre.h.
2013-08-23 22:53:54 +04:00
Maxim Dounin 8884e2745c Cache: lock timeouts are now logged at info level. 2013-08-23 22:18:54 +04:00
Maxim Dounin 404b1c508f Upstream: posted requests handling after ssl handshake errors.
Missing call to ngx_http_run_posted_request() resulted in a main request hang
if subrequest's ssl handshake with an upstream server failed for some reason.

Reported by Aviram Cohen.
2013-08-23 22:18:46 +04:00
Maxim Dounin 081f407be9 Fixed try_files with empty argument (ticket #390). 2013-08-23 22:18:39 +04:00
Sergey Kandaurov 14a80e85fe MIME: eot MIME type updated to follow IANA (ticket #306). 2013-08-23 16:24:24 +04:00
Sergey Kandaurov 01262f849e MIME: added the most common OOXML MIME types (ticket #243). 2013-08-23 16:24:24 +04:00
Sergey Kandaurov 4c4c1f16ab MIME: added application/font-woff MIME type (ticket #292). 2013-08-23 16:24:23 +04:00
Maxim Dounin f2bca5fbf3 Added auth request to win32 builds. 2013-08-21 20:46:10 +04:00
Sergey Kandaurov 630789f7f4 Added safety belt for the case of sending header twice.
The aforementioned situation is abnormal per se and as such it now forces
request termination with appropriate error message.
2013-07-30 15:04:46 +04:00
Sergey Kandaurov 7067d80b93 Autoindex: improved ngx_de_info() error handling.
This allows to build a directory listing whenever a loop exists in symbolic
link resolution of the path argument.
2013-07-30 11:43:21 +04:00
Sergey Kandaurov c0bd2b039e Autoindex: return NGX_ERROR on error if headers were sent.
This prevents ngx_http_finalize_request() from issuing
ngx_http_special_response_handler() on a freed context.
2013-07-30 11:43:21 +04:00
Maxim Dounin 3a6f2bc98c Style improved after 12dd27b74117. 2013-08-20 21:33:43 +04:00
Maxim Dounin 0335d5143b Backed out f1a91825730a and 7094bd12c1ff.
While ngx_get_full_name() might have a bit more descriptive arguments,
the ngx_conf_full_name() is generally easier to use when parsing
configuration and limits exposure of cycle->prefix / cycle->conf_prefix
details.
2013-08-20 21:11:19 +04:00
Maxim Dounin b261aefe78 Auth request module import. 2013-08-21 19:19:47 +04:00
Maxim Dounin 7e28dede8b Minor ngx_http_parse_request_line() optimization.
Noted by Nils Kuhnhenn.
2013-08-21 12:51:31 +04:00
Sergey Kandaurov 2994e51332 Format specifier fixes in error logging. 2013-08-20 20:47:16 +04:00
Maxim Dounin 9e0576dfb6 Whitespace fix. 2013-08-17 16:54:55 +04:00
Valentin Bartenev d4e53b28fb SPDY: alert about activated fake events instead of deleting them.
They refer to the same socket descriptor as our real connection, and
deleting them will stop processing of the connection.

Events of fake connections must not be activated, and if it happened there
is nothing we can do.  The whole processing should be terminated as soon as
possible, but it is not obvious how to do this safely.
2013-08-15 19:16:12 +04:00
Valentin Bartenev 00e47db3e7 SPDY: do not reject headers with empty value (ticket #396).
A quote from SPDY draft 2 specification: "The length of each name and
value must be greater than zero.  A receiver of a zero-length name or
value must send a RST_STREAM with code PROTOCOL error."

But it appears that Chrome browser allows sending requests over SPDY/2
connection using JavaScript that contain headers with empty values.

For better compatibility across SPDY clients and to be compliant with
HTTP, such headers are no longer rejected.

Also, it is worth noting that in SPDY draft 3 the statement has been
changed so that it permits empty values for headers.
2013-08-15 19:16:09 +04:00
Valentin Bartenev b6bf25e3f0 SPDY: fixed corruption of headers with names longer than 255.
It is a bad idea to put zero byte in position where the length of
the next header name can be stored before it was parsed.
2013-08-15 19:14:58 +04:00
Valentin Bartenev 57d9af1130 Unbreak building on Linux without sendfile64() support.
It was broken in 8e446a2daf48 when the NGX_SENDFILE_LIMIT constant was added
to ngx_linux_sendfile_chain.c having the same name as already defined one in
ngx_linux_config.h.

The newer is needed to overcome a bug in old Linux kernels by limiting the
number of bytes to send per sendfile() syscall.  The older is used with
sendfile() on ancient kernels that works with 32-bit offsets only.

One of these renamed to NGX_SENDFILE_MAXSIZE.
2013-08-15 19:14:33 +04:00
Sergey Kandaurov becb186153 Referer module: fixed regex matching against HTTPS referers.
When matching a compiled regex against value in the "Referer" header field,
the length was calculated incorrectly for strings that start from "https://".
This might cause matching to fail for regexes with end-of-line anchors.

Patch by Liangbin Li.
2013-08-13 17:47:04 +04:00
Gleb Smirnoff e0cdce9b76 Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
In ngx_*_sendfile_chain() when calculating pointer to a first
non-zero sized buf, use "in" as iterator.  This fixes processing
of zero sized buf(s) after EINTR.  Otherwise function can return
zero sized buf to caller, and later ngx_http_write_filter()
logs warning.
2013-08-08 15:06:39 +04:00
Sergey Budnevitch 8cc618f140 Fixed misleading example SSL config.
a) ssl as listen parameter is preferable.
b) ssl_protocols defaults are better because they do not forbid TLS versions
   1.1 and 1.2.
c) ssl_session_timeout has sense only with SSL cache.
2013-08-07 20:01:43 +04:00
Valentin Bartenev b4bad635df API change: removed the ngx_conf_full_name() function.
The ngx_get_full_name() should be used instead.
2013-08-06 19:58:40 +04:00
Valentin Bartenev 1ba76fed4c Replaced ngx_conf_full_name() with ngx_get_full_name().
The ngx_get_full_name() function takes more readable arguments list.
2013-08-06 19:58:40 +04:00
Valentin Bartenev 37929ea7bd Fixed memory leaks in the root and auth_basic_user_file directives.
If a relative path is set by variables, then the ngx_conf_full_name()
function was called while processing requests, which causes allocations
from the cycle pool.

A new function that takes pool as an argument was introduced.
2013-08-06 19:58:40 +04:00
Valentin Bartenev 74b34e9513 Image filter: use "application/json" MIME type for JSON output.
As it is defined by RFC 4627, and allows for various browser tools like
JSONView to display JSON well-formatted.
2013-08-05 14:30:03 +04:00
Ruslan Ermilov 784f6ac953 Core: guard use of AI_ADDRCONFIG.
Some systems (notably NetBSD and OpenBSD) lack AI_ADDRCONFIG support.

Reported by Piotr Sikora.
2013-08-05 13:44:56 +04:00
Maxim Dounin 4c58c9424d Fixed build with signed socklen_t and unix sockets.
This seems to be the case at least under Cygwin, where build was broken
by 05ba5bce31e0 (1.5.3).

Reported by Kevin Worthington,
http://mailman.nginx.org/pipermail/nginx/2013-August/040028.html.
2013-08-05 11:40:33 +04:00
Ruslan Ermilov 4ea173e06e Core: only resolve address families configured on the local system.
This is done by passing AI_ADDRCONFIG to getaddrinfo().

On Linux, setting net.ipv6.conf.all.disable_ipv6 to 1 will now be
respected.

On FreeBSD, AI_ADDRCONFIG filtering is currently implemented by
attempting to create a datagram socket for the corresponding family,
which succeeds even if the system doesn't in fact have any addresses
of that family configured.  That is, if the system with IPv6 support
in the kernel doesn't have IPv6 addresses configured, AI_ADDRCONFIG
will filter out IPv6 only inside a jail without IPv6 addresses or
with IPv6 disabled.
2013-08-05 10:55:59 +04:00
Valentin Bartenev a15541168b MIME: use "application/javascript" for .js files.
Though there are several MIME types commonly used for JavaScript nowadays,
the most common being "text/javascript", "application/javascript", and
currently used by nginx "application/x-javascript", RFC 4329 prefers
"application/javascript".

The "charset_types" directive's default value was adjusted accordingly.
2013-07-31 23:40:46 +04:00
Sergey Kandaurov ecd0675d7b Version bump. 2013-07-31 18:35:57 +04:00
Sergey Kandaurov 393529a9d3 Configure: fixed autotest cleanup commands.
Previously, if configured with --with-cc="clang -g", the autotest.dSYM
directories were left unremoved.
2013-07-31 18:16:40 +04:00
Maxim Dounin eddfa735d3 release-1.5.3 tag 2013-07-30 17:27:55 +04:00
Maxim Dounin 6e41da0e8f nginx-1.5.3-RELEASE 2013-07-30 17:27:55 +04:00
Sergey Kandaurov a344712243 Perl: fixed syntax usage for C preprocessor directives.
As per perlxs, C preprocessor directives should be at the first
non-whitespace of a line to avoid interpreting them as comments.

#if and #endif are moved so that there are no blank lines before them
to retain them as part of the function body.
2013-07-29 17:30:01 +04:00
Ruslan Ermilov 1fac169aa3 Upstream: reliably detect connection failures with SSL peers. 2013-07-29 13:23:16 +04:00
Maxim Dounin 5b947ec9ab Upstream: no last buffer on errors.
Previously, after sending a header we always sent a last buffer and
finalized a request with code 0, even in case of errors.  In some cases
this resulted in a loss of ability to detect the response wasn't complete
(e.g. if Content-Length was removed from a response by gzip filter).

This change tries to propogate to a client information that a response
isn't complete in such cases.  In particular, with this change we no longer
pretend a returned response is complete if we wasn't able to create
a temporary file.

If an error code suggests the error wasn't fatal, we flush buffered data
and disable keepalive, then finalize request normally.  This allows to to
propogate information about a problem to a client, while still sending all
the data we've got from an upstream.
2013-07-25 15:00:41 +04:00
Maxim Dounin f60921a099 Upstream: request finalization rework.
No semantic changes expected, though some checks are done differently.
In particular, the r->cached flag is no longer explicitly checked.  Instead,
we relay on u->header_sent not being set if a response is sent from
a cache.
2013-07-25 15:00:29 +04:00
Maxim Dounin 69bfb41e22 Upstream: NGX_HTTP_CLIENT_CLOSED_REQUEST no longer reset to 0.
The NGX_HTTP_CLIENT_CLOSED_REQUEST code is allowed to happen after we
started sending a response (much like NGX_HTTP_REQUEST_TIME_OUT), so there
is no need to reset response code to 0 in this case.
2013-07-25 15:00:25 +04:00
Maxim Dounin 2a05da7ad3 Upstream: added check if a response is complete.
Checks were added to both buffered and unbuffered code paths to detect
and complain if a response is incomplete.  Appropriate error codes are
now passed to ngx_http_upstream_finalize_request().

With this change in unbuffered mode we now use u->length set to -1 as an
indicator that EOF is allowed per protocol and used to indicate response
end (much like its with p->length in buffered mode).  Proxy module was
changed to set u->length to 1 (instead of previously used -1) in case of
chunked transfer encoding used to comply with the above.
2013-07-25 15:00:12 +04:00
Maxim Dounin 0dd364c15d Upstream: u->length now defaults to -1 (API change).
That is, by default we assume that response end is signalled by
a connection close.  This seems to be better default, and in line
with u->pipe->length behaviour.

Memcached module was modified accordingly.
2013-07-25 14:58:11 +04:00
Maxim Dounin 56b422d2a9 Upstream: fixed store/cache of unfinished responses.
In case of upstream eof, only responses with u->pipe->length == -1
are now cached/stored.  This ensures that unfinished chunked responses
are not cached.

Note well - previously used checks for u->headers_in.content_length_n are
preserved.  This provides an additional level of protection if protol data
disagree with Content-Length header provided (e.g., a FastCGI response
is sent with wrong Content-Length, or an incomple SCGI or uwsgi response),
as well as protects from storing of responses to HEAD requests.  This should
be reconsidered if we'll consider caching of responses to HEAD requests.
2013-07-25 14:56:59 +04:00
Maxim Dounin d9e52e119d Upstream: replaced u->pipe->temp_file with p->temp_file.
While here, redundant parentheses removed.  No functional changes.
2013-07-25 14:56:49 +04:00
Maxim Dounin 29b24ac818 Upstream: NGX_ERROR after pipe errors. 2013-07-25 14:56:41 +04:00
Maxim Dounin c1aaf829bd Upstream: NGX_HTTP_GATEWAY_TIME_OUT after upstream timeouts.
There is no real difference from previously used 0 as NGX_HTTP_* will
become 0 in ngx_http_upstream_finalize_request(), but the change
preserves information about a timeout a bit longer.  Previous use of
ETIMEDOUT in one place was just wrong.

Note well that with cacheable responses there will be a difference
(code in ngx_http_upstream_finalize_request() will store the error
in cache), though this change doesn't touch cacheable case.
2013-07-25 14:56:20 +04:00
Maxim Dounin ba4cf2ed1b Upstream: ngx_http_upstream_finalize_request(NGX_ERROR) on errors.
Previously, ngx_http_upstream_finalize_request(0) was used in most
cases after errors.  While with current code there is no difference,
use of NGX_ERROR allows to pass a bit more information into
ngx_http_upstream_finalize_request().
2013-07-25 14:56:13 +04:00
Maxim Dounin 57a7b0f783 Upstream: consistent error handling after u->input_filter_init().
In all cases ngx_http_upstream_finalize_request() with NGX_ERROR now used.
Previously used NGX_HTTP_INTERNAL_SERVER_ERROR in the subrequest in memory
case don't cause any harm, but inconsistent with other uses.
2013-07-25 14:56:00 +04:00
Maxim Dounin 7f28f0f465 Upstream: busy lock remnants removed. 2013-07-25 14:55:59 +04:00
Maxim Dounin dc1ff453fd Upstream: stale comments removed. 2013-06-13 19:52:31 +04:00
Maxim Dounin 36a1039e62 Gzip: clearing of c->buffered if all data are flushed.
This allows to finalize unfinished responses while still sending as
much data as available.
2013-07-25 14:55:32 +04:00
Maxim Dounin 0243370111 Event pipe: fixed writing cache header to a temp file.
With previous code the p->temp_file->offset wasn't adjusted if a temp
file was written by the code in ngx_event_pipe_write_to_downstream()
after an EOF, resulting in cache not being used with empty scgi and uwsgi
responses with Content-Length set to 0.

Fix it to call ngx_event_pipe_write_chain_to_temp_file() there instead
of calling ngx_write_chain_to_temp_file() directly.
2013-07-25 14:55:09 +04:00
Maxim Dounin ad92f54bc6 Fixed ngx_http_test_reading() to finalize request properly.
Previous code called ngx_http_finalize_request() with rc = 0.  This is
ok if a response status was already set, but resulted in "000" being
logged if it wasn't.  In particular this happened with limit_req
if a connection was prematurely closed during limit_req delay.
2013-06-14 20:56:07 +04:00
Maxim Dounin abe507d766 Sub filter: fixed matching after a partial match.
After a failed partial match we now check if there is another partial
match in previously matched substring to fix cases like "aab" in "aaab".

The ctx->saved string is now always sent if it's present on return
from the ngx_http_sub_parse() function (and reset accordingly).  This
allows to release parts of previously matched data.
2013-07-25 14:54:53 +04:00
Maxim Dounin 5c7b85beff Sub filter: fixed incomplete last buffer on partial match.
If a pattern was partially matched at a response end, partially matched
string wasn't send.  E.g., a response "fo" was truncated to an empty response
if partially mathed by a pattern "foo".
2013-07-25 14:54:48 +04:00
Maxim Dounin c227e958c5 Sub filter: flush buffers handling. 2013-07-25 14:54:47 +04:00
Maxim Dounin f5f1feae6f Sub filter: switched to ngx_chain_get_free_buf().
No functional changes.
2013-07-25 14:54:45 +04:00
Maxim Dounin 81305d80e2 Sub filter: stale comments removed. 2013-07-25 14:54:43 +04:00
Ruslan Ermilov 16d959e2ee On DragonFlyBSD, TCP_KEEPIDLE and TCP_KEEPINTVL are in msecs.
Based on a patch by Sepherosa Ziehau.
2013-07-25 12:46:03 +04:00
Ruslan Ermilov 8028c23764 Style: reuse one int variable in ngx_configure_listening_sockets().
No functional changes.
2013-07-25 12:46:02 +04:00
Valentin Bartenev 223a4e7c37 SPDY: fixed segfault with "client_body_in_file_only" enabled.
It is possible to send FLAG_FIN in additional empty data frame, even if it is
known from the content-length header that request body is empty.  And Firefox
actually behaves like this (see ticket #357).

To simplify code we sacrificed our microoptimization that did not work right
due to missing check in the ngx_http_spdy_state_data() function for rb->buf
set to NULL.
2013-07-24 22:24:25 +04:00
Maxim Dounin cf8b7a5db6 Xslt: exsltRegisterAll() moved to preconfiguration.
The exsltRegisterAll() needs to be called before XSLT stylesheets
are compiled, else stylesheet compilation hooks will not work.  This
change fixes EXSLT Functions extension.
2013-07-19 15:59:50 +04:00
Valentin Bartenev 3b6d3efb39 Events: honor NGX_USE_GREEDY_EVENT when kqueue support is enabled.
Currently this flag is needed for epoll and rtsig, and though these methods
usually present on different platforms than kqueue, nginx can be compiled to
support all of them.
2013-07-13 03:24:30 +04:00
Maxim Dounin 3162bdc3ef Style. 2013-07-11 20:38:27 +04:00
Maxim Dounin 6d18315985 Configure: perl Makefile rebuild after configure.
The $NGX_AUTO_CONFIG_H added to perl module Makefile dependencies to
make sure it's always rebuild after a configure.  It is needed as we
expand various variables used for Makefile generation during configure
(in particular, nginx version).
2013-07-11 20:34:02 +04:00
Vladimir Homutov 59c9fb4821 Core: fixed possible use of an uninitialized variable.
The call to ngx_sock_ntop() in ngx_connection_local_sockaddr() might be
performed with the uninitialized "len" variable.  The fix is to initialize
variable to the size of corresponding socket address type.

The issue was introduced in commit 05ba5bce31e0.
2013-07-11 19:50:19 +04:00
Vladimir Homutov 8c0be99886 Core: extended ngx_sock_ntop() with socklen parameter.
On Linux, sockaddr length is required to process unix socket addresses properly
due to unnamed sockets (which don't have sun_path set at all) and abstract
namespace sockets.
2013-07-11 16:07:25 +04:00
Gleb Smirnoff a32d753122 Make macros safe. 2013-07-05 11:42:25 +04:00
Ruslan Ermilov ad1b01f828 Upstream: updated list of ngx_event_connect_peer() return values.
ngx_http_upstream_get_keepalive_peer() may return NGX_DONE to
indicate that the cached keepalive connection is reused.
2013-07-03 12:04:13 +04:00
Vladimir Homutov 469be19f4e Core: consolidated log-related code.
The stderr redirection code is moved to ngx_log_redirect_stderr().
The opening of the default log code is moved to ngx_log_open_default().
2013-06-28 17:24:54 +04:00
Maxim Dounin 12a76529c0 Version bump. 2013-07-02 20:05:49 +04:00
Maxim Dounin 084c2cdb8f release-1.5.2 tag 2013-07-02 16:28:51 +04:00
Maxim Dounin 0d6b1c32b1 nginx-1.5.2-RELEASE 2013-07-02 16:28:50 +04:00
Maxim Dounin 2dfdcac344 Fixed ngx_http_parse_chunked() minimal length calculation.
Minimal data length we expect for further calls was calculated incorrectly
if parsing stopped right after parsing chunk size.  This might in theory
affect clients and/or backends using LF instead of CRLF.

Patch by Dmitry Popov.
2013-06-28 13:55:05 +04:00
Maxim Dounin a5d3cdb0af Fixed build on Linux with x32 ABI.
On Linux x32 inclusion of sys/sysctl.h produces an error.  As sysctl() is
only used by rtsig event method code, which is legacy and not compiled
in by default on modern linuxes, the sys/sysctl.h file now only included
if rtsig support is enabled.

Based on patch by Serguei I. Ivantsov.
2013-06-26 15:47:27 +04:00
Vladimir Homutov ecb8615d70 Core: support several "error_log" directives.
When several "error_log" directives are specified in the same configuration
block, logs are written to all files with a matching log level.

All logs are stored in the singly-linked list that is sorted by log level in
the descending order.

Specific debug levels (NGX_LOG_DEBUG_HTTP,EVENT, etc.) are not supported
if several "error_log" directives are specified.  In this case all logs
will use debug level that has largest absolute value.
2013-06-20 20:47:39 +04:00
Ruslan Ermilov 2de090e987 Simplified ngx_list_create(). 2013-06-19 08:55:08 +04:00
Tatsuhiko Kubo 724470bf78 Valgrind: another complaint about uninitialized bytes. 2013-06-12 00:41:24 +09:00
Valentin Bartenev 0464096c0c SPDY: fixed code style, no functional changes. 2013-06-13 16:28:42 +04:00
Vladimir Homutov 5e665ee7c0 Core: moved initialization of log level.
The cycle->new_log->log_level should only be initialized by ngx_init_cycle()
if no error logs were found in the configuration.  This move allows to get rid
of extra initialization in ngx_error_log().
2013-06-13 14:50:10 +04:00
Jim Radford baa4618b94 SPDY: pass through the full status when available.
Avoid stripping the status text when proxying for compatibility with http.
2013-06-07 13:16:00 -07:00
Maxim Dounin b51a6af6d3 Perl: fixed r->header_in("Cookie") (ticket #351).
It was broken by X-Forwarded-For related changes in f7fe817c92a2 (1.3.14)
as hh->offset is no longer 0 for Cookie.
2013-06-10 14:35:00 +04:00
Maxim Dounin 9d042ae8d1 Fixed debug logging in ngx_http_parse_complex_uri().
The *u previously logged isn't yet initialized at this point, and
Valgrind complains.
2013-06-05 19:45:08 +04:00
Maxim Dounin d53b56bdf5 Mail: fixed possible uninitialized memory access.
Found by Valgrind.
2013-06-05 19:44:23 +04:00
Maxim Dounin 5636b1b6ab Valgrind: supressed complaints about uninitialized bytes.
Valgrind complains if we pass uninitialized memory to a syscall:

==36492== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)
==36492==    at 0x6B5E6A: sendmsg (in /usr/lib/system/libsystem_kernel.dylib)
==36492==    by 0x10004288E: ngx_signal_worker_processes (ngx_process_cycle.c:527)
==36492==    by 0x1000417A7: ngx_master_process_cycle (ngx_process_cycle.c:203)
==36492==    by 0x100001F10: main (nginx.c:410)
==36492==  Address 0x7fff5fbff71c is on thread 1's stack

Even initialization of all members of the structure passed isn't enough, as
there is padding which still remains uninitialized and results in Valgrind
complaint.  Note there is no real problem here as data from uninitialized
memory isn't used.
2013-06-05 19:44:22 +04:00
Maxim Dounin bb16b848b0 Valgrind: sigaction() failure now ignored.
Valgrind intercepts SIGUSR2 in some cases, and nginx might not be able to
start due to sigaction() failure.  If compiled with NGX_VALGRIND defined,
we now ignore the failure of sigaction().
2013-06-05 19:44:20 +04:00
Valentin Bartenev 36e76523dd Status: the "last_in_chain" flag must be set.
The module always produces only one and obviously the last buffer in chain.
2013-06-05 16:22:40 +04:00
Valentin Bartenev 15ec383f75 SPDY: use proper macros for value length and headers counter.
Currently these macros are synonyms, but this may change in the future
(in particular, spdy/3 uses 4 bytes for lengths).
2013-06-05 02:13:52 +04:00
Maxim Dounin 2152955bc9 Version bump. 2013-06-04 19:38:20 +04:00
Vladimir Homutov 9cb4176c7c Core: fixed handling of "stderr" in error_log.
If "stderr" was specified in one of the "error_log" directives,
stderr is not redirected to the first error_log on startup,
configuration reload, and reopening log files.
2013-06-04 11:27:36 +04:00
Vladimir Homutov fe4a759d05 Core: fixed stderr redirection on win32 in ngx_reopen_files().
On win32 stderr was not redirected into a file specified by "error_log"
while reopening files.  Fix is to use platform-independent functions to
work with stderr, as already used by ngx_init_cycle() and main() since
rev. d8316f307b6a.
2013-06-03 16:54:28 +04:00
Maxim Dounin 75ccac0ad5 release-1.5.1 tag 2013-06-04 17:21:52 +04:00
Maxim Dounin 978df01dcf nginx-1.5.1-RELEASE 2013-06-04 17:21:52 +04:00
Maxim Dounin d9b05ae454 Updated zlib used for win32 builds. 2013-06-04 16:16:51 +04:00
Maxim Dounin c58777c9f6 Win32: accept_mutex now always disabled (ticket #362).
Use of accept mutex on win32 may result in a deadlock if there are multiple
worker_processes configured and the mutex is grabbed by a process which
can't accept connections.
2013-05-31 14:59:26 +04:00
Ruslan Ermilov d3aadd7b5a OCSP stapling: fixed incorrect debug level. 2013-05-31 13:30:37 +04:00
Ruslan Ermilov 3f054aa40c Access: support for UNIX-domain client addresses (ticket #359). 2013-05-30 18:23:05 +04:00
Maxim Dounin 790a979a3e Win32: added missing reset of wev->ready on WSAEWOULDBLOCK.
This fixes connection hang with websockets proxy, and likely some other
places as well.
2013-05-29 19:18:22 +04:00
Maxim Dounin fd39612ffd Upstream: http_403 support in proxy_next_upstream (and friends).
The parameter is mostly identical to http_404, and is expected to
be used in similar situations.  The 403 code might be returned by
a backend instead of 404 on initial sync of new directories with rsync.

See here for feature request and additional details:
http://mailman.nginx.org/pipermail/nginx-ru/2013-April/050920.html
2013-05-27 16:54:09 +04:00
Maxim Dounin ee820cfb83 Xslt: xslt_last_modified directive.
Directive is similar to ssi_last_modified and sub_filter_last_modified
directives introduced by previous commits.
2013-05-24 22:28:09 +04:00
Maxim Dounin f96b55ad41 Sub filter: sub_filter_last_modified directive.
Directive is similar to ssi_last_modified introduced by previous commit.

Patch by Alexey Kolpakov.
2013-05-24 22:27:30 +04:00
Maxim Dounin 98809dc323 SSI: ssi_last_modified directive.
The "ssi_last_modified" directive allows to preserve Last-Modified header
in SSI responses.  The directive is similar to SSILastModified one available
in Apache:

http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilastmodified

Patch by Alexey Kolpakov.
2013-05-24 22:27:23 +04:00
Valentin Bartenev bc25f2b27f Core: strengthen configuration syntax checker.
It is now a syntax error if tokens passed to a custom configuration
handler are terminated by "{".

The following incorrect configuration is now properly rejected:

  map $v $v2 {
      a b {
      c d {
      e f {
  }
2013-05-23 20:30:27 +04:00
Ruslan Ermilov eef4a7cd8b Memcached: stricten header validation.
An invalid memcached reply that started with '\n' could cause
segmentation fault.

An invalid memcached reply "VALUE / 0 2\r?ok\r\nEND\r\n" was
considered as a valid response.

In addition, if memcached reports that the key was not found,
set u->headers_in.content_length_n to 0.  This ensures that
ngx_http_memcached_filter() will not be called while previous
code relied on always intercepting 404.  Initialization of
ctx->rest was moved to where it belongs.
2013-05-23 16:26:10 +04:00
Sergey Kandaurov 8c12dbafc2 Use "void" for functions with empty parameter list. 2013-05-23 15:47:58 +04:00
Ruslan Ermilov d9aa40c49e Configure: fixed test of OS X atomic(3). 2013-05-23 10:23:21 +04:00
Piotr Sikora ad18f61b5f Style: replace SSL *ssl with ngx_ssl_conn_t *ssl_conn.
No functional changes.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-05-21 18:45:07 -07:00
Piotr Sikora d2ae7df751 Style: remove unnecessary references to HTTP from non-HTTP modules.
No functional changes.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-05-21 18:43:43 -07:00
Maxim Dounin 09965fc6c3 Referer module: added $invalid_referer to variables hash.
This makes it accessible via dynamic lookup with ngx_http_get_variable()
from Perl, SSI, etc.

Patch by Yichun Zhang (agentzh).
2013-05-22 22:31:53 +04:00
Maxim Dounin 28a91f5ebc Upstream: fixed fail_timeout and max_fails > 1.
Due to peer->checked always set since rev. c90801720a0c (1.3.0)
by round-robin and least_conn balancers (ip_hash not affected),
the code in ngx_http_upstream_free_round_robin_peer() function
incorrectly reset peer->fails too often.

Reported by Dmitry Popov,
http://mailman.nginx.org/pipermail/nginx-devel/2013-May/003720.html
2013-05-21 21:47:50 +04:00
F. da Silva fb94dc41c4 Mail: missing ngx_ssl_ecdh_curve() call. 2013-05-10 16:53:45 +02:00
Sergey Kandaurov 194b5d8f5e Fixed error logging.
The provided argument list didn't follow a used format string.
2013-05-21 17:30:19 +04:00
Ruslan Ermilov b14e75630f Upstream: slightly optimized ngx_http_upstream_process_header(). 2013-05-21 12:54:27 +04:00
Ruslan Ermilov 903d00d8b0 Upstream: made the assignment more obvious.
No functional changes.
2013-05-21 12:54:26 +04:00
Piotr Sikora 1c476c251b OCSP stapling: fix error logging of successful OCSP responses.
Due to a bad argument list, nginx worker would crash (SIGSEGV) while
trying to log the fact that it received OCSP response with "revoked"
or "unknown" certificate status.

While there, fix similar (but non-crashing) error a few lines above.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-05-16 15:37:13 -07:00
Filipe Da Silva 68bd975e74 Mail: removed surplus ngx_close_connection() call.
It is already called for a peer connection a few lines above.
2013-05-09 10:54:28 +02:00
Ruslan Ermilov a32d439af1 Upstream keepalive: slightly simplified code. 2013-05-15 15:04:49 +04:00
Ruslan Ermilov 500dc1ae4d Removed vestiges of SVN. 2013-04-25 17:41:45 +04:00
Maxim Dounin cef7ed4064 Proxy: clear script engine used to calculate lengths.
Previous code is believed to be safe, but might access uninitialized
memory (e.g., e->quote).
2013-05-15 12:23:44 +04:00
Maxim Dounin a262170fee Fixed lingering_time check.
There are two significant changes in this patch:

1) The <= 0 comparison is done with a signed type.  This fixes the case
   of ngx_time() being larger than r->lingering_time.

2) Calculation of r->lingering_time - ngx_time() is now always done
   in the ngx_msec_t type.  This ensures the calculation is correct
   even if time_t is unsigned and differs in size from ngx_msec_t.

Thanks to Lanshun Zhou.
2013-05-13 17:39:45 +04:00
Ruslan Ermilov ea1d3a9bd5 Upstream: allow to intercept responses with status 300.
This fixes an omission made in 9e7926763f87 where all 3XX statuses
were allowed for "error_page".
2013-05-13 14:10:22 +04:00
Piotr Sikora 08f37d2f17 PCRE: retain input pattern for all regular expressions.
Previously, input pattern was kept only for regular expressions
with named captures, which resulted in error log entries without
input pattern for PCRE errors that occured while processing
regular expressions without them.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-05-02 03:26:36 -07:00
Maxim Dounin c0214e4879 Proxy: $proxy_internal_body_length fixed.
The $proxy_internal_body_length value might change during request lifetime,
notably if proxy_set_body used, and use of a cached value might result in
incorrect upstream requests.

Patch by Lanshun Zhou.
2013-05-11 21:12:24 +04:00
Maxim Dounin a324191205 Mp4: indentation and style, no functional changes. 2013-05-11 18:49:49 +04:00
Maxim Dounin 31a5a88828 Added r->limit_rate_after.
As of now, it allows to better control bandwidth limiting from additional
modules.  It is also expected to be used to add variables support to
the limit_rate_after directive.
2013-05-11 18:49:42 +04:00
Maxim Dounin d4d431e8c2 Fixed build with --with-mail_ssl_module.
If nginx was compiled without --with-http_ssl_module, but with some
other module which uses OpenSSL (e.g. --with-mail_ssl_module), insufficient
preprocessor check resulted in build failure.  The problem was introduced
by e0a3714a36f8 (1.3.14).

Reported by Roman Arutyunyan.
2013-05-11 18:49:30 +04:00
Maxim Dounin 62265c811d Request body: fixed r->count increment on allocation failure. 2013-05-11 18:49:19 +04:00
Maxim Dounin 5c2861e4e6 Perl: extra "return" removed. 2013-05-11 18:48:56 +04:00
Maxim Dounin 0d5de60cf6 Version bump. 2013-05-11 18:43:28 +04:00
Maxim Dounin 63db43210c release-1.5.0 tag 2013-05-06 14:05:17 +04:00
Maxim Dounin e6fe408310 release-1.5.0-RELEASE 2013-05-06 13:52:36 +04:00
Maxim Dounin 1d344d0e90 Fixed chunk size parsing. 2013-05-06 14:03:24 +04:00
Ruslan Ermilov 56f1820111 Proxy: allocate $proxy_internal_body_length from request pool. 2013-04-29 18:58:58 +04:00
Ruslan Ermilov f5bde9d067 Configure: fixed detection of newer Apple clang compilers. 2013-04-29 18:07:22 +04:00
Ruslan Ermilov 610c821909 Version bump. 2013-04-29 18:06:58 +04:00
Maxim Dounin a50315ead3 release-1.4.0 tag 2013-04-24 13:59:45 +00:00
Maxim Dounin 073bb004f9 nginx-1.4.0-RELEASE 2013-04-24 13:59:34 +00:00
Maxim Dounin 60743fc99e Version bump. 2013-04-24 13:03:43 +00:00
Valentin Bartenev e011fcd939 SPDY: set NGX_TCP_NODELAY_DISABLED for fake connections.
This is to avoid setting the TCP_NODELAY flag on SPDY socket in
ngx_http_upstream_send_response().  The latter works per request,
but in SPDY case it might affect other streams in connection.
2013-04-23 10:15:49 +00:00
Maxim Dounin 7eaf755525 Perl: request body handling fixed.
As of 1.3.9, chunked request body may be available with
r->headers_in.content_length_n <= 0.  Additionally, request body
may be in multiple buffers even if r->request_body_in_single_buf
was requested.
2013-04-23 10:04:12 +00:00
Maxim Dounin 43401ca269 Configure: fixed perl Makefile generation (ticket #334).
Dependancy tracking introduced in r5169 were not handled absolute path
names properly.  Absolute names might appear in CORE_DEPS if --with-openssl
or --with-pcre configure arguments are used to build OpenSSL/PCRE
libraries.

Additionally, revert part of r5169 to set NGX_INCS from Makefile
variables.  Makefile variables have $ngx_include_opt in them, which
might result in wrong include paths being used.  As a side effect,
this also restores build with --with-http_perl_module and --without-http
at the same time.
2013-04-19 12:19:57 +00:00
Ruslan Ermilov a3dabbf07c Configure: uniformly refer to libs when searching for md5 and sha1. 2013-04-18 14:26:08 +00:00
Ruslan Ermilov c85441f05e Version bump. 2013-04-18 14:16:44 +00:00
Maxim Dounin 807bbabf91 release-1.3.16 tag 2013-04-16 14:05:22 +00:00
Maxim Dounin 66f2a815e0 nginx-1.3.16-RELEASE 2013-04-16 14:05:11 +00:00
Maxim Dounin f22b2c2f8b Events: backout eventport changes (r5172) for now.
Evenport method needs more work.  Changes in r5172, while being correct,
introduce various new regressions with current code.
2013-04-16 12:58:03 +00:00
Maxim Dounin c724e9cbe7 Request body: only read body in main request (ticket #330).
Before 1.3.9 an attempt to read body in a subrequest only caused problems
if body wasn't already read or discarded in a main request.  Starting with
1.3.9 it might also cause problems if body was discarded by a main request
before subrequest start.

Fix is to just ignore attempts to read request body in a subrequest, which
looks like right thing to do anyway.
2013-04-16 10:14:59 +00:00
Ruslan Ermilov b8235cbb4c Upstream: warn if multiple non-stackable balancers are installed. 2013-04-12 19:12:13 +00:00
Valentin Bartenev 54ec33616d Events: fixed typos in two previous commits. 2013-04-12 17:31:08 +00:00
Valentin Bartenev a816100a12 Events: handle only active events in eventport.
We generate both read and write events if an error event was returned by
port_getn() without POLLIN/POLLOUT, but we should not try to handle inactive
events, they may even have no handler.
2013-04-12 15:04:23 +00:00
Valentin Bartenev 07a06e6a6b Events: protection from stale events in eventport and devpoll.
Stale write event may happen if read and write events was reported both,
and processing of the read event closed descriptor.

In practice this might result in "sendfilev() failed (134: ..." or
"writev() failed (134: ..." errors when switching to next upstream server.

See report here:
http://mailman.nginx.org/pipermail/nginx/2013-April/038421.html
2013-04-12 15:02:33 +00:00
Sergey Kandaurov 735a53ea94 Upstream: fixed $upstream_response_length without buffering.
Reported by Piotr Sikora.
2013-04-11 13:49:13 +00:00
Maxim Dounin d35a500fa8 Configure: fixed nginx.so rebuild (broken by r5145).
To avoid further breaks it's now done properly, all the dependencies
are now passed to Makefile.PL.  While here, fixed include list passed to
Makefile.PL to use Makefile variables rather than a list expanded during
configure.
2013-04-10 17:07:44 +00:00
Valentin Bartenev 574b2cf9c3 Upstream: removed surplus ngx_resolve_name_done() call.
It will be called in ngx_http_upstream_finalize_request().
2013-04-04 14:19:06 +00:00
Valentin Bartenev 8a2c8094ff Limit req: rate should be non-zero.
Specifying zero rate caused division by zero when calculating delays.
2013-04-03 14:13:35 +00:00
Ruslan Ermilov f2954f855e Pass PCRE_CASELESS to pcre_compile() for caseless matching.
Previously, we sometimes passed constant value 1 that happens to
match PCRE_CASELESS and thus was harmless.
2013-03-29 08:47:37 +00:00
Ruslan Ermilov 7df043a834 Configure: unified nginx version computation constructs. 2013-03-28 08:47:25 +00:00
Ruslan Ermilov bdcafcd22e Simplified nginx version maintenance.
It's no longer necessary to update src/http/modules/perl/nginx.pm
when version is bumped, as it's now derived from src/core/nginx.h.
2013-03-28 08:47:06 +00:00
Ruslan Ermilov 87102a4603 Configure: fixed perl module make rules.
Filename extension used for dynamically loaded perl modules isn't
necessarily ".so" (e.g., it's ".bundle" on Mac OS X).

This fixes "make" after "make" unnecessarily rebuilding perl module.
2013-03-28 08:46:42 +00:00
Ruslan Ermilov 2cfee772a7 Configure: improved make dependencies for perl module.
Added missing dependencies for perl module's Makefile.

Simplified dependencies for perl module nginx.so: it depends
on Makefile that in turn depends on other perl bits.
2013-03-28 08:46:12 +00:00
Ruslan Ermilov 3a96c20d2b Configure: improved layout of the generated makefile.
No functional changes.
2013-03-28 08:45:45 +00:00
Maxim Dounin 8e4a569bf7 Upstream: fixed tcp_nodelay with connection upgrade (ticket #325). 2013-03-27 15:18:34 +00:00
Maxim Dounin 05873fb01a Event connect: don't penalize AF_INET6 connections.
Problems with setsockopt(TCP_NODELAY) and setsockopt(TCP_NOPUSH), as well
as sendfile() syscall on Solaris, are specific to UNIX-domain sockets.
Other address families, i.e. AF_INET and AF_INET6, are fine.
2013-03-27 15:16:45 +00:00
Maxim Dounin c973b0daf2 Version bump. 2013-03-27 15:15:34 +00:00
Maxim Dounin 8c29fbd3da release-1.3.15 tag 2013-03-26 13:03:14 +00:00
Maxim Dounin c1b095a6cb nginx-1.3.15-RELEASE 2013-03-26 13:03:02 +00:00
Valentin Bartenev 01e129a457 Use NGX_FILE_ERROR for handling file operations errors.
On Win32 platforms 0 is used to indicate errors in file operations, so
comparing against -1 is not portable.

This was not much of an issue in patched code, since only ngx_fd_info() test
is actually reachable on Win32 and in worst case it might result in bogus
error log entry.

Patch by Piotr Sikora.
2013-03-25 15:49:11 +00:00
Ruslan Ermilov 3bf2110092 Upstream: removed rudiments of upstream connection caching.
This functionality is now provided by ngx_http_upstream_keepalive_module.
2013-03-25 14:51:44 +00:00
Ruslan Ermilov 43ea4ea8bb Upstream: removed sorting of upstream servers.
Sorting of upstream servers by their weights is not required by
current balancing algorithms.

This will likely change mapping to backends served by ip_hash
weighted upstreams.
2013-03-25 13:41:30 +00:00
Ruslan Ermilov 78124724ab Mail: IPv6 backends (ticket #323). 2013-03-25 13:38:59 +00:00
Ruslan Ermilov 18d08cfdcc Upstream: removed double-free workarounds in peer.free() methods. 2013-03-25 13:16:55 +00:00
Ruslan Ermilov ba8a023ed8 Upstream: only call peer.free() if peer.get() selected a peer. 2013-03-25 13:14:49 +00:00
Maxim Dounin e8af864209 Misc: support for Mercurial repositories. 2013-03-22 15:47:18 +00:00
Maxim Dounin 359c8d4874 Misc: removed unused "snapshot" target. 2013-03-22 15:14:43 +00:00
Maxim Dounin cef7515743 Misc: switch to single export operation in "zip" target.
While exporting parts of the tree might be better in some cases, it
is awfully slow overseas, and also requires unlocking ssh key multiple
times.  Exporting the whole repo and removing directories not needed for
zip is faster here.

It is also a required step before we can switch to Mercurial.
2013-03-22 15:14:07 +00:00
Ruslan Ermilov 3e4feec7a0 Split clients: check length when parsing configuration. 2013-03-21 16:06:53 +00:00
Ruslan Ermilov 286e7a96d8 Removed unused ngx_http_clear_variable() macro. 2013-03-21 16:06:13 +00:00
Ruslan Ermilov dc1b149a8f Fixed language in a comment preceding ngx_http_index_handler(). 2013-03-21 16:05:35 +00:00
Ruslan Ermilov 7f67dae3d1 Moved ngx_array_t definition from ngx_core.h to ngx_array.h. 2013-03-21 16:04:09 +00:00
Ruslan Ermilov f9bafdc7f6 Use NGX_DEFAULT_POOL_SIZE macro where appropriate. 2013-03-21 16:03:24 +00:00
Ruslan Ermilov 3b5130c6aa Simplified ngx_array_create(). 2013-03-21 15:52:52 +00:00
Ruslan Ermilov 793710749e Core: fixed resource leak if binary upgrade fails due to no memory.
Found by Coverity (CID 992320).
2013-03-20 18:07:25 +00:00
Valentin Bartenev c9594dd61c Preliminary experimental support for SPDY draft 2. 2013-03-20 10:36:57 +00:00
Valentin Bartenev c68dcb946d Win32: disabled MSVC warning about '\0' not fitting into array.
We believe that this warning produces more inconvience than real benefit.
Here is an example to trigger:

  u_char a[4] = "test";
2013-03-20 10:18:26 +00:00
Valentin Bartenev 37d3055894 URI processing code moved to a separate function.
This allows to reuse it in the upcoming SPDY module.
2013-03-20 09:36:27 +00:00
Ruslan Ermilov c5fe6cc71b Image filter: the "image_filter_interlace" directive.
Patch by Ian Babrou, with minor changes.
2013-03-19 08:13:48 +00:00
Maxim Dounin ce58b19f60 The limit_req_status and limit_conn_status directives.
Patch by Nick Marden, with minor changes.
2013-03-18 14:50:29 +00:00
Ruslan Ermilov dfbe2eef92 Core: guard against failed allocation during binary upgrade.
Patch by Piotr Sikora.
2013-03-18 07:13:57 +00:00
Valentin Bartenev ba660038c2 Status: introduced the "ngx_stat_waiting" counter.
And corresponding variable $connections_waiting was added.

Previously, waiting connections were counted as the difference between
active connections and the sum of reading and writing connections.
That made it impossible to count more than one request in one connection
as reading or writing (as is the case for SPDY).

Also, we no longer count connections in handshake state as waiting.
2013-03-15 20:00:49 +00:00
Valentin Bartenev eb9eb4e754 Allow to reuse connections that wait their first request.
This should improve behavior under deficiency of connections.

Since SSL handshake usually takes significant amount of time,
we exclude connections from reusable queue during this period
to avoid premature flush of them.
2013-03-15 19:49:54 +00:00
Maxim Dounin 90247a7b58 Upstream: fixed previous commit.
Store r->connection on stack to make sure it's still available if request
finalization happens to actually free request memory.
2013-03-14 16:22:43 +00:00
Maxim Dounin 775be72d11 Upstream: call ngx_http_run_posted_requests() on resolve errors.
If proxy_pass to a host with dynamic resolution was used to handle
a subrequest, and host resolution failed, the main request wasn't run
till something else happened on the connection.  E.g. request to "/zzz"
with the following configuration hanged:

    addition_types *;
    resolver 8.8.8.8;

    location /test {
        set $ihost xxx;
        proxy_pass http://$ihost;
    }

    location /zzz {
      add_after_body /test;
      return 200 "test";
    }

Report and original version of the patch by Lanshun Zhou,
http://mailman.nginx.org/pipermail/nginx-devel/2013-March/003476.html.
2013-03-14 12:37:54 +00:00
Maxim Dounin d2f01440e1 Request body: avoid linking rb->buf to r->header_in.
Code to reuse of r->request_body->buf in upstream module assumes it's
dedicated buffer, hence after 1.3.9 (r4931) it might reuse r->header_in
if client_body_in_file_only was set, resulting in original request
corruption.  It is considered to be safer to always create a dedicated
buffer for rb->bufs to avoid such problems.
2013-03-14 12:30:26 +00:00
Maxim Dounin 50dcb6289b Request body: next upstream fix.
After introduction of chunked request body handling in 1.3.9 (r4931),
r->request_body->bufs buffers have b->start pointing to original buffer
start (and b->pos pointing to real data of this particular buffer).

While this is ok as per se, it caused bad things (usually original request
headers included before the request body) after reinit of the request
chain in ngx_http_upstream_reinit() while sending the request to a next
upstream server (which used to do b->pos = b->start for each buffer
in the request chain).

Patch by Piotr Sikora.
2013-03-14 12:28:53 +00:00
Maxim Dounin 0815b08180 Fixed logging in ngx_http_wait_request_handler().
If c->recv() returns 0 there is no sense in using ngx_socket_errno for
logging, its value meaningless.  (The code in question was copied from
ngx_http_keepalive_handler(), but ngx_socket_errno makes sense there as it's
used as a part of ECONNRESET handling, and the c->recv() call is preceeded
by the ngx_set_socket_errno(0) call.)
2013-03-12 13:38:04 +00:00
Valentin Bartenev 2e8ad2850d Removed unused prototype of ngx_http_find_server_conf().
This function prototype and its implementation was added in r90,
but the implementation was removed in r97.
2013-03-11 14:44:56 +00:00
Valentin Bartenev e4e0e94099 Gzip: fixed setting of NGX_HTTP_GZIP_BUFFERED.
In r2411 setting of NGX_HTTP_GZIP_BUFFERED in c->buffered was moved from
ngx_http_gzip_filter_deflate_start() to ngx_http_gzip_filter_buffer() since
it was always called first.  But in r2543 the "postpone_gzipping" directive
was introduced, and if postponed gzipping is disabled (the default setting),
ngx_http_gzip_filter_buffer() is not called at all.

We must always set NGX_HTTP_GZIP_BUFFERED after the start of compression
since there is always a trailer that is buffered.

There are no known cases when it leads to any problem with current code.
But we already had troubles in upcoming SPDY implementation.
2013-03-11 11:19:58 +00:00
Valentin Bartenev f4f1b5dd47 SSL: Next Protocol Negotiation extension support.
Not only this is useful for the upcoming SPDY support, but it can
also help to improve HTTPS performance by enabling TLS False Start
in Chrome/Chromium browsers [1].  So, we always enable NPN for HTTPS
if it is supported by OpenSSL.

[1] http://www.imperialviolet.org/2012/04/11/falsestart.html
2013-03-07 18:21:28 +00:00
Valentin Bartenev 84cd3affeb Refactored ngx_http_init_request().
Now it can be used as the request object factory with minimal impact on the
connection object.  Therefore it was renamed to ngx_http_create_request().
2013-03-07 18:14:27 +00:00
Valentin Bartenev 33b3715ee4 Removed c->single_connection flag.
The c->single_connection was intended to be used as lock mechanism
to serialize modifications of request object from several threads
working with client and upstream connections.  The flag is redundant
since threads in nginx have never been used that way.
2013-03-07 18:07:16 +00:00
Valentin Bartenev bcb79d8aeb Respect the new behavior of TCP_DEFER_ACCEPT.
In Linux 2.6.32, TCP_DEFER_ACCEPT was changed to accept connections
after the deferring period is finished without any data available.
(Reading from the socket returns EAGAIN in this case.)

Since in nginx TCP_DEFER_ACCEPT is set to "post_accept_timeout", we
do not need to wait longer if deferred accept returns with no data.
2013-03-07 17:59:27 +00:00
Valentin Bartenev b0e335c130 Use "client_header_timeout" for all requests in a connection.
Previously, only the first request in a connection used timeout
value from the "client_header_timeout" directive while reading
header.  All subsequent requests used "keepalive_timeout" for
that.

It happened because timeout of the read event was set to the
value of "keepalive_timeout" in ngx_http_set_keepalive(), but
was not removed when the next request arrived.
2013-03-07 17:41:40 +00:00
Valentin Bartenev cba5b81065 Create request object only after the first byte was received.
Previously, we always created an object and logged 400 (Bad Request)
in access log if a client closed connection without sending any data.
Such a connection was counted as "reading".

Since it's common for modern browsers to behave like this, it's no
longer considered an error if a client closes connection without
sending any data, and such a connection will be counted as "waiting".

Now, we do not log 400 (Bad Request) and keep memory footprint as
small as possible.
2013-03-07 17:21:50 +00:00
Valentin Bartenev bcd4f97fe2 Version bump. 2013-03-07 17:07:04 +00:00
Maxim Dounin 6ffa53f59b release-1.3.14 tag 2013-03-05 14:36:20 +00:00
Maxim Dounin aa80062eaa nginx-1.3.14-RELEASE 2013-03-05 14:35:58 +00:00
Maxim Dounin 9738f54211 Mp4: fixed handling of too small mdat atoms (ticket #266).
Patch by Gernot Vormayr (with minor changes).
2013-03-04 15:39:03 +00:00
Valentin Bartenev 52a29295de Allocate request object from its own pool.
Previously, it was allocated from a connection pool and
was selectively freed for an idle keepalive connection.

The goal is to put coupled things in one chunk of memory,
and to simplify handling of request objects.
2013-03-01 14:55:42 +00:00
Valentin Bartenev d39feb981f SNI: added restriction on requesting host other than negotiated.
According to RFC 6066, client is not supposed to request a different server
name at the application layer.  Server implementations that rely upon these
names being equal must validate that a client did not send a different name
in HTTP request.  Current versions of Apache HTTP server always return 400
"Bad Request" in such cases.

There exist implementations however (e.g., SPDY) that rely on being able to
request different host names in one connection.  Given this, we only reject
requests with differing host names if verification of client certificates
is enabled in a corresponding server configuration.

An example of configuration that might not work as expected:

  server {
      listen 433 ssl default;
      return 404;
  }

  server {
      listen 433 ssl;
      server_name example.org;

      ssl_client_certificate org.cert;
      ssl_verify_client on;
  }

  server {
      listen 433 ssl;
      server_name example.com;

      ssl_client_certificate com.cert;
      ssl_verify_client on;
  }

Previously, a client was able to request example.com by presenting
a certificate for example.org, and vice versa.
2013-02-27 17:41:34 +00:00
Valentin Bartenev 126d946a81 SNI: reset to default server if requested host was not found.
Not only this is consistent with a case without SNI, but this also
prevents abusing configurations that assume that the $host variable
is limited to one of the configured names for a server.

An example of potentially unsafe configuration:

  server {
      listen 443 ssl default_server;
      ...
  }

  server {
      listen 443;
      server_name example.com;

      location / {
          proxy_pass http://$host;
      }
  }

Note: it is possible to negotiate "example.com" by SNI, and to request
arbitrary host name that does not exist in the configuration above.
2013-02-27 17:38:54 +00:00
Valentin Bartenev 6fbf55c9d5 SNI: avoid surplus lookup of virtual server if SNI was used. 2013-02-27 17:33:59 +00:00
Valentin Bartenev 5dd8a20da7 Apply server configuration as soon as host is known.
Previously, this was done only after the whole request header
was parsed, and if an error occurred earlier then the request
was processed in the default server (or server chosen by SNI),
while r->headers_in.server might be set to the value from the
Host: header or host from request line.

r->headers_in.server is in turn used for $host variable and
in HTTP redirects if "server_name_in_redirect" is disabled.
Without the change, configurations that rely on this during
error handling are potentially unsafe if SNI is used.

This change also allows to use server specific settings of
"underscores_in_headers", "ignore_invalid_headers", and
"large_client_header_buffers" directives for HTTP requests
and HTTPS requests without SNI.
2013-02-27 17:27:15 +00:00
Valentin Bartenev 8c3abb1a89 SSL: do not treat SSL handshake as request.
The request object will not be created until SSL handshake is complete.
This simplifies adding another connection handler that does not need
request object right after handshake (e.g., SPDY).

There are also a few more intentional effects:

 - the "client_header_buffer_size" directive will be taken from the
   server configuration that was negotiated by SNI;

 - SSL handshake errors and timeouts are not logged into access log
   as bad requests;

 - ngx_ssl_create_connection() is not called until the first byte of
   ClientHello message was received.  This also decreases memory
   consumption if plain HTTP request is sent to SSL socket.
2013-02-27 17:21:21 +00:00
Valentin Bartenev 65d898f1a0 Status: do not count connection as reading right after accept().
Before we receive the first bytes, the connection is counted
as waiting.

This change simplifies further code changes.
2013-02-27 17:16:51 +00:00
Valentin Bartenev 8d6dfb00d4 SNI: reuse selected configuration for all requests in a connection.
Previously, only the first request in a connection was assigned the
configuration selected by SNI.  All subsequent requests initially
used the default server's configuration, ignoring SNI, which was
wrong.

Now all subsequent requests in a connection will initially use the
configuration selected by SNI.  This is done by storing a pointer
to configuration in http connection object.  It points to default
server's configuration initially, but changed upon receipt of SNI.

(The request's configuration can be further refined when parsing
the request line and Host: header.)

This change was not made specific to SNI as it also allows slightly
faster access to configuration without the request object.
2013-02-27 17:12:48 +00:00
Valentin Bartenev 34c96add1d SNI: ignore captures in server_name regexes when matching by SNI.
This change helps to decouple ngx_http_ssl_servername() from the request
object.

Note: now we close connection in case of error during server name lookup
for request.  Previously, we did so only for HTTP/0.9 requests.
2013-02-27 17:06:52 +00:00
Valentin Bartenev b57d86b04c Changed interface of ngx_http_validate_host(). 2013-02-27 17:03:14 +00:00
Valentin Bartenev b82752f1b9 Introduced the ngx_http_set_connection_log() macro.
No functional changes.
2013-02-27 16:56:47 +00:00
Valentin Bartenev ab45828d29 The default server lookup is now done only once per connection.
Previously, it was done for every request in a connection.
2013-02-27 16:53:01 +00:00
Ruslan Ermilov 3555ed9bb8 Correctly handle multiple X-Forwarded-For headers (ticket #106). 2013-02-27 13:29:50 +00:00
Ruslan Ermilov e1d7830f98 Fixed separator in $sent_http_cache_control.
In case multiple "Cache-Control" headers are sent to a client,
multiple values in $sent_http_cache_control were incorrectly
split by a semicolon.  Now they are split by a comma.
2013-02-27 13:22:20 +00:00
Valentin Bartenev 7041b84d65 Fixed potential segfault in ngx_http_keepalive_handler().
In case of error in the read event handling we close a connection
by calling ngx_http_close_connection(), that also destroys connection
pool. Thereafter, an attempt to free a buffer (added in r4892) that
was allocated from the pool could cause SIGSEGV and is meaningless
as well (the buffer already freed with the pool).
2013-02-23 13:23:48 +00:00
Maxim Dounin 1b9eee5118 SSL: retry "sess_id" and "id" allocations.
In case of fully populated SSL session cache with no memory left for
new allocations, ngx_ssl_new_session() will try to expire the oldest
non-expired session and retry, but only in case when slab allocation
fails for "cached_sess", not when slab allocation fails for either
"sess_id" or "id", which can happen for number of reasons and results
in new session not being cached.

Patch fixes this by adding retry logic to "sess_id" & "id" allocations.

Patch by Piotr Sikora.
2013-02-23 11:54:25 +00:00
Maxim Dounin b233ca6fb8 Trailing whitespace fix. 2013-02-23 11:50:42 +00:00
Andrey Belov 2b92bc2fc3 Introduced variables in ngx_http_stub_status module.
Three new variables were added: $connections_active, $connections_reading
and $connections_writing.
2013-02-21 23:31:57 +00:00
Maxim Dounin 2045f9888a Connection upgrade support in uwsgi and scgi modules.
Prodded by Roberto De Ioris.
2013-02-20 16:41:05 +00:00
Valentin Bartenev 88aba92123 Removed zero termination of shm zone names.
It was added in r2717 and no longer needed since r2721,
where the termination was added to ngx_shm_alloc() and
ngx_init_zone_pool().  So then it only corrupts error
messages about ivalid zones.
2013-02-19 17:48:45 +00:00
Valentin Bartenev 4e8d362658 Version bump. 2013-02-19 17:45:12 +00:00
Maxim Dounin 89985f24be release-1.3.13 tag 2013-02-19 15:15:11 +00:00
Maxim Dounin 44af47a113 nginx-1.3.13-RELEASE 2013-02-19 15:14:48 +00:00
Maxim Dounin 0d42a9e0ce Proxy: fixed do_write handling in previous commit.
As rightfully complained by MSVC, do_write variable was used uninitialized.
Correct fix is to set it's initial value based on event happened.
2013-02-18 15:08:46 +00:00
Maxim Dounin 5f77a13f4d Proxy: support for connection upgrade (101 Switching Protocols).
This allows to proxy WebSockets by using configuration like this:

    location /chat/ {
        proxy_pass http://backend;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

Connection upgrade is allowed as long as it was requested by a client
via the Upgrade request header.
2013-02-18 13:50:52 +00:00
Gleb Smirnoff ec6e4ad6ab Configure: changed default compiler from "gcc" to "cc".
This allows to automatically pick the preferred system compiler on
systems with multiple compilers.

Reviewed by:	mdounin, ru
2013-02-18 11:35:28 +00:00
Maxim Dounin e876cc4910 Configure: rebuild perl module nginx.so if headers are changed.
Note: the "-p" argument of cp(1) dropped intentionally, to force nginx.so
rebuild.  It is considered too boring to properly list all dependencies
in Makefile.PL.
2013-02-15 16:50:22 +00:00
Maxim Dounin e896ec37d9 Fixed false memset warning on Linux with -O3 (ticket #275).
Prodded by John Leach.
2013-02-13 14:39:46 +00:00
Maxim Dounin 9a4e07356a Updated OpenSSL used for win32 builds. 2013-02-11 23:37:20 +00:00
Maxim Dounin 53d10ee17d Added support for {SHA} passwords (ticket #50).
Note: use of {SHA} passwords is discouraged as {SHA} password scheme is
vulnerable to attacks using rainbow tables.  Use of {SSHA}, $apr1$ or
crypt() algorithms as supported by OS is recommended instead.

The {SHA} password scheme support is added to avoid the need of changing
the scheme recorded in password files from {SHA} to {SSHA} because such
a change hides security problem with {SHA} passwords.

Patch by Louis Opter, with minor changes.
2013-02-07 12:09:56 +00:00
Maxim Dounin 0c8eab4995 Version bump. 2013-02-07 12:09:09 +00:00
Maxim Dounin 4bcfb3d7c1 release-1.3.12 tag 2013-02-05 14:07:01 +00:00
Maxim Dounin 2258d26b3e nginx-1.3.12-RELEASE 2013-02-05 14:06:41 +00:00
Maxim Dounin 963fb4d535 Updated OpenSSL used for win32 builds. 2013-02-05 13:41:48 +00:00
Ruslan Ermilov e6c96519f6 GeoIP: removed pseudo-support of "proxy" and "netspeed" databases. 2013-02-04 16:44:22 +00:00
Maxim Dounin 37e741775e FastCGI: proper handling of split fastcgi end request.
If fastcgi end request record was split between several network packets,
with fastcgi_keep_conn it was possible that connection was saved in incorrect
state (e.g. with padding bytes not yet read).
2013-02-01 14:41:50 +00:00
Maxim Dounin 74f81e76ee FastCGI: unconditional state transitions.
Checks for f->padding before state transitions make code hard to follow,
remove them and make sure we always do another loop iteration after
f->state is set to ngx_http_fastcgi_st_padding.
2013-02-01 14:41:07 +00:00
Maxim Dounin 12a3a4d569 FastCGI: fixed wrong connection close with fastcgi_keep_conn.
With fastcgi_keep_conn it was possible that connection was closed after
FCGI_STDERR record with zero padding and without any further data read yet.
This happended as f->state was set to ngx_http_fastcgi_st_padding and then
"break" happened, resulting in p->length being set to f->padding, i.e. 0
(which in turn resulted in connection close).

Fix is to make sure we continue the loop after f->state is set.
2013-02-01 14:40:19 +00:00
Maxim Dounin 4f9b68a9a9 Request body: fixed client_body_in_file_only.
After introduction of chunked request body reading support in 1.3.9 (r4931),
the rb->bufs wasn't set if request body was fully preread while calling the
ngx_http_read_client_request_body() function.

Reported by Yichun Zhang (agentzh).
2013-02-01 14:38:18 +00:00
Maxim Dounin fabab386ed SSL: fixed ngx_ssl_handshake() with level-triggered event methods.
Missing calls to ngx_handle_write_event() and ngx_handle_read_event()
resulted in a CPU hog during SSL handshake if an level-triggered event
method (e.g. select) was used.
2013-02-01 14:37:43 +00:00
Valentin Bartenev 5ef334fff4 SSL: take into account data in the buffer while limiting output.
In some rare cases this can result in a more smooth sending rate.
2013-01-28 15:41:12 +00:00
Valentin Bartenev bfe4ae8a88 SSL: avoid calling SSL_write() with zero data size.
According to documentation, calling SSL_write() with num=0 bytes to be sent
results in undefined behavior.

We don't currently call ngx_ssl_send_chain() with empty chain and buffer.
This check handles the case of a chain with total data size that is
a multiple of NGX_SSL_BUFSIZE, and with the special buffer at the end.

In practice such cases resulted in premature connection close and critical
error "SSL_write() failed (SSL:)" in the error log.
2013-01-28 15:40:25 +00:00
Valentin Bartenev 3df8fe1d19 SSL: calculation of buffer size moved closer to its usage.
No functional changes.
2013-01-28 15:38:36 +00:00
Valentin Bartenev 822e47a69a SSL: preservation of flush flag for buffered data.
Previously, if SSL buffer was not sent we lost information that the data
must be flushed.
2013-01-28 15:37:11 +00:00
Valentin Bartenev e1a24144cb SSL: resetting of flush flag after the data was written.
There is no need to flush next chunk of data if it does not contain a buffer
with the flush or last_buf flags set.
2013-01-28 15:35:12 +00:00
Valentin Bartenev df5156a062 SSL: removed conditions that always hold true. 2013-01-28 15:34:09 +00:00
Ruslan Ermilov c3c61f20d9 Secure_link: fixed configuration inheritance.
The "secure_link_secret" directive was always inherited from the outer
configuration level even when "secure_link" and "secure_link_md5" were
specified on the inner level.
2013-01-28 14:42:07 +00:00
Ruslan Ermilov c03dd581d0 Events: fixed null pointer dereference with resolver and poll.
A POLLERR signalled by poll() without POLLIN/POLLOUT, as seen on
Linux, would generate both read and write events, but there's no
write event handler for resolver events.  A fix is to only call
event handler of an active event.
2013-01-25 09:59:28 +00:00
Ruslan Ermilov c2e6604ff8 GeoIP: IPv6 support.
When using IPv6 databases, IPv4 addresses are looked up as IPv4-mapped
IPv6 addresses.

Mostly based on a patch by Gregor Kališnik (ticket #250).
2013-01-24 16:15:51 +00:00
Ruslan Ermilov cd4c54ee05 Configure: fixed GeoIP library detection. 2013-01-24 16:15:07 +00:00
Ruslan Ermilov cb50a5a269 Configure: fixed style of include directories. 2013-01-24 16:14:12 +00:00
Maxim Dounin 82af8b89cd Proxy: fixed proxy_method to always add space.
Before the patch if proxy_method was specified at http{} level the code
to add trailing space wasn't executed, resulting in incorrect requests
to upstream.
2013-01-22 12:36:00 +00:00
Sergey Budnevitch 5875127661 Removed redundant variable assignment. 2013-01-21 15:05:54 +00:00
Ruslan Ermilov cb433e7483 Variables $pipe, $request_length, $time_iso8601, and $time_local.
Log module counterparts are preserved for efficiency.

Based on patch by Kiril Kalchev.
2013-01-21 13:15:29 +00:00
Ruslan Ermilov b6ffb27779 Version bump. 2013-01-17 09:55:36 +00:00
Ruslan Ermilov 8bc682efb6 Fixed and improved the "*_bind" directives of proxying modules.
The "proxy_bind", "fastcgi_bind", "uwsgi_bind", "scgi_bind" and
"memcached_bind" directives are now inherited; inherited value
can be reset by the "off" parameter.  Duplicate directives are
now detected.  Parameter value can now contain variables.
2013-01-16 09:42:57 +00:00
Maxim Dounin 38fe4b6e8f release-1.3.11 tag 2013-01-10 13:17:29 +00:00
Maxim Dounin 4745aee8d2 nginx-1.3.11-RELEASE 2013-01-10 13:17:04 +00:00
Ruslan Ermilov 9d386e446a Fixed "proxy_pass" with IP address and no port (ticket #276).
Upstreams created by "proxy_pass" with IP address and no port were
broken in 1.3.10, by not initializing port in u->sockaddr.

API change: ngx_parse_url() was modified to always initialize port
(in u->sockaddr and in u->port), even for the u->no_resolve case;
ngx_http_upstream() and ngx_http_upstream_add() were adopted.
2013-01-10 12:58:55 +00:00
Maxim Dounin 0217be18c2 Updated PCRE used for win32 builds. 2013-01-10 11:38:14 +00:00
Maxim Dounin af5325b724 SSL: speedup loading of configs with many ssl servers.
The patch saves one EC_KEY_generate_key() call per server{} block by
informing OpenSSL about SSL_OP_SINGLE_ECDH_USE we are going to use before
the SSL_CTX_set_tmp_ecdh() call.

For a configuration file with 10k simple server{} blocks with SSL enabled
this change reduces startup time from 18s to 5s on a slow test box here.
2013-01-09 14:11:48 +00:00
Valentin Bartenev ce2a924ba8 Events: added check for duplicate "events" directive. 2013-01-08 14:03:37 +00:00
Valentin Bartenev 4f956c6f03 The data pointer in ngx_open_file_t objects must be initialized.
Uninitialized pointer may result in arbitrary segfaults if access_log is used
without buffer and without variables in file path.

Patch by Tatsuhiko Kubo (ticket #268).
2013-01-08 14:01:57 +00:00
Ruslan Ermilov b24b8f1e5a Year 2013. 2012-12-31 22:08:19 +00:00
Ruslan Ermilov ae9a0bc8e3 Geo: improved code readability. 2012-12-27 21:35:47 +00:00
Ruslan Ermilov 700804cc89 Upstream keepalive: detect duplicate "keepalive" directive.
A failure to detect duplicate "keepalive" directive resulted in
stack exhaustion.
2012-12-26 14:46:06 +00:00
Ruslan Ermilov 51b8a56c35 Version bump. 2012-12-26 09:29:37 +00:00
Ruslan Ermilov 25f9c0baee Geo: made "default" affect both IPv4 and IPv6 when using prefixes.
Previously, "default" was equivalent to specifying 0.0.0.0/0, now
it's equivalent to specifying both 0.0.0.0/0 and ::/0 (if support
for IPv6 is enabled) with the same value.
2012-12-26 05:03:51 +00:00
Maxim Dounin dcfe818780 release-1.3.10 tag 2012-12-25 14:24:12 +00:00
Maxim Dounin 4bca1fcd89 nginx-1.3.10-RELEASE 2012-12-25 14:23:45 +00:00
Ruslan Ermilov 0a59862a03 Geo: properly initialize ngx_cidr_t when dealing with "default". 2012-12-25 10:00:39 +00:00
Ruslan Ermilov 7e4b7e2ff3 Geo: IPv6 support.
The "ranges" mode is still limited to IPv4 only.
2012-12-25 08:21:56 +00:00
Valentin Bartenev 1ca4dbf377 Upstream: fixed state resetting when switching to backup servers.
Based on patch by Thomas Chen (ticket #257).
2012-12-25 08:02:21 +00:00
Valentin Bartenev 0ace09e871 Fixed HEAD requests handling when proxying is used (closes #261). 2012-12-24 17:32:53 +00:00
Ruslan Ermilov 494a072638 Trailing whitespace fix. 2012-12-24 16:40:55 +00:00
Valentin Bartenev 7ec3beaa31 Access log: the "gzip" parameter of the "access_log" directive.
Note: this requires zlib version 1.2.0.4 or above to work.
2012-12-23 19:09:33 +00:00
Valentin Bartenev c72c078ba1 Configure: added the NGX_ZLIB define.
This was introduced for conditional compilation of the code that requires
the zlib library.
2012-12-23 16:04:14 +00:00
Valentin Bartenev 848dbbfc6c Access log: the "flush" parameter of the "access_log" directive. 2012-12-23 15:51:47 +00:00
Valentin Bartenev 5d215d4806 Reopening log files code moved to a separate function.
The code refactored in a way to call custom handler that can do appropriate
cleanup work (if any), like flushing buffers, finishing compress streams,
finalizing connections to log daemon, etc..
2012-12-23 15:36:52 +00:00
Valentin Bartenev a03123e95e Access log: fixed redundant buffer reallocation.
Previously a new buffer was allocated for every "access_log" directive with the
same file path and "buffer=" parameters, while only one buffer per file is used.
2012-12-23 15:27:55 +00:00
Ruslan Ermilov ac372c084f Properly initialize "struct in6_addr" with zeroes. 2012-12-22 20:03:38 +00:00
Maxim Dounin db33ef23a6 Core: crypt_r() error handling fixed.
The crypt_r() function returns NULL on errors, check it explicitly instead
of assuming errno will remain 0 if there are no errors (per POSIX, the
setting of errno after a successful call to a function is unspecified
unless the description of that function specifies that errno shall not
be modified).

Additionally, dropped unneeded ngx_set_errno(0) and fixed error handling
of memory allocation after normal crypt(), which was inapropriate and
resulted in null pointer dereference on allocation failures.
2012-12-21 16:13:03 +00:00
Maxim Dounin b9d1936ece Image filter: fixed image_filter rotate inheritance.
Configurations like

    location /i/ {
        image_filter resize 200 200;
        image_filter rotate 180;

        location /i/foo/ {
            image_filter resize 200 200;
        }
   }

resulted in rotation incorrectly applied in the location /i/foo, without
any way to clear it.  Fix is to handle conf->angle/conf->acv consistently
with other filter variables and do not try to inherit them if there are
transformations defined for current location.
2012-12-21 15:07:45 +00:00
Ruslan Ermilov 7e999a3f8a Geo: ensure that default entry is always present.
If 0.0.0.0/32 entry was present and there was no explicit "default",
we failed to add an empty string as a default value.
2012-12-21 08:46:52 +00:00
Ruslan Ermilov 320e758410 There's no need to normalize address returned by ngx_ptocidr(). 2012-12-21 08:44:39 +00:00
Maxim Dounin 8abdb90720 Image filter: configuration inheritance fixes.
The image_filter_jpeg_quality, image_filter_sharpen and "image_filter rotate"
were inherited incorrectly if a directive with variables was defined, and
then redefined to a literal value, i.e. in configurations like

    image_filter_jpeg_quality $arg_q;

    location / {
        image_filter_jpeg_quality 50;
    }

Patch by Ian Babrou, with minor changes.
2012-12-20 19:04:28 +00:00
Ruslan Ermilov bb1494bdec Brought the link to ngx_http_perl_module documentation up to date. 2012-12-20 15:34:37 +00:00
Ruslan Ermilov 86dd001ebf Fixed return type of internal function that allocates radix tree nodes. 2012-12-20 11:16:03 +00:00
Ruslan Ermilov 48613efacc Let "add_header" affect 201 responses (ticket #125). 2012-12-19 10:33:56 +00:00
Ruslan Ermilov 1ab92acec6 Slightly optimized code that handles special headers in "add_header". 2012-12-19 10:30:45 +00:00
Maxim Dounin c317e6ba76 Avoid sending "100 Continue" on 413 Request Entity Too Large.
Patch by Igor Sysoev.
2012-12-18 18:39:39 +00:00
Ruslan Ermilov 73522e6612 Added checks that disallow adding a variable with an empty name.
Added variable name syntax checks to "geo" and "map" directives.
2012-12-17 19:03:33 +00:00
Ruslan Ermilov a495326c52 Implemented IPv6 support for URLs specified using domain names.
This includes "debug_connection", upstreams, "proxy_pass", etc.
(ticket #92)

To preserve compatibility, "listen" specified with a domain name
selects the first IPv4 address, if available.  If not available,
the first IPv6 address will be used (ticket #186).
2012-12-17 12:08:53 +00:00
Ruslan Ermilov a527ad164f Fixed URL parsing code.
The URL parsing code is not expected to initialize port from default port
when in "no_resolve" mode.  This got broken in r4671 for the case of IPv6
literals.
2012-12-17 09:44:46 +00:00
Ruslan Ermilov d886882970 Simplified URL parsing code.
Except for the "listen" directive, "*" specified as a hostname is
no longer treated specially.
2012-12-17 09:31:53 +00:00
Ruslan Ermilov 3a63c2b35f Geo: fixed the "ranges" without ranges case.
The following configuration returned an empty value for $geo:

    geo $geo {
        ranges;
        default default;
    }
2012-12-14 19:56:03 +00:00
Ruslan Ermilov 64a1ba7634 Geo: improved ngx_http_geo_block() code readability. 2012-12-14 19:35:37 +00:00
Valentin Bartenev f566cfa100 Fixed handling of ngx_write_fd() and ngx_read_fd() errors.
The ngx_write_fd() and ngx_read_fd() functions return -1 in case of error,
so the incorrect comparison with NGX_FILE_ERROR (which is 0 on windows
platforms) might result in inaccurate error message in the error log.

Also the ngx_errno global variable is being set only if the returned value
is -1.
2012-12-14 15:24:24 +00:00
Valentin Bartenev 435753dd55 Gzip: fixed zlib memLevel adjusting.
An incorrect memLevel (lower than 1) might be passed to deflateInit2() if the
"gzip_hash" directive is set to a value less than the value of "gzip_window"
directive. This resulted in "deflateInit2() failed: -2" alert and an empty
reply.
2012-12-14 15:17:58 +00:00
Maxim Dounin 16f4851c13 Upstream: fixed SIGSEGV with the "if" directive.
Configuration like

    location / {
        set $true 1;

        if ($true) {
            proxy_pass http://backend;
        }

        if ($true) {
            # nothing
        }
    }

resulted in segmentation fault due to NULL pointer dereference as the
upstream configuration wasn't initialized in an implicit location created
by the last if(), but the r->content_handler was set due to first if().

Instead of committing a suicide by dereferencing a NULL pointer, return
500 (Internal Server Error) in such cases, i.e. if uscf is NULL.  Better
fix would be to avoid such cases by fixing the "if" directive handling,
but it's out of scope of this patch.

Prodded by Piotr Sikora.
2012-12-13 16:05:59 +00:00
Ruslan Ermilov 44d18ce6ca Fixed variable syntax checking in "set", "geo", "limit_conn_zone",
and "perl_set" directives.
2012-12-13 15:05:19 +00:00
Maxim Dounin 44453d3c2f Proxy: better error message about unexpected data.
Requested by Igor Sysoev.
2012-12-13 13:45:39 +00:00
Valentin Bartenev eb90e8a5a5 Limit rate: fixed integer overflow in limit calculation (ticket #256).
Patch by Alexey Antropov.
2012-12-12 14:48:48 +00:00
Maxim Dounin 797cb820dc Configure: better check for PCRE JIT.
On Mac OS X system toolchain by default prefers include files
from /usr/local/include, but libraries from /usr/lib.  This might result in
various problems, in particular the one outlined below.

If the PCRE library is installed into /usr/local/, this results in pcre.h
being used from /usr/local/include (with PCRE_CONFIG_JIT defined), but
libpcre from /usr/lib (as shipped with the OS, without pcre_free_study()
symbol).  As a result build fails as we use pcre_free_study() function
if we try to compile with PCRE JIT support.

Obvious workaround is to the root cause is to ask compiler to prefer
library from /usr/local/lib via ./configure --with-ld-opt="-L/usr/local/lib".
On the other hand, in any case it would be good to check if the function
we are going to use is available, hence the change.

See thread here for details:
http://mailman.nginx.org/pipermail/nginx-devel/2012-December/003074.html

Prodded by Piotr Sikora.
2012-12-12 13:50:07 +00:00
Ruslan Ermilov ae1a0986ed The "auth_basic" directive gained support of variables. 2012-12-10 13:11:11 +00:00
Ruslan Ermilov ee7305607c Allow the complex value to be defined as an empty string.
This makes conversion from strings to complex values possible
without the loss of functionality.
2012-12-06 23:03:53 +00:00
Ruslan Ermilov 161822f728 Xslt: prevented infinite loop.
If XSLT transformation failed and error 500 was handled in the same
location, an infinite loop occured that exhausted the stack.
2012-12-06 21:22:58 +00:00
Ruslan Ermilov f4d3ceec53 Fixed build with embedded perl in certain setups (ticket #48). 2012-12-03 16:00:26 +00:00
Ruslan Ermilov 7e5005f68f Fixed the NGX_SOCKADDR_STRLEN macro definition.
The ngx_sock_ntop() function, when told to print both address and port,
prints IPv6 address in square brackets, followed by colon and port.
2012-11-30 11:26:50 +00:00
Maxim Dounin 16e6bb82f3 Core: removed GLOB_NOSORT glob option.
This will result in alphabetical sorting of included files if
the "include" directive with wildcards is used.

Note that the behaviour is now different from that on Windows, where
alphabetical sorting is not guaranteed for FindFirsFile()/FindNextFile()
(used to be alphabetical on NTFS, but not on FAT).

Approved by Igor Sysoev, prodded by many.
2012-11-29 23:15:41 +00:00
Maxim Dounin 201329cc5c Version bump. 2012-11-29 23:13:18 +00:00
Maxim Dounin a2a56153bd release-1.3.9 tag 2012-11-27 13:55:54 +00:00
Maxim Dounin ea00fa45c7 nginx-1.3.9-RELEASE 2012-11-27 13:55:34 +00:00
Maxim Dounin 10fe62af2f Gunzip: added missing ngx_http_clear_etag(). 2012-11-26 21:30:45 +00:00
Maxim Dounin 81f133133f Core: fixed ngx_write_chain_to_file() with IOV_MAX reached.
Catched by dav_chunked.t on Solaris.  In released versions this might
potentially result in corruption of complex protocol responses if they
were written to disk and there were more distinct buffers than IOV_MAX
in a single write.
2012-11-26 21:19:57 +00:00
Maxim Dounin 289d1dc38d Request body: block write events while reading body.
If write events are not blocked, an extra write event might happen for
various reasons (e.g. as a result of a http pipelining), resulting in
incorrect body being passed to a post handler.

The problem manifested itself with the dav module only, as this is
the only module which reads the body from a content phase handler (in
contrast to exclusive content handlers like proxy).  Additionally, dav
module used to dump core in such situations due to ticket #238.

See reports here:

http://mailman.nginx.org/pipermail/nginx-devel/2012-November/002981.html
http://serverfault.com/questions/449195/nginx-webdav-server-with-auth-request
2012-11-26 18:01:49 +00:00
Maxim Dounin f2f8989941 Request body: error checking fixes, negative rb->rest handling.
Negative rb->rest can't happen with current code, but it's good to have
it handled anyway.

Found by Coverity (CID 744846, 744847, 744848).
2012-11-26 18:01:08 +00:00
Maxim Dounin cab0e1d4d9 Request body: improved handling of incorrect chunked request body.
While discarding chunked request body in some cases after detecting
request body corruption no error was returned, while it was possible
to correctly return 400 Bad Request.  If error is detected too late,
make sure to properly close connection.

Additionally, in ngx_http_special_response_handler() don't return body
of 500 Internal Server Error to a client if ngx_http_discard_request_body()
fails, but disable keepalive and continue.
2012-11-26 18:00:14 +00:00
Maxim Dounin bb3a948b99 Request body: fixed discard of chunked request body.
Even if there is no preread data, make sure to always call
ngx_http_discard_request_body_filter() in case of chunked request
body to initialize r->headers_in.content_length_n for later use.
2012-11-26 17:59:30 +00:00
Ruslan Ermilov 22eb7ecb4d Core: don't reuse shared memory zone that changed ownership (ticket #210).
nginx doesn't allow the same shared memory zone to be used for different
purposes, but failed to check this on reconfiguration.  If a shared memory
zone was used for another purpose in the new configuration, nginx attempted
to reuse it and crashed.
2012-11-23 12:43:58 +00:00
Ruslan Ermilov 7ee9c002bf Fixed location of debug message in ngx_shmtx_lock(). 2012-11-21 14:23:26 +00:00
Maxim Dounin 1e034114d0 Request body: unbreak build without debug. 2012-11-21 01:40:11 +00:00
Maxim Dounin b5280fc457 Request body: chunked transfer encoding support. 2012-11-21 01:08:11 +00:00
Maxim Dounin 4849a998ad Request body: recalculate size of a request body in scgi module.
This allows to handle requests with chunked body by scgi module, and
also simplifies handling of various request body modifications.
2012-11-21 01:06:53 +00:00
Maxim Dounin 440081609e Request body: $content_length variable to honor real body size.
This allows to handle requests with chunked body by fastcgi and uwsgi
modules, and also simplifies handling of various request body modifications.
2012-11-21 01:05:08 +00:00
Maxim Dounin 989e1ece6f Request body: always use calculated size of a request body in proxy.
This allows to handle requests with chunked body, and also simplifies
handling of various request body modifications.
2012-11-21 01:03:48 +00:00
Maxim Dounin d033098ed3 Request body: adjust b->pos when chunked parsing done.
This is a nop for the current code, though will allow to correctly parse
pipelined requests.
2012-11-21 01:02:56 +00:00
Maxim Dounin 6d26158767 Request body: chunked parsing moved to ngx_http_parse.c from proxy.
No functional changes.
2012-11-21 00:59:16 +00:00
Maxim Dounin 79bea028df Request body: properly handle events while discarding body.
An attempt to call ngx_handle_read_event() before actually reading
data from a socket might result in read event being disabled, which is
wrong.  Catched by body.t test on Solaris.
2012-11-21 00:57:56 +00:00
Maxim Dounin e8005778a4 Request body: fixed socket leak on errors.
The r->main->count reference counter was always incremented in
ngx_http_read_client_request_body(), while it is only needs to be
incremented on positive returns.
2012-11-21 00:57:16 +00:00
Maxim Dounin 53e489223c Request body: code duplication reduced, no functional changes.
The r->request_body_in_file_only with empty body case is now handled in
ngx_http_write_request_body().
2012-11-21 00:55:50 +00:00
Maxim Dounin 99101e53b1 Request body: $request_body variable generalization.
The $request_body variable was assuming there can't be more than two
buffers.  While this is currently true due to request body reading
implementation details, this is not a good thing to depend on and may
change in the future.
2012-11-21 00:55:06 +00:00
Maxim Dounin a030551cd6 Request body: fixed "501 Not Implemented" error handling.
It is not about "Method" but a generic message, and is expected to be used
e.g. if specified Transfer-Encoding is not supported.  Fixed message to
match RFC 2616.

Additionally, disable keepalive on such errors as we won't be able to read
request body correctly if we don't understand Transfer-Encoding used.
2012-11-21 00:54:01 +00:00
Maxim Dounin db49dd33e0 Core: added debug logging of writev() in ngx_write_chain_to_file(). 2012-11-21 00:52:35 +00:00
Maxim Dounin 4bc6164a06 Dav: fixed segfault on PUT if body was already read (ticket #238).
If request body reading happens with different options it's possible
that there will be no r->request_body->temp_file available (or even
no r->request_body available if body was discarded).  Return internal
server error in this case instead of committing suicide by dereferencing
a null pointer.
2012-11-21 00:51:37 +00:00
Igor Sysoev 471f08f690 Fixed failure to start cache manager and cache loader processes
if there were more than 512 listening sockets in configuration.
2012-11-20 13:37:55 +00:00
Maxim Dounin 426425f465 Trailing whitespace fix. 2012-11-17 00:36:44 +00:00
Maxim Dounin 77849a26d1 Upstream: better detection of connect() failures with kqueue.
Pending EOF might be reported on both read and write events, whichever
comes first, so check both of them.

Patch by Yichun Zhang (agentzh), slightly modified.
2012-11-16 18:29:19 +00:00
Ruslan Ermilov 395ede67ae Upstream: honor the "down" flag for a single server.
If an upstream block was defined with the only server marked as
"down", e.g.

    upstream u {
        server 127.0.0.1:8080 down;
    }

an attempt was made to contact the server despite the "down" flag.
It is believed that immediate 502 response is better in such a
case, and it's also consistent with what is currently done in case
of multiple servers all marked as "down".
2012-11-16 12:18:05 +00:00
Ruslan Ermilov 621b777cb5 Variables $request_time and $msec.
Log module counterparts are preserved for efficiency.
2012-11-16 09:37:14 +00:00
Ruslan Ermilov 199859bc94 Fixed setting of CPU affinity on respawn of dead worker processes.
Worker processes are now made aware of their sequential number needed
to select CPU affinity mask.  This replaces a workaround from r4865.
2012-11-16 09:25:52 +00:00
Ruslan Ermilov c114d1a847 Version bump. 2012-11-16 07:49:41 +00:00
Maxim Dounin e33bfd23c4 release-1.3.8 tag 2012-10-30 13:35:18 +00:00
Maxim Dounin e6422bd905 nginx-1.3.8-RELEASE 2012-10-30 13:34:23 +00:00
Maxim Dounin ef0636141d Event pipe: fixed handling of buf_to_file data.
Input filter might free a buffer if there is no data in it, and in case
of first buffer (used for cache header and request header, aka p->buf_to_file)
this resulted in cache corruption.  Buffer memory was reused to read upstream
response before headers were written to disk.

Fix is to avoid moving pointers in ngx_event_pipe_add_free_buf() to a buffer
start if we were asked to free a buffer used by p->buf_to_file.

This fixes occasional cache file corruption, usually resulted
in "cache file ... has md5 collision" alerts.

Reported by Anatoli Marinov.
2012-10-30 11:14:24 +00:00
Maxim Dounin 71d4250024 Style, parentheses instead of braces in misc/GNUMakefile. 2012-10-30 11:09:38 +00:00
Maxim Dounin 3ce91533b3 Variables $connection and $connection_requests.
Log module counterparts are removed as they aren't used often and
there is no need to preserve them for efficiency.
2012-10-29 17:17:59 +00:00
Maxim Dounin e12828f9db Resolver: added missing memory allocation error handling. 2012-10-24 14:07:08 +00:00
Valentin Bartenev c45a263cb5 ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
idle connections.

This behaviour is consistent with the ngx_http_set_keepalive() function and it
should decrease memory usage in some cases (especially if epoll/rtsig is used).
2012-10-23 14:36:18 +00:00
Andrey Belov 419252cbc0 Core: the "auto" parameter of the "worker_processes" directive.
The parameter will set the number of worker processes to the
autodetected number of available CPU cores.
2012-10-23 09:08:41 +00:00
Maxim Dounin 72761f9ff3 Removed conditional compilation from waitpid() error test.
There are reports that call to a signal handler for an exited process
despite waitpid() already called for the process may happen on Linux
as well.
2012-10-18 14:48:33 +00:00
Maxim Dounin 8c7c1ab3d3 Gunzip: fixed r->gzip_ok check. 2012-10-18 14:27:40 +00:00
Maxim Dounin 3ea79d6814 OCSP stapling: properly check if there is ssl.ctx.
This fixes segfault if stapling was enabled in a server without a certificate
configured (and hence no ssl.ctx).
2012-10-05 11:09:14 +00:00
Maxim Dounin 4182d86e5a Variable $bytes_sent.
It replicates variable $bytes_sent as previously available in log module
only.

Patch by Benjamin Grössing (with minor changes).
2012-10-03 15:25:36 +00:00
Maxim Dounin 34446ab731 Log: $apache_bytes_sent removed.
It was renamed to $body_bytes_sent in nginx 0.3.10 and the old name is
deprecated since then.
2012-10-03 15:25:06 +00:00
Maxim Dounin 7f4d8bb530 SSL: the "ssl_verify_client" directive parameter "optional_no_ca".
This parameter allows to don't require certificate to be signed by
a trusted CA, e.g. if CA certificate isn't known in advance, like in
WebID protocol.

Note that it doesn't add any security unless the certificate is actually
checked to be trusted by some external means (e.g. by a backend).

Patch by Mike Kazantsev, Eric O'Connor.
2012-10-03 15:24:08 +00:00
Maxim Dounin d82f2ed357 Version bump. 2012-10-03 15:22:18 +00:00
Maxim Dounin 58e3708944 release-1.3.7 tag 2012-10-02 13:33:58 +00:00
Maxim Dounin ccd1aec52f nginx-1.3.7-RELEASE 2012-10-02 13:33:37 +00:00
Maxim Dounin 640b478a45 OCSP stapling: build fixes.
With the "ssl_stapling_verify" commit build with old OpenSSL libraries
was broken due to incorrect prototype of the ngx_ssl_stapling() function.
One incorrect use of ngx_log_debug() instead of ngx_log_debug2() slipped in
and broke win32 build.
2012-10-01 13:54:13 +00:00
Maxim Dounin fa7c9d59d1 OCSP stapling: ssl_stapling_verify directive.
OCSP response verification is now switched off by default to simplify
configuration, and the ssl_stapling_verify allows to switch it on.

Note that for stapling OCSP response verification isn't something required
as it will be done by a client anyway.  But doing verification on a server
allows to mitigate some attack vectors, most notably stop an attacker from
presenting some specially crafted data to all site clients.
2012-10-01 12:53:11 +00:00
Maxim Dounin 6d1395ba42 OCSP stapling: OCSP_basic_verify() OCSP_TRUSTOTHER flag now used.
This is expected to simplify configuration in a common case when OCSP
response is signed by a certificate already present in ssl_certificate
chain.  This case won't need any extra trusted certificates.
2012-10-01 12:51:27 +00:00
Maxim Dounin f97f662247 OCSP stapling: log error data in ngx_ssl_error().
It's hard to debug OCSP_basic_verify() failures without the actual error
string it records in the error data field.
2012-10-01 12:50:36 +00:00
Maxim Dounin a8c15d74c1 OCSP stapling: check Content-Type.
This will result in better error message in case of incorrect response
from OCSP responder:

... OCSP responder sent invalid "Content-Type" header: "text/plain"
    while requesting certificate status, responder: ...

vs.

... d2i_OCSP_RESPONSE() failed (SSL:
    error:0D07209B:asn1 encoding routines:ASN1_get_object:too long
    error:0D068066:asn1 encoding routines:ASN1_CHECK_TLEN:bad object header
    error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error)
    while requesting certificate status, responder: ...
2012-10-01 12:48:54 +00:00
Maxim Dounin 2bc96fc38b OCSP stapling: loading OCSP responses.
This includes the ssl_stapling_responder directive (defaults to OCSP
responder set in certificate's AIA extension).

OCSP response for a given certificate is requested once we get at least
one connection with certificate_status extension in ClientHello, and
certificate status won't be sent in the connection in question.  This due
to limitations in the OpenSSL API (certificate status callback is blocking).

Note: SSL_CTX_use_certificate_chain_file() was reimplemented as it doesn't
allow to access the certificate loaded via SSL_CTX.
2012-10-01 12:47:55 +00:00
Maxim Dounin 0f80e32d95 OCSP stapling: the ngx_event_openssl_stapling.c file.
Missed in previous commit.
2012-10-01 12:42:43 +00:00
Maxim Dounin f82645a67a OCSP stapling: ssl_stapling_file support.
Very basic version without any OCSP responder query code, assuming valid
DER-encoded OCSP response is present in a ssl_stapling_file configured.

Such file might be produced with openssl like this:

openssl ocsp -issuer root.crt -cert domain.crt -respout domain.staple \
             -url http://ocsp.example.com
2012-10-01 12:41:08 +00:00
Maxim Dounin 9125e5adff OCSP stapling: ssl_trusted_certificate directive.
The directive allows to specify additional trusted Certificate Authority
certificates to be used during certificate verification.  In contrast to
ssl_client_certificate DNs of these cerificates aren't sent to a client
during handshake.

Trusted certificates are loaded regardless of the fact whether client
certificates verification is enabled as the same certificates will be
used for OCSP stapling, during construction of an OCSP request and for
verification of an OCSP response.

The same applies to a CRL (which is now always loaded).
2012-10-01 12:39:36 +00:00
Maxim Dounin 1c765fdf2c Resolver: cached addresses are returned with random rotation now.
This ensures balancing when working with dynamically resolved upstream
servers with multiple addresses.

Based on patch by Anton Jouline.
2012-09-28 18:28:38 +00:00
Andrey Belov 58eaaef760 Correct plural form for "path" in the whole source base. 2012-09-28 13:49:26 +00:00
Andrey Belov 71115479bb Made sure to initialize the entire ngx_file_t structure.
Found by Coverity.
2012-09-28 13:15:11 +00:00
Maxim Dounin a7d23e111e SSL: added version checks for ssl compression workaround.
The SSL_COMP_get_compression_methods() is only available as an API
function in OpenSSL 0.9.8+, require it explicitly to unbreak build
with OpenSSL 0.9.7.
2012-09-27 18:01:06 +00:00
Maxim Dounin 135e55cbc1 SSL: fixed compression workaround to remove all methods.
Previous code used sk_SSL_COMP_delete(ssl_comp_methods, i) while iterating
stack from 0 to n, resulting in removal of only even compression methods.

In real life this change is a nop, as there is only one compression method
which is enabled by default in OpenSSL.
2012-09-27 17:59:59 +00:00
Andrey Belov 8693db9749 Configure: additional test for ExtUtils::Embed perl module presence.
Now perl configure will correctly fail if ExtUtils::Embed perl module
is not present in the system (found on Amazon Linux AMI, as of
release 2012.03).
2012-09-27 15:01:57 +00:00
Maxim Dounin 9bbf7f577b Configure: help updated to list upstream keepalive and least_conn.
Patch by Joshua Zhu.
2012-09-26 16:39:38 +00:00
Maxim Dounin e244dbe129 Added clearing of cpu_affinity after process spawn.
This fixes unwanted/incorrect cpu_affinity use on dead worker processes
respawn.  While this is not ideal, it's expected to be better when previous
situation where multiple processes were spawn with identical CPU affinity
set.

Reported by Charles Chen.
2012-09-26 16:25:12 +00:00
Maxim Dounin d27df5eec8 Version bump. 2012-09-26 15:52:06 +00:00
Maxim Dounin 24ec6c463b release-1.3.6 tag 2012-09-12 10:41:56 +00:00
Maxim Dounin 47a7bb6a0b nginx-1.3.6-RELEASE 2012-09-12 10:41:36 +00:00
Maxim Dounin 77949709ce Updated zlib used for win32 builds. 2012-09-11 13:36:34 +00:00
Maxim Dounin 0c385651d6 Helper target "win32" to run configure for win32 builds. 2012-09-11 13:17:31 +00:00
Maxim Dounin 252a30dd3a Configure: fixed make macros to use parentheses instead of braces.
Parentheses are more portable, in particular they are understood by nmake
while braces aren't.
2012-09-11 12:43:59 +00:00
Valentin Bartenev 306ba2ab4a Improved 50x error page.
The feature set of the new page:

 - HTML5 compliant;
 - Looks similar to the new "Welcome page" (r4835);
 - Sysadmin hint with a link to the documentation of the "error_log" directive.
2012-09-11 12:37:04 +00:00
Maxim Dounin 215bd2f2ff Configure: provide inflate() when building zlib on win32.
It is now needed for gunzip filter.
2012-09-11 12:35:30 +00:00
Maxim Dounin 339f7a0071 Gunzip: removed nginx.h leftover include. 2012-09-11 01:13:23 +00:00
Maxim Dounin 1187730f7b Gunzip filter import. 2012-09-10 16:52:47 +00:00
Maxim Dounin 2f9b38d001 Gzip static: "always" parameter in "gzip_static" directive.
With "always" gzip static returns gzipped content in all cases, without
checking if client supports it.  It is useful if there are no uncompressed
files on disk anyway.
2012-09-10 16:48:25 +00:00
Maxim Dounin 6ee44f4ef2 Memcached: memcached_gzip_flag directive.
This directive allows to test desired flag as returned by memcached and
sets Content-Encoding to gzip if one found.

This is reimplementation of patch by Tomash Brechko as available on
http://openhack.ru/.  It should be a bit more correct though (at least
I think so).  In particular, it doesn't try to detect if we are able to
gunzip data, but instead just sets correct Content-Encoding.
2012-09-10 16:43:49 +00:00
Valentin Bartenev ebfab6697d Improved welcome page.
The feature set of the new page:

 - HTML5 compliant;
 - Description of why the user is seeing the page and what his next
   step should be;
 - Links to official community and commercial support websites.
2012-09-07 13:24:46 +00:00
Maxim Dounin 7259922e55 Write filter: replaced unneeded loop with one to free chains.
Noted by Gabor Lekeny.
2012-09-05 15:06:47 +00:00
Valentin Bartenev 84ed29ca71 Limit req: fix of rbtree node insertion on hash collisions.
The rbtree used in ngx_http_limit_req_module has two level of keys, the top is
hash, and the next is the value string itself. However, when inserting a new
node, only hash has been set, while the value string has been left empty.

The bug was introduced in r4419 (1.1.14).

Found by Charles Chen.
2012-09-03 12:55:50 +00:00
Ruslan Ermilov 2b52ec5af4 Pass changes.xml thru xmllint when generating CHANGES and CHANGES.ru. 2012-08-30 16:08:13 +00:00
Ruslan Ermilov 75795fe26f Converted DOS-style newlines. 2012-08-30 16:05:43 +00:00
Ruslan Ermilov 4e63f32acc Fixed overflow if ngx_slab_alloc() is called with very big "size" argument. 2012-08-30 15:09:21 +00:00
Ruslan Ermilov 2a94bde1f0 Fixed strict aliasing bugs when dealing with IPv4-mapped IPv6 addresses
(closes #201).
2012-08-30 14:58:11 +00:00
Ruslan Ermilov abae0fcd60 Fixed the "include" directive.
The "include" directive should be able to include multiple files if
given a filename mask.  Fixed this to work for "include" directives
inside the "map" or "types" blocks.  The "include" directive inside
the "geo" block is still not fixed.
2012-08-28 13:31:01 +00:00
Ruslan Ermilov 43ed985451 Version bump. 2012-08-27 14:21:41 +00:00
Maxim Dounin d4d7667647 release-1.3.5 tag 2012-08-21 13:05:26 +00:00
Maxim Dounin 0d8cf67135 nginx-1.3.5-RELEASE 2012-08-21 13:05:02 +00:00
Maxim Dounin b0e9dd232a Radix tree preallocation fix.
The preallocation size was calculated incorrectly and was always 8 due to
sizeof(ngx_radix_tree_t) accidentally used instead of sizeof(ngx_radix_node_t).
2012-08-18 23:17:58 +00:00
Maxim Dounin 16298e92d6 Whitespace fix. 2012-08-18 23:04:39 +00:00
Andrey Belov aceafa502f Mark logically dead code with corresponding comment.
Found by Coverity.
2012-08-17 15:35:50 +00:00
Maxim Dounin 66ce48c12f Mp4: removed restriction to avc1/mp4a formats (ticket #194). 2012-08-17 11:02:35 +00:00
Ruslan Ermilov f33eb8c971 Mail: fixed handling of AF_UNIX addresses in "listen".
This makes AF_UNIX addresses in mail officially supported.
2012-08-17 05:21:28 +00:00
Ruslan Ermilov b0c8df479b Removed a stale "AF_INET only" comment.
IPv6 client connections in mail modules have been supported since r2856.
2012-08-17 05:14:19 +00:00
Ruslan Ermilov 8fb0247ab3 Mail: fixed sorting of listen addresses (ticket #187).
For http module this problem was already fixed in r4756.
2012-08-17 05:08:42 +00:00
Maxim Dounin bbf9030181 Geo: fixed handling of ranges without default set.
The bug had appeared in 0.8.43 (r3653).  Patch by Weibin Yao.
2012-08-16 13:01:41 +00:00
Maxim Dounin c51aa3c412 Crypt: fixed handling of corrupted SSHA entries in password file.
Found by Coverity.
2012-08-16 12:05:58 +00:00
Maxim Dounin c087dbf52f Map: fixed optimization of variables as values.
Previous code incorrectly used ctx->var_values as an array of pointers to
ngx_http_variable_value_t, but the array contains structures, not pointers.
Additionally, ctx->var_values inspection failed to properly set var on
match.
2012-08-16 10:58:18 +00:00
Ruslan Ermilov 3062edc931 mail_core: don't let the well-known port in the "listen" directive to
override the already set "protocol".
2012-08-15 11:30:24 +00:00
Ruslan Ermilov 0e93cf6b69 Corrected the directive name in the ngx_mail_auth_http_module error message. 2012-08-15 11:17:55 +00:00
Valentin Bartenev adc36b7c2b Added three missing checks for NULL after ngx_array_push() calls.
Found by Coverity.
2012-08-08 12:03:46 +00:00
Andrey Belov 52a8f1e7ef Explicitly ignore returned value from close() in ngx_event_core_init_conf().
We don't have strong reason to inform about any errors
reported by close() call here, and there are no other things
to do with its return value.

Prodded by Coverity.
2012-08-07 13:57:04 +00:00
Andrey Belov e2c166347c Explicitly ignore returned value from unlink() in ngx_open_tempfile().
The only thing we could potentially do here in case of error
returned is to complain to error log, but we don't have log
structure available here due to interface limitations.

Prodded by Coverity.
2012-08-06 16:06:59 +00:00
Maxim Dounin b76e7a5fea Resolver: fixed possible memory leak in ngx_resolver_create().
Found by Coverity.
2012-08-06 10:48:09 +00:00
Ruslan Ermilov 7d589ca7e2 Fixed the -p parameter handling.
Ensure that the path supplied always ends with a `/' except when empty.
An empty value now corresponds to the current directory instead of `/'.
2012-08-03 12:52:32 +00:00
Maxim Dounin c182270293 Fixed possible use of old cached times if runtime went backwards.
If ngx_time_sigsafe_update() updated only ngx_cached_err_log_time, and
then clock was adjusted backwards, the cached_time[slot].sec might
accidentally match current seconds on next ngx_time_update() call,
resulting in various cached times not being updated.

Fix is to clear the cached_time[slot].sec to explicitly mark cached times
are stale and need updating.
2012-08-03 09:10:39 +00:00
Maxim Dounin 896fa4e441 Added "const" to ngx_memcpy() with NGX_MEMCPY_LIMIT defined.
This fixes warning produced during compilation of the ngx_http_geoip_module
due to const qualifier being discarded.
2012-08-03 09:07:30 +00:00
Maxim Dounin f54b2fe189 Whitespace fix. 2012-08-03 09:00:25 +00:00
Ruslan Ermilov c3b5f66bd3 Removed the need in Perl to generate ZIP archive of nginx/Windows. 2012-08-02 14:58:36 +00:00
Maxim Dounin d60bd1af74 Win32: fixed build with Visual Studio 2005 Express.
It is available via winetricks which makes it still usable, and has
an old crtdefs.h which uses _CRT_SECURE_NO_DEPRECATE instead of
_CRT_SECURE_NO_WARNINGS to suppress warnings.

Reported by HAYASHI Kentaro,
http://mailman.nginx.org/pipermail/nginx-devel/2012-August/002542.html
2012-08-02 12:53:07 +00:00
Andrey Belov 3f34a664cb Reorder checks in ngx_shared_memory_add() for more consistent error messages. 2012-08-01 14:37:08 +00:00
Ruslan Ermilov e6f5594097 Simplified makefile that builds CHANGES. 2012-07-31 21:49:23 +00:00
Ruslan Ermilov 4a75d569ca Version bump. 2012-07-31 21:47:56 +00:00
Ruslan Ermilov 184eb76779 Updated PCRE used for win32 builds. 2012-07-31 13:13:52 +00:00
Ruslan Ermilov 04fa4c50ec release-1.3.4 tag 2012-07-31 12:38:57 +00:00
Ruslan Ermilov 077d6724d2 nginx-1.3.4-RELEASE 2012-07-31 12:38:37 +00:00
Ruslan Ermilov 36890eb5e2 Core: ipv6only is now on by default.
There is a general consensus that this change results in better
consistency between different operating systems and differently
tuned operating systems.

Note: this changes the width and meaning of the ipv6only field
of the ngx_listening_t structure.  3rd party modules that create
their own listening sockets might need fixing.
2012-07-30 12:27:06 +00:00
Valentin Bartenev 3711aabbf2 ngx_http_find_virtual_server() should return NGX_DECLINED if virtual server not
found.
2012-07-30 11:42:03 +00:00
Maxim Dounin eca4cb86b0 Upstream: hide_headers/pass_headers inheritance fix.
Hide headers and pass headers arrays might not be inherited correctly
into a nested location, e.g. in configuration like

    server {
        proxy_hide_header X-Foo;
        location / {
            location /nested/ {
                proxy_pass_header X-Pad;
            }
        }
    }

the X-Foo header wasn't hidden in the location /nested/.

Reported by Konstantin Svist,
http://mailman.nginx.org/pipermail/nginx-ru/2012-July/047555.html
2012-07-30 10:35:26 +00:00
Ruslan Ermilov a2bd6b5dd6 Improved diagnostics when a directive is specified in the wrong context. 2012-07-29 19:59:06 +00:00
Ruslan Ermilov c4fa6e1a31 Removed extraneous GCC warning flags. 2012-07-29 19:45:30 +00:00
Ruslan Ermilov 8fdddbaf59 Slight optimization in ngx_http_upstream_add(): replaced an expression
known to be constant with the constant value.
2012-07-29 19:44:09 +00:00
Ruslan Ermilov 1395be64a2 ngx_http_upstream_add() should return NULL if an error occurs. 2012-07-29 19:38:25 +00:00
Ruslan Ermilov f275f84e9b Reduced the number of preprocessor directives. 2012-07-26 14:47:42 +00:00
Ruslan Ermilov e629b37932 When "debug_connection" is configured with a domain name, only the first
resolved address was used.  Now all addresses will be used.
2012-07-24 17:40:06 +00:00
Ruslan Ermilov a8ba779147 Added the Clang compiler support.
The -Werror is commented out to not break builds on Linux.
2012-07-24 15:17:03 +00:00
Ruslan Ermilov b57d93be20 Made sure to run configure in a "C" locale.
Otherwise, we may fail to properly detect a version of compiler.
2012-07-24 15:16:09 +00:00
Ruslan Ermilov 0e5749c2fd Added a commented out -Wmissing-prototypes to CFLAGS.
It is commented out to not break builds with 3rd party modules.
2012-07-24 15:13:34 +00:00
Ruslan Ermilov 2116442078 Fixed compilation with -Wmissing-prototypes. 2012-07-24 15:09:54 +00:00
Ruslan Ermilov a6b64ace7a Replaced a number of "else if" with "elif". 2012-07-24 15:00:42 +00:00
Maxim Dounin ea7734fdbb Win32: fixed cpu hog after process startup failure.
If ngx_spawn_process() failed while starting a process, the process
handle was closed but left non-NULL in the ngx_processes[] array.
The handle later was used in WaitForMultipleObjects() (if there
were multiple worker processes configured and at least one worker
process was started successfully), resulting in infinite loop.

Reported by Ricardo V G:
http://mailman.nginx.org/pipermail/nginx-devel/2012-July/002494.html
2012-07-23 16:37:24 +00:00
Ruslan Ermilov ed9c46c4cf Fixed debugging messages to account that limit_zone was renamed to limit_conn. 2012-07-20 08:21:59 +00:00
Ruslan Ermilov d2fb59e6a8 Fixed sorting of listen addresses so that wildcard address is always at
the end (closes #187).  Failure to do so could result in several listen
sockets to be created instead of only one listening on wildcard address.

Reported by Roman Odaisky.
2012-07-17 04:47:34 +00:00
Ruslan Ermilov 9d80c31e8d Version bump. 2012-07-17 04:42:38 +00:00
Ruslan Ermilov 47a33df3cc Synchronized the license text with the FreeBSD's bsd-style-copyright. 2012-07-10 12:40:35 +00:00
Maxim Dounin b9df52e78d release-1.3.3 tag 2012-07-10 12:20:30 +00:00
Maxim Dounin 0710b4783c nginx-1.3.3-RELEASE 2012-07-10 12:20:10 +00:00
Maxim Dounin 0ee155d244 Entity tags: empty etags handling in If-Range.
Entity tag may be of length 2 as per RFC 2616, i.e. double quotes only.
Pointed out by Ruslan Ermilov.
2012-07-09 17:04:37 +00:00
Maxim Dounin 924cb17b60 Entity tags: the "etag" directive.
It allows to disable generation of nginx's own entity tags, while
still handling ETags in cache properly.  This may be useful e.g.
if one want to serve static files from servers with different ETag
generation algorithms.
2012-07-09 14:53:42 +00:00
Maxim Dounin 8e303db828 Entity tags: set for static respones. 2012-07-09 00:13:06 +00:00
Maxim Dounin 1d6020921e Entity tags: handling in add_header.
Notably this allows to clear ETag if one want to for some reason.
2012-07-07 21:24:01 +00:00
Maxim Dounin 9a59a5d4f6 Entity tags: clear on entity changes. 2012-07-07 21:22:27 +00:00
Maxim Dounin 4933ade4e2 Entity tags: support in If-Range header. 2012-07-07 21:21:15 +00:00
Maxim Dounin 27435f7124 Entity tags: basic support in not modified filter.
This includes handling of ETag headers (if present in a response) with
basic support for If-Match, If-None-Match conditionals in not modified
filter.

Note that the "r->headers_out.last_modified_time == -1" check in the not
modified filter is left as is intentionally.  It's to prevent handling
of If-* headers in case of proxy without cache (much like currently
done with If-Modified-Since).
2012-07-07 21:20:27 +00:00
Maxim Dounin 344cac9554 Not modified filter: tests separated from actions.
This makes code more extendable.  The only functional change is when
If-Modified-Since and If-Unmodified-Since are specified together, the
case which is explicitly left undefined by RFC 2616.  The new behaviour
is to respect them both, which seems better.
2012-07-07 21:18:30 +00:00
Maxim Dounin cbdd6b4c1d Added Last-Modified parsing in add_header.
This allows to use last modified time set in If-Range checks.  Code
simplified to improve readability.
2012-07-07 21:16:51 +00:00
Maxim Dounin 4d3cb3aa06 Fixed If-Range with unknown last modified time.
If modification time isn't known, skip range processing and return full
entity body instead of just ignoring If-Range.  Ignoring If-Range isn't
safe as client will assume entity wasn't changed since time specified.
2012-07-07 21:16:21 +00:00
Maxim Dounin 1c6b7b24b2 Configure: fixed "make" used instead of "${MAKE}". 2012-07-07 09:35:30 +00:00
Andrey Belov aff2878083 Corrected $request_length calculation for pipelined requests. 2012-07-06 04:27:06 +00:00
Ruslan Ermilov 9f054becb3 Fixed typo in a function name. 2012-07-03 13:06:40 +00:00
Ruslan Ermilov 718505bcd7 Made sure to initialize the entire "struct flock" allocated on stack. 2012-07-03 13:05:18 +00:00
Maxim Dounin 4c40827b6f Reset r->uri_changed in a named location (ticket #184). 2012-07-03 11:30:05 +00:00
Maxim Dounin ac789f385c Typo fixed. 2012-07-03 11:28:54 +00:00
Ruslan Ermilov 6efae9d41f map: strip final dot before looking up in a map of hostnames.
(closes #182)
2012-06-29 20:33:26 +00:00
Ruslan Ermilov cd9e54d0b8 Version bump. 2012-06-29 11:03:01 +00:00
Maxim Dounin 4ac240ab86 release-1.3.2 tag 2012-06-26 13:46:53 +00:00
Maxim Dounin 6bdf179115 nginx-1.3.2-RELEASE 2012-06-26 13:46:23 +00:00
Maxim Dounin 574c96a586 Mp4: fixed build on win32 after r4689. 2012-06-26 12:31:40 +00:00
Ruslan Ermilov a8e8b6b5c8 Added code to look up Google perftools in /opt/local/, for MacPorts. 2012-06-26 08:15:40 +00:00
Maxim Dounin 0e4f22012a Style. 2012-06-25 18:09:38 +00:00
Maxim Dounin 8ce648cf24 Incorrect tag release-1.2.1 removed.
Changes to misc/GNUmakefile was missed during stable-1.2 branch
creation, resulting in tag set on trunk, not on branch.

Reported by Marcel Gmuer.
2012-06-25 15:30:17 +00:00
Ruslan Ermilov 96cef18459 Fixed a harmless error in spelling of "Connection: close" when computing
the response header length.
2012-06-25 13:08:25 +00:00
Ruslan Ermilov e0c5661fcc Fixed compile-time conditionals used to detect if X-Forwarded-For support
is needed.
2012-06-21 11:02:22 +00:00
Igor Sysoev 30cc28eaa7 Disabled gzip compression in OpenSSL prior to 1.0.0 version.
This saves about 522K per connection.
2012-06-20 12:55:28 +00:00
Ruslan Ermilov 146e36cf1b Added IPv6 support to ip_hash. 2012-06-19 12:36:54 +00:00
Maxim Dounin c888914482 Upstream keepalive: "single" parameter deprecated.
The original idea was to optimize edge cases in case of interchangeable
backends, i.e. don't establish a new connection if we have any one
cached.  This causes more harm than good though, as it screws up
underlying balancer's idea about backends used and may result in
various unexpected problems.
2012-06-18 14:23:42 +00:00
Maxim Dounin 574e987c26 Fixed return type of ngx_strerror_init(). 2012-06-18 14:12:03 +00:00
Maxim Dounin 338e278074 Fixed "sendmsg() failed" alerts on HP-UX.
HP-UX needs _HPUX_ALT_XOPEN_SOCKET_API to be defined to be able to
use various POSIX versions of networking functions.  Notably sendmsg()
resulted in "sendmsg() failed (9: Bad file number)" alerts without it.

See xopen_networking(7) for more details.
2012-06-18 14:11:29 +00:00
Maxim Dounin 21773a372a Fixed segfault with poll and resolver used.
Poll event method needs ngx_cycle->files to work, and use of ngx_exit_cycle
without files set caused null pointer dereference in resolver's cleanup
on udp socket close.
2012-06-18 14:10:50 +00:00
Maxim Dounin 1acd38af2e Changed default alignment to 16.
This fixes alignment problems observerd on ARMs, and likely also needed
for MIPSes.  Unless we know alignment is not required just assume we
need 16, which appears to be safe default for all architectures.

See here for details:
http://mailman.nginx.org/pipermail/nginx/2012-June/034139.html
2012-06-18 14:09:54 +00:00
Maxim Dounin 59fc7ee114 Fixed handling of conflicting wildcard server names.
With previous code wildcard names were added to hash even if conflict
was detected.  This resulted in identical names in hash and segfault
later in ngx_hash_wildcard_init().
2012-06-18 14:06:00 +00:00
Maxim Dounin 17988b6c8b Mp4: fixed streaming if moov atom is at buffer edge. 2012-06-18 14:02:20 +00:00
Maxim Dounin 03fbf3c39d Mp4: fixed non-keyframe seeks in some cases (ticket #175).
Number of entries in stsc atom was wrong if we've added an entry to
split a chunk.

Additionally, there is no need to add an entry if we are going to split
last chunk in an entry, it's enough to update the entry we already have.
Previously new entry was added and old one was left as is, resulting in
incorrect entry with zero chunks which might confuse some software.
2012-06-18 14:01:18 +00:00
Andrey Belov 8424d1c513 Style fix. 2012-06-18 13:51:20 +00:00
Andrey Belov 2a11726cbf New core variable: $status.
Contains response status code as a 3-digit integer
(with leading zeroes if necessary), or one of the following values:

    000 - response status code has not yet been assigned
    009 - HTTP/0.9 request is being processed
2012-06-18 13:43:44 +00:00
Ruslan Ermilov ccf583800d When "resolver" is configured with a domain name, only the first
resolved address was used.  Now all addresses will be used.
2012-06-18 12:46:05 +00:00
Ruslan Ermilov 3391492b4b Fixed crash in ngx_resolver_cleanup_tree().
If sending a DNS request fails with an error (e.g., when mistakenly trying
to send it to a local IP broadcast), such a request is not deleted if there
are clients waiting on it.  However, it was still erroneously removed from
the queue.  Later ngx_resolver_cleanup_tree() attempted to remove it from
the queue again that resulted in a NULL pointer dereference.
2012-06-18 12:30:45 +00:00
Ruslan Ermilov ada17a1be5 Version bump. 2012-06-18 11:07:44 +00:00
Ruslan Ermilov 27eb750330 Fixed spelling of "endianness", and called it "byte ordering" in the
user visible part.
2012-06-08 09:41:55 +00:00
Maxim Dounin 94686805e3 release-1.2.1 tag 2012-06-05 14:02:03 +00:00
Maxim Dounin 5ab78b4f1d release-1.3.1 tag 2012-06-05 13:47:50 +00:00
Maxim Dounin e8474c8e73 nginx-1.3.1-RELEASE 2012-06-05 13:47:29 +00:00
Maxim Dounin 73368a5019 Win32: uris with ":$" are now rejected.
There are too many problems with special NTFS streams, notably "::$data",
"::$index_allocation" and ":$i30:$index_allocation".

For now we don't reject all URIs with ":" like Apache does as there are no
good reasons seen yet, and there are multiple programs using it in URLs
(e.g. MediaWiki).
2012-06-05 13:38:27 +00:00
Maxim Dounin 03accd8cba Win32: normalization of trailing dot inside uri.
Windows treats "/directory./" identical to "/directory/".  Do the same
when working on Windows.  Note that the behaviour is different from one
with last path component (where multiple spaces and dots are ignored by
Windows).
2012-06-05 13:37:29 +00:00
Maxim Dounin f6d86c82f6 Win32: disallowed access to various non-canonical name variants.
This includes trailings dots and spaces, NTFS streams (and short names, as
previously checked).  The checks are now also done in ngx_file_info(), thus
allowing to use the "try_files" directive to protect external scripts.
2012-06-05 13:36:09 +00:00
Ruslan Ermilov 19652a2a33 Support for IPv6 literals and an optional port in resolver. 2012-06-04 14:23:27 +00:00
Maxim Dounin b4702b5708 Support for IPv6 literals in proxy_pass and so on. 2012-06-04 14:07:34 +00:00
Maxim Dounin 335998961b Upstream: least_conn compilation fixes.
Removed duplicate call of ngx_http_upstream_init_round_robin_peer()
overlooked during code changes.  Rewritten "return lcp->free_rr_peer(...)"
as MSVC doesn't like it.
2012-06-04 00:00:28 +00:00
Maxim Dounin 4ae095f0d0 Upstream: weights support in ip_hash balancer. 2012-06-03 23:22:41 +00:00
Maxim Dounin 57fb58a1e8 Upstream: least_conn balancer module. 2012-06-03 23:21:26 +00:00
Maxim Dounin eefc559c2b Resolver: fixed format specification.
Patch by Yichun Zhang (agentzh).
2012-06-03 23:18:24 +00:00
Ruslan Ermilov 079a30a5ac Code reduction (no functional changes). 2012-06-01 11:35:09 +00:00
Valentin Bartenev 8973fd9209 Removed mistaken setting of NGX_SSL_BUFFERED flag in ngx_ssl_send_chain()
if SSL buffer is not used.
2012-05-30 12:43:27 +00:00
Valentin Bartenev 5f909780bd Fixed returned value handling from the cookie rewrite handler.
If the "proxy_cookie_domain" or "proxy_cookie_path" directive is used and there
are no matches in Set-Cookie header then ngx_http_proxy_rewrite_cookie() returns
NGX_DECLINED to indicate that the header was not rewritten. Returning this value
further from the upstream headers copy handler resulted in 500 error response.

See here for report:
http://mailman.nginx.org/pipermail/nginx/2012-May/033858.html
2012-05-30 12:30:03 +00:00
Ruslan Ermilov 2273b15eb5 geoip: got rid of ugly casts when calling ngx_free().
This is done by removing the "const" qualifier from the common return
type of handler functions returning either "const char *" or "char *".
2012-05-29 09:19:51 +00:00
Ruslan Ermilov 599b1c2e9e Fixed broken build. 2012-05-28 14:20:04 +00:00
Ruslan Ermilov b64ab07328 Fixed memory leak if $geoip_org variable was used.
Patch by Denis F. Latypoff (slightly modified).
2012-05-28 13:17:48 +00:00
Ruslan Ermilov da3525a877 Fixed the reuse of parsed DTDs and XSLTs.
Patch by Kuramoto Eiji.
2012-05-24 07:35:12 +00:00
Maxim Dounin 05933e3a32 Fixed compilation with -DNGX_DEBUG_MALLOC on FreeBSD 10.
After jemalloc 3.0.0 import there is no _malloc_options symbol, it has
been replaced with the malloc_conf one with a different syntax.
2012-05-23 15:07:01 +00:00
Maxim Dounin 8ee2806337 Fixed warning during nginx.xs compilation. 2012-05-23 10:36:12 +00:00
Ruslan Ermilov 17622dfdf1 Fixed potential null pointer dereference in ngx_resolver_create().
While here, improved error message.
2012-05-22 13:12:14 +00:00
Ruslan Ermilov df1660c004 Removed historical and now redundant syntax pre-checks in ngx_parse_url(). 2012-05-21 10:55:10 +00:00
Maxim Dounin d79d5818e6 Fixed core variables dynamic access after reconfiguration.
If variable was indexed in previous configuration but not in current
one, the NGX_HTTP_VAR_INDEXED flag was left set and confused
ngx_http_get_variable().

Patch by Yichun Zhang (agentzh), slightly modified.
2012-05-17 18:10:34 +00:00
Maxim Dounin c4760a443b Fixed segfault with filter_finalize introduced in r4621 (1.3.0).
Example configuration to reproduce:

    location /image/ {
        error_page 415 = /zero;
        image_filter crop 100 100;
        proxy_pass http://127.0.0.1:8080;
        proxy_store on;
    }

    location /zero {
        return 204;
    }

The problem appeared if upstream returned (big enough) non-image file,
causing 415 to be generated by image filter.
2012-05-17 17:41:40 +00:00
Valentin Bartenev c6467ab653 Fixed building --with-cpp_test_module on some systems. 2012-05-17 15:12:45 +00:00
Valentin Bartenev 2d615aa0db Fixed the ngx_regex.h header file compatibility with C++. 2012-05-17 13:47:04 +00:00
Ruslan Ermilov e341d03a00 Zero padded the returned and logged HTTP status code, and fixed possible
buffer overrun in $status handling.
2012-05-16 13:27:04 +00:00
Ruslan Ermilov f0eaf1d05f Capped the status code that may be returned with "return" and "try_files". 2012-05-16 13:22:03 +00:00
Ruslan Ermilov b31cd0a34a Added syntax checking of the second parameter of the "split_clients" directive. 2012-05-16 13:14:53 +00:00
Ruslan Ermilov 62922d1f91 Version bump. 2012-05-16 13:09:39 +00:00
Maxim Dounin 54c7451b37 release-1.3.0 tag 2012-05-15 14:24:09 +00:00
Maxim Dounin 770e771423 nginx-1.3.0-RELEASE 2012-05-15 14:23:49 +00:00
Maxim Dounin 18e2bb410d Updated OpenSSL used for win32 builds. 2012-05-15 14:20:06 +00:00
Ruslan Ermilov 3551ac6d43 Fixed win32 build after changes in r4624. 2012-05-15 08:10:59 +00:00
Valentin Bartenev e226297beb Update c->sent in ngx_ssl_send_chain() even if SSL buffer is not used. 2012-05-14 16:30:33 +00:00
Ruslan Ermilov 19e780d7ee Reverted previous attempt to fix complation warning introduced in
r4624 and actually fixed it.
2012-05-14 15:52:37 +00:00
Ruslan Ermilov 95db3e384a geoip: trusted proxies support and partial IPv6 support.
The module now supports recursive search of client address through the
chain of trusted proxies (closes #100), in the same scope as the geo
module.  Proxies are listed by the "geoip_proxy" directive, recursive
search is enabled by the "geoip_proxy_recursive" directive.  IPv6 is
partially supported: proxies may be specified with IPv6 addresses.

Example:
    geoip_country .../GeoIP.dat;
    geoip_proxy 127.0.0.1;
    geoip_proxy ::1;
    geoip_proxy 10.0.0.0/8;
    geoip_proxy_recursive on;
2012-05-14 14:00:17 +00:00
Ruslan Ermilov e928278250 geo: chains of trusted proxies and partial IPv6 support.
The module now supports recursive search of client address through
the chain of trusted proxies, controlled by the "proxy_recursive"
directive in the "geo" block.  It also gets partial IPv6 support:
now proxies may be specified with IPv6 addresses.

Example:
    geo $test {
        ...
        proxy 127.0.0.1;
        proxy ::1;
        proxy_recursive;
    }

There's also a slight change in behavior.  When original client
address (as specified by the "geo" directive) is one of the
trusted proxies, and the value of the X-Forwarded-For request
header cannot not be parsed as a valid address, an original client
address will be used for lookup.  Previously, 255.255.255.255 was
used in this case.
2012-05-14 13:53:22 +00:00
Ruslan Ermilov 8ec865acd9 Fixed compilation warning introduced in r4624. 2012-05-14 13:15:22 +00:00
Ruslan Ermilov f4d172c6c4 realip: chains of trusted proxies and IPv6 support.
The module now supports recursive search of client address through
the chain of trusted proxies, controlled by the "real_ip_recursive"
directive (closes #2).  It also gets full IPv6 support (closes #44)
and canonical value of the $client_addr variable on address change.

Example:
    real_ip_header X-Forwarded-For;
    set_real_ip_from 127.0.0.0/8;
    set_real_ip_from ::1;
    set_real_ip_from unix:;
    real_ip_recursive on;
2012-05-14 12:41:03 +00:00
Ruslan Ermilov fd1fba5763 New function ngx_http_get_forwarded_addr() to look up real client address.
On input it takes an original address, string in the X-Forwarded-For format
and its length, list of trusted proxies, and a flag indicating to perform
the recursive search.  On output it returns NGX_OK and the "deepest" valid
address in a chain, or NGX_DECLINED.  It supports AF_INET and AF_INET6.
Additionally, original address and/or proxy may be specified as AF_UNIX.
2012-05-14 12:27:41 +00:00
Maxim Dounin 71ffad056a Upstream: fixed ip_hash rebalancing with the "down" flag.
Due to weight being set to 0 for down peers, order of peers after sorting
wasn't the same as without the "down" flag (with down peers at the end),
resulting in client rebalancing for clients on other servers.  The only
rebalancing which should happen after adding "down" to a server is one
for clients on the server.

The problem was introduced in r1377 (which fixed endless loop by setting
weight to 0 for down servers).  The loop is no longer possible with new
smooth algorithm, so preserving original weight is safe.
2012-05-14 09:58:07 +00:00
Maxim Dounin da7357fa5e Upstream: smooth weighted round-robin balancing.
For edge case weights like { 5, 1, 1 } we now produce { a, a, b, a, c, a, a }
sequence instead of { c, b, a, a, a, a, a } produced previously.

Algorithm is as follows: on each peer selection we increase current_weight
of each eligible peer by its weight, select peer with greatest current_weight
and reduce its current_weight by total number of weight points distributed
among peers.

In case of { 5, 1, 1 } weights this gives the following sequence of
current_weight's:

     a  b  c
     0  0  0  (initial state)

     5  1  1  (a selected)
    -2  1  1

     3  2  2  (a selected)
    -4  2  2

     1  3  3  (b selected)
     1 -4  3

     6 -3  4  (a selected)
    -1 -3  4

     4 -2  5  (c selected)
     4 -2 -2

     9 -1 -1  (a selected)
     2 -1 -1

     7  0  0  (a selected)
     0  0  0

To preserve weight reduction in case of failures the effective_weight
variable was introduced, which usually matches peer's weight, but is
reduced temporarily on peer failures.

This change also fixes loop with backup servers and proxy_next_upstream
http_404 (ticket #47), and skipping alive upstreams in some cases if there
are multiple dead ones (ticket #64).
2012-05-14 09:57:20 +00:00
Maxim Dounin bc191a2699 Fixed possible request hang with filter finalization.
With r->filter_finalize set the ngx_http_finalize_connection() wasn't
called from ngx_http_finalize_request() called with NGX_OK, resulting in
r->main->count not being decremented, thus causing request hang in some
rare situations.

See here for more details:
http://mailman.nginx.org/pipermail/nginx-devel/2012-May/002190.html

Patch by Yichun Zhang (agentzh).
2012-05-14 09:48:05 +00:00
Maxim Dounin 3aa1296653 Resolver: protection from duplicate responses.
If we already had CNAME in resolver node (i.e. rn->cnlen and rn->u.cname
set), and got additional response with A record, it resulted in rn->cnlen
set and rn->u.cname overwritten by rn->u.addr (or rn->u.addrs), causing
segmentation fault later in ngx_resolver_free_node() on an attempt to free
overwritten rn->u.cname.  The opposite (i.e. CNAME got after A) might cause
similar problems as well.
2012-05-14 09:13:45 +00:00
Maxim Dounin aca0c6088d Accept moderation in case of EMFILE/ENFILE.
In case of EMFILE/ENFILE returned from accept() we disable accept events,
and (in case of no accept mutex used) arm timer to re-enable them later.
With accept mutex we just drop it, and rely on normal accept mutex handling
to re-enable accept events once it's acquired again.

As we now handle errors in question, logging level was changed to "crit"
(instead of "alert" used for unknown errors).

Note: the code might call ngx_enable_accept_events() multiple times if
there are many listen sockets.  The ngx_enable_accept_events() function was
modified to check if connection is already active (via c->read->active) and
skip it then, thus making multiple calls safe.
2012-05-11 13:33:06 +00:00
Maxim Dounin 9466cac7e8 Rewrite: fixed escaping and possible segfault (ticket #162).
The following code resulted in incorrect escaping of uri and possible
segfault:

    location / {
        rewrite ^(.*) $1?c=$1;
        return 200 "$uri";
    }

If there were arguments in a rewrite's replacement string, and length was
actually calculated (due to duplicate captures as in the example above,
or variables present), the is_args flag was set and incorrectly copied
after length calculation.  This resulted in escaping applied to the uri part
of the replacement, resulting in incorrect escaping.  Additionally, buffer
was allocated without escaping expected, thus this also resulted in buffer
overrun and possible segfault.
2012-05-11 13:19:22 +00:00
Maxim Dounin a696ef1c32 Fastcgi: fixed padding handling on fixed-size records.
Padding was incorrectly ignored on end request, empty stdout and stderr
fastcgi records.  This resulted in protocol desynchronization if fastcgi
application used these records with padding for some reason.

Reported by Ilia Vinokurov.
2012-05-11 13:14:58 +00:00
Maxim Dounin 73cb76f94c Added r->state reset on fastcgi/scgi/uwsgi request start.
Failing to do so results in problems if 400 or 414 requests are
redirected to fastcgi/scgi/uwsgi upstream, as well as after invalid
headers got from upstream.  This was already fixed for proxy in r3478,
but fastcgi (the only affected protocol at that time) was missed.

Reported by Matthieu Tourne.
2012-05-11 13:09:24 +00:00
Maxim Dounin 78d84ebccb Added write event handler reset in ngx_http_named_location().
On internal redirects this happens via ngx_http_handler() call, which is
not called on named location redirect.  As a result incorrect write handler
remained (if previously set) and this might cause incorrect behaviour (likely
request hang).

Patch by Yichun Zhang (agentzh).
2012-05-04 11:35:22 +00:00
Ruslan Ermilov bd3b9ddf0f debug_connection: added the IPv6 and UNIX-domain socket support. 2012-04-29 22:02:18 +00:00
Valentin Bartenev 1049bd0334 Removed surplus condition. 2012-04-27 10:48:42 +00:00
Andrey Belov 6a46aa9c8c Allows particular modules to handle subrequests properly. 2012-04-26 13:06:27 +00:00
Ruslan Ermilov 001aaa24d7 Fixed segmentation fault in ngx_resolver_create_name_query().
If name passed for resolution was { 0, NULL } (e.g. as a result
of name server returning CNAME pointing to ".") pointer wrapped
to (void *) -1 resulting in segmentation fault on an attempt to
dereference it.

Reported by Lanshun Zhou.
2012-04-26 12:58:42 +00:00
Maxim Dounin 6ce6b2911a Version bump. 2012-04-26 11:20:29 +00:00
Maxim Dounin ce80bcfff4 release-1.2.0 tag 2012-04-23 13:07:07 +00:00
Maxim Dounin 91d403e043 nginx-1.2.0-RELEASE 2012-04-23 13:06:47 +00:00
Maxim Dounin 3d8c70a1cf Version bump. 2012-04-23 12:54:14 +00:00
Igor Sysoev df0ab1bc56 Fix of "%f" format handling.
ngx_sprintf("%.2f", 0.999) incorrectly resulted in "0.100" instead of "1.00".
2012-04-23 11:11:32 +00:00
Maxim Dounin a7f0314fa9 Update openssl used for win32 builds. 2012-04-23 11:05:21 +00:00
Maxim Dounin f512254db7 Proxy: added ctx checking to input filters.
The proxy module context may be NULL in case of filter finalization
(e.g. by image_filter) followed by an internal redirect.  This needs
some better handling, but for now just check if ctx is still here.
2012-04-23 10:40:01 +00:00
Maxim Dounin fa57f456e6 Image filter: compare aspect ratio more accurately during crop.
Previously used fixed-point calculation caused wrong code path selection
in some cases, resulting in incorrect image size.

See here for report:
http://mailman.nginx.org/pipermail/nginx-devel/2012-April/002123.html
2012-04-21 19:02:21 +00:00
Maxim Dounin 6297486201 Fixed segfault with try_files (ticket #152).
The problem occured if first uri in try_files was shorter than request uri,
resulting in reserve being 0 and hence allocation skipped.  The bug was
introduced in r4584 (1.1.19).
2012-04-19 15:48:03 +00:00
Maxim Dounin 473942c035 Fixed master exit if there is no events section (ticket #150).
Instead of checking if there is events{} section present in configuration
in init_module handler we now do the same in init_conf handler.  This
allows master process to detect incorrect configuration early and
reject it.
2012-04-18 14:47:10 +00:00
Ruslan Ermilov 748ee0f18b Don't silently ignore the last line of configuration file that
consists solely of one unterminated token (inspired by #150).
2012-04-18 13:30:43 +00:00
Maxim Dounin 793b52c6fd Fixed ngx_readv_chain() to honor IOV_MAX (ticket #14).
Not using full chain passed is ok as consumers are expected to check
event's ready flag to determine if another call is needed, not the
returned size.
2012-04-17 09:13:58 +00:00
Maxim Dounin c004de4166 IOV_MAX handling microoptimization.
We now stop on IOV_MAX iovec entries only if we are going to add new one,
i.e. next buffer can't be coalesced into last iovec.

This also fixes incorrect checks for trailer creation on FreeBSD and
Mac OS X, header.nelts was checked instead of trailer.nelts.
2012-04-17 09:13:15 +00:00
Maxim Dounin 1f0dccf0f6 Fixed loop in ngx_writev_chain() and ngx_solaris_sendfilev_chain().
The "complete" flag wasn't cleared on loop iteration start, resulting in
broken behaviour if there were more than IOV_MAX buffers and first
iteration was fully completed (and hence the "complete" flag was set
to 1).
2012-04-17 09:10:50 +00:00
Maxim Dounin ed8af1fd81 Fixed log->action after ssl handshake. 2012-04-16 13:05:20 +00:00
Ruslan Ermilov dd622656ad Fixed grammar in error messages. 2012-04-12 19:35:41 +00:00
Maxim Dounin ec7d5874cd Version bump. 2012-04-12 16:34:59 +00:00
Maxim Dounin 6757a8857e release-1.1.19 tag 2012-04-12 12:43:31 +00:00
Maxim Dounin b647f7e293 nginx-1.1.19-RELEASE 2012-04-12 12:42:46 +00:00
Maxim Dounin bca5c0993d Mp4: sanity checks cleanup. 2012-04-12 12:18:14 +00:00
Ruslan Ermilov dc686bacd4 Reduced the number of lines of code in ngx_inet_addr(). 2012-04-12 10:20:33 +00:00
Ruslan Ermilov 3ac27a9236 Fixed buffer overflow when long URI is processed by "try_files" in
regex location with "alias" (fixes ticket #135).
2012-04-12 09:19:14 +00:00
Ruslan Ermilov bf34b6049c Improved readability of the code that produces bitmask from prefix.
In collaboration with Maxim Dounin.
2012-04-11 17:18:15 +00:00
Ruslan Ermilov 575b212faa Fixed directives inheritance. 2012-04-11 09:56:30 +00:00
Maxim Dounin 3e1b54f325 Access module: fixed inheritance of allow/deny ipv6 rules.
Previous (incorrect) behaviour was to inherit ipv6 rules separately from
ipv4 ones.  Now all rules are either inherited (if there are no rules
defined at current level) or not (if there are any rules defined).
2012-04-10 13:25:53 +00:00
Igor Sysoev 6563fc34b7 Fixed debug logging. 2012-04-10 11:28:59 +00:00
Igor Sysoev bb8ba158e0 Fixed previous commit. 2012-04-10 11:27:43 +00:00
Igor Sysoev 9041d31766 Fixed mp4 module seek. 2012-04-10 11:21:47 +00:00
Maxim Dounin 8acd0ef88a Fixed signed integer overflows in timer code (ticket #145).
Integer overflow is undefined behaviour in C and this indeed caused
problems on Solaris/SPARC (at least in some cases).  Fix is to
subtract unsigned integers instead, and then cast result to a signed
one, which is implementation-defined behaviour and used to work.

Strictly speaking, we should compare (unsigned) result with the maximum
value of the corresponding signed integer type instead, this will be
defined behaviour.  This will require much more changes though, and
considered to be overkill for now.
2012-04-06 23:46:09 +00:00
Andrey Belov 0b24fd0a7c Comment fixed. 2012-04-05 19:49:34 +00:00
Maxim Konovalov 0e4566ef82 Style: the function type should be on a line by itself
preceding the function.  No functional changes.
2012-04-05 15:32:43 +00:00
Ruslan Ermilov 4a0e842e42 In ngx_ptocidr(), check that the supplied prefix length is within
the allowed range.
2012-04-03 08:22:00 +00:00
Ruslan Ermilov 32620c4c63 Fixed spelling in multiline C comments. 2012-04-03 07:37:31 +00:00
Maxim Dounin 85c4a8b269 Win32: improved ngx_mutex_init() stub (ticket #138).
This allows to run nginx with "master_process off" under Windows.
2012-04-02 21:31:45 +00:00
Maxim Dounin 988ffba69c Win32: fixed memory allocation for shmem name (ticket #134). 2012-04-02 21:30:58 +00:00
Maxim Dounin f33e66dc3c Upstream: reject upstreams without normal servers.
Such upstreams cause CPU hog later in the code as number of peers isn't
expected to be 0.  Currently this may happen either if there are only backup
servers defined in an upstream block, or if server with ipv6 address used
in an upstream block.
2012-04-02 21:29:35 +00:00
Maxim Dounin 4d7c823b8c Version bump. 2012-04-02 21:28:31 +00:00
Ruslan Ermilov 0915c2bdb8 Corrected spelling of error message (ticket #136). 2012-03-29 19:47:27 +00:00
Maxim Dounin 8f285af8c8 release-1.1.18 tag 2012-03-28 13:29:55 +00:00
Maxim Dounin dfc2c89344 nginx-1.1.18-RELEASE 2012-03-28 13:29:29 +00:00
Maxim Dounin 5c69849ed8 Fixed win32 build after realpath changes in r4559. 2012-03-28 13:04:39 +00:00
Maxim Dounin 91e7e7c8a1 Configure: fixed msghdr.msg_control test on 64bit platforms.
Broken by r4560.
2012-03-28 12:38:03 +00:00
Ruslan Ermilov 57c94d4bf0 Replaced ngx_http_realip_from_t with ngx_in_cidr_t. 2012-03-28 09:29:09 +00:00
Ruslan Ermilov b063ae220b Fixed calculation of range boundaries. 2012-03-28 06:50:23 +00:00
Maxim Dounin 8604ec37dd Xslt: parser options now set with xmlCtxtUseOptions().
Note that "ctxt->loadsubset = 1" previously used isn't really correct as
ctxt->loadsubset is a bitfield now.  The use of xmlCtxtUseOptions() with
XML_PARSE_DTDLOAD is believed to be a better way to do the same thing.

Patch by Laurence Rowe.
2012-03-28 01:56:49 +00:00
Maxim Dounin 2afba4d789 Fixed more gcc46 warnings in configure tests.
Steps to reproduce:

./configure --with-cc="gcc46" --with-cc-opt="-Wall -Werror -O2"
2012-03-27 16:44:52 +00:00
Maxim Dounin 4d414131b7 Fixed unconditional MAX_PATH usage (ticket #22).
POSIX doesn't require it to be defined, and Debian GNU/Hurd doesn't define
it.  Note that if there is no MAX_PATH defined we have to use realpath()
with NULL argument and free() the result.
2012-03-27 16:42:34 +00:00
Maxim Dounin f9139efec0 Added explicit include of time.h.
Most of the systems have it included due to namespace pollution, but
relying on this is a bad idea.  Explicit include is required for at least
Debian GNU/Hurd.
2012-03-27 16:37:43 +00:00
Maxim Dounin 55c3413fe6 Resolver: added missing sanity checking when creating name queries.
Found by Veracode.
2012-03-22 11:57:18 +00:00
Maxim Dounin 022aa04394 Win32: added missing call to srand().
Found by Veracode.
2012-03-22 10:45:08 +00:00
Maxim Dounin a36faf0acf Added xslt_param and xslt_string_param directives.
Based on patch by Samuel Behan.
2012-03-22 10:44:00 +00:00
Maxim Dounin 9e4be5bb48 Fixed off-by-one in xslt parameter parsing.
The problem was introduced in 0.7.44 (r2589) during conversion to complex
values.  Previously string.len included space for terminating NUL, but
with complex values it doesn't.
2012-03-22 10:43:33 +00:00
Maxim Dounin a96c127a61 Restricted keepalive_disable safari to OS X only.
The problem doesn't affect non-Apple systems for sure, and many pretend
to be Safari now.

Prodded by Piotr Sikora.
2012-03-22 10:42:27 +00:00
Maxim Dounin 35307c9599 Removed safari from keepalive_disable default.
The bug in question is likely already fixed (though unfortunately we have
no information available as Apple's bugtracker isn't open), and the
workaround seems to be too pessimistic for modern versions of Safari
as well as other webkit-based browsers pretending to be Safari.
2012-03-22 10:41:29 +00:00
Ruslan Ermilov ade29f616b The addition of $tcpinfo_* variables has broken the build on Linux
systems with glibc versions prior to 2.7.  Fixed this by checking
the existence of "struct tcp_info" members during configuration.
2012-03-21 15:35:05 +00:00
Ruslan Ermilov 448f8672fd worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support. 2012-03-21 13:58:51 +00:00
Ruslan Ermilov 1143677c21 If we inserted "Last-Modified" in r->headers_out.headers, don't
forget to set the r->headers_out.last_modified pointer to it.
2012-03-21 07:35:43 +00:00
Ruslan Ermilov 7eb5b0c22e Minor ngx_http_headers_filter_module.c code cleanup.
- Removed "hash" element from ngx_http_header_val_t which was always 1.
- Replaced NGX_HTTP_EXPIRES_* with ngx_http_expires_t enum type.
- Added prototype for ngx_http_add_header()
- Simplified ngx_http_set_last_modified().
2012-03-21 06:19:11 +00:00
Maxim Konovalov 33e34cdf78 For the sake of case/switch code readability, 'fall through'
comments added.
2012-03-19 14:57:29 +00:00
Ruslan Ermilov d4d9cea998 Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
$tcpinfo_rcv_space variables.  Supported on Linux and FreeBSD.
2012-03-16 19:15:33 +00:00
Ruslan Ermilov 5b40bbbb9c Some older OSes (notably FreeBSD 4.x) did not have %zu
format specifier, so revert to using %d.
2012-03-16 07:33:55 +00:00
Ruslan Ermilov 8a4f3a138e Fixed compilation warnings in configuration C tests.
Based on a patch by Piotr Sikora.
2012-03-15 20:39:38 +00:00
Ruslan Ermilov c1b87dc54c Local variable "ngx_http_next_filter" renamed to "ngx_http_next_body_filter"
for consistency with other modules.
2012-03-15 20:08:58 +00:00
Ruslan Ermilov 99ca3f26dc The "error_log" directive specified in the "http", "server", and
"location" sections now understands the special "stderr" parameter.
It was already treated specially when specified in the main section.
2012-03-15 20:04:50 +00:00
Ruslan Ermilov 7a5b5e5926 Slight optimization in ngx_http_get_variable_index(). 2012-03-15 19:41:35 +00:00
Ruslan Ermilov 3b066cec82 - New variable: $connection_requests.
- While here, fixed format specifier for $connection.
2012-03-15 19:37:32 +00:00
Maxim Dounin dc7ac807b0 Version bump. 2012-03-15 17:43:54 +00:00
Maxim Dounin fa9b0ad877 release-1.1.17 tag 2012-03-15 11:32:39 +00:00
Maxim Dounin 8d23dd97c6 nginx-1.1.17-RELEASE 2012-03-15 11:32:18 +00:00
Maxim Dounin 7c80c856e4 Headers with null character are now rejected.
Headers with NUL character aren't allowed by HTTP standard and may cause
various security problems.  They are now unconditionally rejected.
2012-03-15 11:27:57 +00:00
Maxim Dounin b205e8c661 Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
This resulted in a disclosure of previously freed memory if upstream
server returned specially crafted response, potentially exposing
sensitive information.

Reported by Matthew Daley.
2012-03-15 11:27:12 +00:00
Maxim Dounin ff3f2356f7 Fixed ssi and perl interaction.
Embedded perl module assumes there is a space for terminating NUL character,
make sure to provide it in all situations by allocating one extra byte for
value buffer.  Default ssi_value_length is reduced accordingly to
preserve 256 byte allocations.

While here, fixed another one byte value buffer overrun possible in
ssi_quoted_symbol_state.

Reported by Matthew Daley.
2012-03-15 11:23:07 +00:00
Maxim Dounin da14c9c7f0 Uwsgi: merged r->http_version fixes from scgi module.
Fixed incorrect use of r->http_version (r4372).  Removed duplicate function
declaration (r4373).  Removed error if there is no Status header (r4374).
2012-03-15 11:21:54 +00:00
Maxim Dounin 3ad068cbe7 Updated OpenSSL and PCRE used for win32 builds. 2012-03-15 01:57:09 +00:00
Ruslan Ermilov 5545b46598 Mentioned the NGINX environment variable. 2012-03-12 12:29:56 +00:00
Ruslan Ermilov b26da8fd5f Added scgi_temp and uwsgi_temp to svn:ignore. 2012-03-11 13:33:03 +00:00
Ruslan Ermilov 0fc908aef4 - Applied some of the OpenBSD changes.
- Expanded contractions.
- Fixed some markup.
- Updated URL of official documentation.
2012-03-06 06:54:48 +00:00
Maxim Dounin e59281a5d1 Whitespace fixes. 2012-03-05 18:09:06 +00:00
Maxim Dounin 53395628d4 Grammar and wording fixes in CHANGES. 2012-03-05 18:08:23 +00:00
Maxim Dounin 072c991170 Version bump. 2012-03-05 18:06:15 +00:00
Maxim Dounin 84fc850a0d release-1.1.16 tag 2012-02-29 13:45:39 +00:00
Maxim Dounin cffa4ee9fd nginx-1.1.16-RELEASE 2012-02-29 13:45:18 +00:00
Maxim Dounin f24fcb636f Raised simultaneous subrequest limit from 50 to 200.
It wasn't enforced for a long time, and there are reports that people
use up to 100 simultaneous subrequests now.  As this is a safety limit
to prevent loops, it's raised accordingly.
2012-02-28 14:54:23 +00:00
Maxim Dounin 0583110041 Added msleep() on reload to allow new processes to start.
This is expected to ensure smoother operation on reload (and with less
chance of listen queue overflows).

Prodded by Igor Sysoev.
2012-02-28 11:40:18 +00:00
Ruslan Ermilov ae0f9f2eda Fixed spelling in single-line comments. 2012-02-28 11:31:05 +00:00
Maxim Dounin bddb6dd46e Workaround for fs_size on ZFS (ticket #46).
ZFS reports incorrect st_blocks until file settles on disk, and this
may take a while (i.e. just after creation of a file the st_blocks value
is incorrect).  As a workaround we now use st_blocks only if
st_blocks * 512 > st_size, this should fix ZFS problems while still
preserving accuracy for other filesystems.

The problem had appeared in r3900 (1.0.1).
2012-02-28 11:09:02 +00:00
Maxim Dounin eac588d9f4 Fix of rbtree lookup on hash collisions.
Previous code incorrectly assumed that nodes with identical keys are linked
together.  This might not be true after tree rebalance.

Patch by Lanshun Zhou.
2012-02-27 22:15:39 +00:00
Maxim Dounin 0709b4a272 Fixed null pointer dereference in resolver (ticket #91).
The cycle->new_log.file may not be set before config parsing finished if
there are no error_log directive defined at global level.  Fix is to
copy it after config parsing.

Patch by Roman Arutyunyan.
2012-02-27 16:57:02 +00:00
Valentin Bartenev af4fa91f82 Disable symlinks: added the "from=" parameter to the "disable_symlinks"
directive.
2012-02-27 16:54:10 +00:00
Valentin Bartenev a8fb01eeb5 Disable symlinks: initialization of the "disable_symlinks" field in
ngx_open_file_info_t moved to a separate function.

This is preparation for the "from=" parameter implementation of the
"disable_symlinks" directive.
2012-02-27 16:51:28 +00:00
Valentin Bartenev fb772b6bce Disable symlinks: added the "from" parameter support to the open file cache. 2012-02-27 16:46:57 +00:00
Maxim Dounin 4ce9dbd11f Configure: moved icc detection before gcc.
New versions of icc confuse auto/cc/name due to introduced handling
of a "icc -v":

$ icc -v
icc version 12.1.3 (gcc version 4.6.0 compatibility)
$ icc -V
Intel(R) C Compiler XE for applications running on IA-32, Version 12.1.3.293 Build 20120212
Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.
FOR NON-COMMERCIAL USE ONLY

See report here:
http://mailman.nginx.org/pipermail/nginx/2012-February/032177.html
2012-02-27 16:23:44 +00:00
Ruslan Ermilov 0ede211577 Added support for the 307 Temporary Redirect. 2012-02-27 11:43:40 +00:00
Ruslan Ermilov f6b7715c06 Renamed constants and fixed off-by-one error in "msie_padding on" handling. 2012-02-22 16:23:29 +00:00
Maxim Dounin f0cedf7c8e Event pipe: fixed buffer loss in p->length case.
With previous code raw buffer might be lost if p->input_filter() was called
on a buffer without any data and used ngx_event_pipe_add_free_buf() to
return it to the free list.  This eventually might cause "all buffers busy"
problem, resulting in segmentation fault due to null pointer dereference in
ngx_event_pipe_write_chain_to_temp_file().

In ngx_event_pipe_add_free_buf() the buffer was added to the list start
due to pos == last, and then "p->free_raw_bufs = cl->next" in
ngx_event_pipe_read_upstream() dropped both chain links to the buffer
from the p->free_raw_bufs list.

Fix is to move "p->free_raw_bufs = cl->next" before calling the
p->input_filter().
2012-02-22 11:28:53 +00:00
Valentin Bartenev b4363125b6 Disable symlinks: use O_SEARCH|O_DIRECTORY to open path components. 2012-02-21 15:10:13 +00:00
Valentin Bartenev 2bc52b081d Disable symlinks: don't allow creating or truncating a file via a symlink in
the last path component if "if_not_owner" parameter is used.

To prevent race condition we have to open a file before checking its owner and
there's no way to change access flags for already opened file descriptor, so
we disable symlinks for the last path component at all if flags allow creating
or truncating the file.
2012-02-21 15:04:41 +00:00
Valentin Bartenev 4b7c1acd1a Disable symlinks: cleanups once again.
In collaboration with Ruslan Ermilov.
2012-02-21 15:01:25 +00:00
Maxim Dounin e8935d64fb Disable symlinks: added explicit cast of AT_FDCWD (ticket #111).
Solaris has AT_FDCWD defined to unsigned value, and comparison of a file
descriptor with it causes warnings in modern versions of gcc.  Explicitly
cast AT_FDCWD to ngx_fd_t to resolve these warnings.
2012-02-20 19:14:35 +00:00
Maxim Dounin 377c3bad77 Disable symlinks: error handling cleanup again. 2012-02-20 19:14:07 +00:00
Maxim Dounin 95a4cc0359 Version bump. 2012-02-20 19:12:48 +00:00
Maxim Dounin 64014c63d8 release-1.1.15 tag 2012-02-15 13:26:27 +00:00
Maxim Dounin ade9a9de82 nginx-1.1.15-RELEASE 2012-02-15 13:26:06 +00:00
Maxim Dounin 67d7583b27 Disable symlinks: fixed edge cases of path handling.
This includes non-absolute pathnames, multiple slashes and trailing
slashes.  In collaboration with Valentin Bartenev.
2012-02-15 12:18:55 +00:00
Maxim Dounin 11c469b387 Disable symlinks: cleanup error handling.
Notably this fixes NGX_INVALID_FILE/NGX_FILE_ERROR mess, and adds
logging of close() errors.  In collaboration with Valentin Bartenev.
2012-02-15 12:17:24 +00:00
Andrey Belov 56d422f5cf Support for disable_symlinks in various modules. 2012-02-13 16:32:21 +00:00
Andrey Belov 539efb1940 Added disable_symlinks directive.
To completely disable symlinks (disable_symlinks on)
we use openat(O_NOFOLLOW) for each path component
to avoid races.

To allow symlinks with the same owner (disable_symlinks if_not_owner),
use openat() (followed by fstat()) and fstatat(AT_SYMLINK_NOFOLLOW),
and then compare uids between fstat() and fstatat().

As there is a race between openat() and fstatat() we don't
know if openat() in fact opened symlink or not.  Therefore,
we have to compare uids even if fstatat() reports the opened
component isn't a symlink (as we don't know whether it was
symlink during openat() or not).

Default value is off, i.e. symlinks are allowed.
2012-02-13 16:29:04 +00:00
Andrey Belov 0490d2d367 Changed ngx_open_and_stat_file() to use ngx_str_t.
No functional changes.
2012-02-13 16:16:45 +00:00
Andrey Belov 32aa837633 Added openat()/fstatat(). 2012-02-13 16:13:21 +00:00
Maxim Dounin 05b47509df Time parsing cleanup.
Nuke NGX_PARSE_LARGE_TIME, it's not used since 0.6.30.  The only error
ngx_parse_time() can currently return is NGX_ERROR, check it explicitly
and make sure to cast it to appropriate type (either time_t or ngx_msec_t)
to avoid signedness warnings on platforms with unsigned time_t (notably QNX).
2012-02-13 15:41:11 +00:00
Maxim Dounin f92b0233ad Fixed build with embedded perl and --with-openssl. 2012-02-13 15:38:48 +00:00
Maxim Dounin d55cc2e03d Core: protection from cycles with named locations and post_action.
Now redirects to named locations are counted against normal uri changes
limit, and post_action respects this limit as well.  As a result at least
the following (bad) configurations no longer trigger infinite cycles:

1. Post action which recursively triggers post action:

    location / {
        post_action /index.html;
    }

2. Post action pointing to nonexistent named location:

    location / {
        post_action @nonexistent;
    }

3. Recursive error page for 500 (Internal Server Error) pointing to
   a nonexistent named location:

    location / {
        recursive_error_pages on;
        error_page 500 @nonexistent;
        return 500;
    }
2012-02-13 15:35:48 +00:00
Maxim Dounin 9b8e05ea05 Core: protection from subrequest loops.
Without the protection, subrequest loop results in r->count overflow and
SIGSEGV.  Protection was broken in 0.7.25.

Note that this also limits number of parallel subrequests.  This
wasn't exactly the case before 0.7.25 as local subrequests were
completed directly.

See here for details:
http://nginx.org/pipermail/nginx-ru/2010-February/032184.html
2012-02-13 15:33:08 +00:00
Maxim Dounin b80fae30f1 Variables: honor no_cacheable for not_found variables.
Variables with the "not_found" flag set follow the same rules as ones with
the "valid" flag set.  Make sure ngx_http_get_flushed_variable() will flush
non-cacheable variables with the "not_found" flag set.

This fixes at least one known problem with $args not available in a subrequest
(with args) when there were no args in the main request and $args variable was
queried in the main request (reported by Laurence Rowe aka elro on irc).

Also this eliminates unneeded call to ngx_http_get_indexed_variable() in
cacheable case (as it will return cached value anyway).
2012-02-13 15:31:07 +00:00
Maxim Dounin ebef778394 Fix for proxy_store leaving temporary files for subrequests.
Temporary files might not be removed if the "proxy_store" or "fastcgi_store"
directives were used for subrequests (e.g. ssi includes) and client closed
connection prematurely.

Non-active subrequests are finalized out of the control of the upstream
module when client closes a connection.  As a result, the code to remove
unfinished temporary files in ngx_http_upstream_process_request() wasn't
executed.

Fix is to move relevant code into ngx_http_upstream_finalize_request() which
is called in all cases, either directly or via the cleanup handler.
2012-02-13 15:28:19 +00:00
Maxim Dounin f56bd50397 Gzip filter: handling of empty flush buffers.
Empty flush buffers are legitimate and may happen e.g. due to $r->flush()
calls in embedded perl.  If there are no data buffered in zlib, deflate()
will return Z_BUF_ERROR (i.e. no progress possible) without adding anything
to output.  Don't treat Z_BUF_ERROR as fatal and correctly send empty flush
buffer if we have no data in output at all.

See this thread for details:
http://mailman.nginx.org/pipermail/nginx/2010-November/023693.html
2012-02-13 15:23:43 +00:00
Maxim Dounin 73a1bb1b0e Removed r->cache/r->cached dependencies in range filter.
This is a layering violation, use correct offset calculations instead.
2012-02-13 15:20:49 +00:00
Valentin Bartenev 624ebb175d Proxy: added the "proxy_cookie_path" directive. 2012-02-13 11:08:05 +00:00
Valentin Bartenev bfd33c9c09 Proxy: added the "proxy_cookie_domain" directive. 2012-02-13 11:04:45 +00:00
Valentin Bartenev ad718ac0a1 Upstream: added callback hook for the "Set-Cookie" header.
No functional changes.
2012-02-13 11:01:58 +00:00
Valentin Bartenev 16d884f6f8 Proxy: generic regex related code from the "proxy_redirect" directive moved
to a separate function.

No functional changes.
2012-02-13 11:00:08 +00:00
Valentin Bartenev 3171bf2ce3 Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
separate function with trivial optimization.

No functional changes.
2012-02-13 10:56:09 +00:00
Valentin Bartenev f1dc99c4b9 Proxy: renamed some "proxy_redirect" related declarations to a more general and
reusable.

No functional changes.
2012-02-13 10:42:44 +00:00
Maxim Dounin ddcad9e656 Upstream: fixed "too big header" check.
If header filter postponed processing of a header by returning NGX_AGAIN
and not moved u->buffer->pos, previous check incorrectly assumed there
is additional space and did another recv() with zero-size buffer.  This
resulted in "upstream prematurely closed connection" error instead
of correct "upstream sent too big header" one.

Patch by Feibo Li.
2012-02-10 14:31:04 +00:00
Valentin Bartenev 0f98c982d8 Added ngx_ncpu detection for most *nix platforms.
This inaccurate detection by using sysconf(_SC_NPROCESSORS_ONLN) can improve
usage of the mutex lock optimization on multicore systems.
2012-02-10 11:24:19 +00:00
Valentin Bartenev 4736877982 Limit conn: returned to the old behavior of using the first actual limit on
the way.

It was unintentionally changed in r4272, so that it could only limit the first
location where the processing of the request has reached PREACCESS phase.
2012-02-10 10:48:58 +00:00
Valentin Bartenev 12ae1f6ff9 Fixed module name in comment. It was forgotten in r4281. 2012-02-10 09:56:37 +00:00
Maxim Dounin 8663c9d8b3 Version bump. 2012-02-09 16:18:02 +00:00
Maxim Dounin aa38617773 release-1.1.14 tag 2012-01-30 13:52:35 +00:00
Maxim Dounin 32f33d6032 nginx-1.1.14-RELEASE 2012-01-30 13:52:10 +00:00
Maxim Dounin 31e1b6b491 Update OpenSSL and PCRE used for win32 builds. 2012-01-30 13:47:03 +00:00
Maxim Dounin ac10152bbf Limit req: unbreak compilation with MSVC. 2012-01-30 13:19:25 +00:00
Valentin Bartenev d167490e0a Fixed memory leak on HUP signal when PCRE JIT was used.
The PCRE JIT compiler uses mmap to allocate memory for its executable codes, so
we have to explicitly call the pcre_free_study() function to free this memory.
2012-01-30 12:53:57 +00:00
Valentin Bartenev 8b6fdbb161 Fixed proxy_redirect off inheritance.
Example configuration to reproduce:

  server {
      proxy_redirect off;

      location / {
          proxy_pass http://localhost:8000;
          proxy_redirect http://localhost:8000/ /;

          location ~ \.php$ {
              proxy_pass http://localhost:8000;
              # proxy_redirect must be inherited from the level above,
              # but instead it was switched off here
          }
      }
  }
2012-01-30 11:22:56 +00:00
Maxim Dounin bd8324bb32 Fixed error handling in ngx_event_connect_peer().
Previously if ngx_add_event() failed a connection was freed two times (once
in the ngx_event_connect_peer(), and again by a caller) as pc->connection was
left set.  Fix is to always use ngx_close_connection() to close connection
properly and set pc->connection to NULL on errors.

Patch by Piotr Sikora.
2012-01-30 11:12:52 +00:00
Valentin Bartenev 4e156a3081 Limit req: support for multiple "limit_req" limits. 2012-01-30 10:17:56 +00:00
Valentin Bartenev 2beee3ded5 Limit req: number of cleanup calls reduced.
Doing a cleanup before every lookup seems to be too aggressive. It can lead to
premature removal of the nodes still usable, which increases the amount of work
under a mutex lock and therefore decreases performance.

In order to improve cleanup behavior, cleanup function call has been moved right
before the allocation of a new node.
2012-01-30 10:01:39 +00:00
Valentin Bartenev 903af93a2d Limit req: allocation and initialization of a new node moved to the lookup
function.

No functional changes.
2012-01-30 09:41:49 +00:00
Valentin Bartenev 3943b24350 Limit req: improved error handling when parsing "zone" parameter of
"limit_req_zone" directive; minimum size of zone is increased.

Previously an unsigned variable was used to keep the return value of
ngx_parse_size() function, which led to an incorrect zone size if NGX_ERROR
was returned.

The new code has been taken from the "limit_conn_zone" directive.
2012-01-30 09:26:08 +00:00
Valentin Bartenev 444d248d4c Limit req: error messages fixed. 2012-01-30 09:02:29 +00:00
Maxim Dounin 4759803fcd Fixed AIO error handling on FreeBSD.
The aio_return() must be called regardless of the error returned by
aio_error().  Not calling it resulted in various problems up to segmentation
faults (as AIO events are level-triggered and were reported again and again).

Additionally, in "aio sendfile" case r->blocked was incremented in case of
error returned from ngx_file_aio_read(), thus causing request hangs.
2012-01-30 07:39:47 +00:00
Maxim Dounin a8362260c5 Removed ENGINE_load_builtin_engines() call.
It's already called by OPENSSL_config().  Calling it again causes some
openssl engines (notably GOST) to corrupt memory, as they don't expect
to be created more than once.
2012-01-30 07:38:27 +00:00
Valentin Bartenev c67c399aba Fixed grammar in PCRE JIT error log message. 2012-01-24 10:20:42 +00:00
Maxim Konovalov 0330b7ef84 Copyright updated. 2012-01-18 15:07:43 +00:00
Maxim Konovalov 27418f6b88 Version bump. 2012-01-18 15:04:17 +00:00
Maxim Konovalov 2bad3828ce Version bump. 2012-01-18 14:33:17 +00:00
Ruslan Ermilov 1fdaac7c1b Fixed spelling. 2012-01-17 07:09:51 +00:00
Maxim Dounin 6181007a4b release-1.1.13 tag 2012-01-16 15:15:01 +00:00
Maxim Dounin 4025c3da41 nginx-1.1.13-RELEASE 2012-01-16 15:14:37 +00:00
Maxim Dounin 2a9140cb9f Updated OpenSSL version used for win32 build. 2012-01-16 15:10:36 +00:00
Igor Sysoev 3d0626aa0a 2012 year. 2012-01-16 14:31:15 +00:00
Valentin Bartenev a07b39def4 Fixed division by zero exception in ngx_hash_init().
The ngx_hash_init() function did not expect call with zero elements count,
which caused FPE error on configs with an empty "types" block in http context
and "types_hash_max_size" > 10000.

Example configuration to reproduce:

  events { }

  http {
          types_hash_max_size 10001;
          types {}
          server {}
  }
2012-01-16 12:42:07 +00:00
Maxim Dounin 07400a51a0 Fixed sched_setaffinity(2) to correctly pass size.
Second argument (cpusetsize) is size in bytes, not in bits.  Previously
used constant 32 resulted in reading of uninitialized memory and caused
EINVAL to be returned on some Linux kernels.
2012-01-16 11:13:48 +00:00
Maxim Dounin 0a482a2731 Fixed handling of mp4 above 2G and 32bit offsets (ticket #84). 2012-01-16 11:03:27 +00:00
Maxim Dounin b16574cc45 Fixed proxy_cache_use_stale in "no live upstreams" case. 2012-01-16 11:01:52 +00:00
Maxim Dounin b929dfb429 Added support for TLSv1.1, TLSv1.2 in ssl_protocols directive.
Support for TLSv1.1 and TLSv1.2 protocols was introduced in OpenSSL 1.0.1
(-beta1 was recently released).  This change makes it possible to disable
these protocols and/or enable them without other protocols.
2012-01-11 11:15:00 +00:00
Maxim Dounin 95bbcfcfb0 Fixed limit_req burst/nodelay inheritance (ticket #76).
The problem was introduced in r4381 (1.1.12).
2012-01-11 11:09:05 +00:00
Valentin Bartenev 56b9f427e8 Fixed: proxy_redirect with regex might broke Refresh header.
The problem was localized in ngx_http_proxy_rewrite_redirect_regex() handler
function which did not take into account prefix when overwriting header value.
2012-01-10 15:09:45 +00:00
Ruslan Ermilov de12e8a6ea Changed ngx_log_debugN() macros to verify the number of arguments
when built with debugging.
2012-01-10 07:28:32 +00:00
Valentin Bartenev fcb581b929 Fixed configure with system PCRE library on Solaris.
The bug has been introduced in r4389.
2011-12-29 15:58:53 +00:00
Maxim Konovalov 8eb05fbc39 Some questionable optomizations flags for icc were removed
in order to simplify support of its future versions.
2011-12-29 15:36:07 +00:00
Maxim Dounin 9a4e6534ec Fixed punctuation. 2011-12-28 13:30:56 +00:00
Sergey Budnevitch 21d6f34287 libraries versions updated 2011-12-27 12:39:11 +00:00
Sergey Budnevitch f8fd16fa5e zlib license file include fixed 2011-12-27 12:35:52 +00:00
Maxim Dounin 7d6f981a87 Version bump. 2011-12-27 11:56:48 +00:00
Maxim Dounin 59c811207a release-1.1.12 tag 2011-12-26 15:05:38 +00:00
Maxim Dounin b4ba849348 nginx-1.1.12-RELEASE 2011-12-26 15:05:17 +00:00
Valentin Bartenev 498cc8846a Added support for regex study and PCRE JIT (ticket #41) optimizations on
configuration phase.
2011-12-26 13:10:36 +00:00
Maxim Dounin 2e6a0bc9a3 Fixed build without debug. 2011-12-26 11:33:11 +00:00
Maxim Dounin 01626586ef Cache lock support for fastcgi, scgi, uwsgi. 2011-12-26 11:16:19 +00:00
Maxim Dounin 79b20c6b5a Cache locks initial implementation.
New directives: proxy_cache_lock on/off, proxy_cache_lock_timeout.  With
proxy_cache_lock set to on, only one request will be allowed to go to
upstream for a particular cache item.  Others will wait for a response
to appear in cache (or cache lock released) up to proxy_cache_lock_timeout.

Waiting requests will recheck if they have cached response ready (or are
allowed to run) every 500ms.

Note: we intentionally don't intercept NGX_DECLINED possibly returned by
ngx_http_file_cache_read().  This needs more work (possibly safe, but needs
further investigation).  Anyway, it's exceptional situation.

Note: probably there should be a way to disable caching of responses
if there is already one request fetching resource to cache (without waiting
at all).  Two possible ways include another cache lock option ("no_cache")
or using proxy_no_cache with some supplied variable.

Note: probably there should be a way to lock updating requests as well.  For
now "proxy_cache_use_stale updating" is available.
2011-12-26 11:15:23 +00:00
Maxim Dounin 5254ac2214 Fixed interaction of limit_rate and sendfile_max_chunk.
It's possible that configured limit_rate will permit more bytes per
single operation than sendfile_max_chunk.  To protect disk from takeover
by a single client it is necessary to apply sendfile_max_chunk as a limit
regardless of configured limit_rate.

See here for report (in Russian):
http://mailman.nginx.org/pipermail/nginx-ru/2010-March/032806.html
2011-12-26 10:51:24 +00:00
Maxim Dounin 812f376092 Fixed throughput problems with large limit_rate.
Previous attempt to fix this was in r1658 (0.6.18), though that one wasn't
enough (it was a noop).
2011-12-26 10:49:57 +00:00
Maxim Dounin b59d1cbb0d Fixed mp4 if first entry in stsc was skipped (ticket #72).
If first entry in stsc atom was skipped, and seek was to chunk boundary,
than first_chunk in the generated stsc table wasn't set to 1.
2011-12-26 10:49:03 +00:00
Valentin Bartenev 45bf93e9a3 SSI: added regex captures support in the expression of the "if" command. 2011-12-25 20:08:37 +00:00
Valentin Bartenev 5fe3db9986 Fixed limit_conn_log_level/limit_req_log_level inheritance.
The directives did not work if there were no limit_conn/limit_req specified on
the same level.
2011-12-25 19:32:31 +00:00
Valentin Bartenev 47bf52865b Added the HTTPS fastcgi_param to fastcgi.conf. 2011-12-25 19:15:56 +00:00
Maxim Konovalov 3a82e1a32e Words duplications removed. 2011-12-24 06:31:57 +00:00
Maxim Dounin daa03354a1 Proxy: made proxy_pass with variables more consistent.
If proxy_pass was used with variables and there was no URI component,
nginx always used unparsed URI.  This isn't consistent with "no variables"
case, where e.g. rewrites are applied even if there is no URI component.

Fix is to use the same logic in both cases, i.e. only use unparsed URI if
it's valid and request is the main one.
2011-12-23 16:04:09 +00:00
Sergey Budnevitch 5a87dab604 configure on Solaris fixed 2011-12-20 16:20:23 +00:00
Maxim Dounin 3d27592e55 Added clearing of r->valid_unparsed_uri on internal redirects.
This resolves issue with try_files (see ticket #70), configuration like

   location / { try_files $uri /index.php; }
   location /index.php { proxy_pass http://backend; }

caused nginx to use original request uri in a request to a backend.

Historically, not clearing of the r->valid_unparsed_uri on internal redirect
was a feature: it allowed to pass the same request to (another) upstream
server via error_page redirection.  Since then named locations appeared
though, and it's time to start resetting r->valid_unparsed_uri on internal
redirects.  Configurations still using this feature should be converted
to use named locations instead.

Patch by Lanshun Zhou.
2011-12-19 14:11:48 +00:00
Valentin Bartenev 83a44c4911 SSI bugfix: the "if" command did not work inside the "block" command and
produced parsing errors.
2011-12-19 13:28:22 +00:00
Maxim Dounin 55d48371c1 Scgi: removed error if there is no Status header.
The SCGI specification doesn't specify format of the response, and assuming
CGI specs should be used there is no reason to complain.  RFC 3875
explicitly states that "A Status header field is optional, and status
200 'OK' is assumed if it is omitted".
2011-12-19 11:25:40 +00:00
Maxim Dounin ad51cbc3fe Scgi: removed duplicate function declaration. 2011-12-19 11:24:32 +00:00
Maxim Dounin 1a19f79ca8 Fixed incorrect use of r->http_version in scgi module.
The r->http_version is a version of client's request, and modules must
not set it unless they are really willing to downgrade protocol version
used for a response (i.e. to HTTP/0.9 if no response headers are available).
In neither case r->http_version may be upgraded.

The former code downgraded response from HTTP/1.1 to HTTP/1.0 for no reason,
causing various problems (see ticket #66).  It was also possible that
HTTP/0.9 requests were upgraded to HTTP/1.0.
2011-12-19 11:23:16 +00:00
Maxim Dounin b73c0ebb43 Version bump. 2011-12-19 11:21:46 +00:00
Maxim Dounin 2bb6abc200 release-1.1.11 tag 2011-12-12 14:18:15 +00:00
Maxim Dounin b02bc82b60 nginx-1.1.11-RELEASE 2011-12-12 14:17:49 +00:00
Maxim Dounin d603e24018 Fixed RELEASE target again. 2011-12-12 12:39:19 +00:00
Maxim Dounin 9be0b7043b Fixed RELEASE target to correctly call "release" one. 2011-12-12 11:00:17 +00:00
Maxim Dounin 93d5ba68ea Cache: only complain on long locked entries.
There have been multiple reports of cases where a real locked entry was
removed, resulting in a segmentation fault later in a worker which locked
the entry.  It looks like default inactive timeout isn't enough in real
life.

For now just ignore such locked entries, and move them to the top of the
inactive queue to allow processing of other entries.
2011-12-12 10:49:14 +00:00
Maxim Dounin 48177aca31 Cache: handling of cache files with long headers.
There are two possible situations which can lead to this: response was
cached with bigger proxy_buffer_size value (and nginx was restared since
then, i.e. shared memory zone content was lost), or due to the race in
the cache update code (see [1]) we've end up with fcn->body_start from
a different response stored in shared memory zone.

[1] http://mailman.nginx.org/pipermail/nginx-devel/2011-September/001287.html
2011-12-12 10:47:48 +00:00
Maxim Dounin c49ba92d1b Cache: obsolete code removed.
The ngx_http_cache() and ngx_http_no_cache_set_slot() functions were replaced
by ngx_http_test_predicates() and ngx_http_set_predicate_slot() in 0.8.46 and
no longer used since then.
2011-12-12 10:46:43 +00:00
Ruslan Ermilov 874288a399 Renamed some constants to improve readability, no functional changes. 2011-12-12 10:45:05 +00:00
Valentin Bartenev 288775577a Proxy: added variables and regexp support to the first parameter of
the "proxy_redirect" directive.
2011-12-12 09:02:29 +00:00
Maxim Dounin a9d1027b80 Microoptimization of sendfile(2) usage under FreeBSD.
FreeBSD kernel checks headers/trailers pointer against NULL, not
corresponding count.  Passing NULL if there are no headers/trailers
helps to avoid unneeded work in kernel, as well as unexpected 0 bytes
GIO in traces.
2011-12-11 16:30:42 +00:00
Valentin Bartenev c8c2ea467b Fixed: some of $sent_http_* variables may contain header entries that actually
haven't been sent to a client.

The ngx_http_variable_headers() and ngx_http_variable_unknown_header() functions
did not ignore response header entries with zero "hash" field.

Thanks to Yichun Zhang (agentzh).
2011-12-09 16:17:12 +00:00
Valentin Bartenev 4d85d27e09 Added HTTPS param with Apache-like behaviour to fastcgi/scgi/uwsgi_params (fixes #38). 2011-12-09 15:38:26 +00:00
Valentin Bartenev 2d299d5013 Added the $https variable. 2011-12-09 14:38:11 +00:00
Valentin Bartenev 34e914fc8a SCGI: added "if_not_empty" flag support to the "scgi_param" directive. 2011-12-09 14:03:06 +00:00
Valentin Bartenev a5e50b92f1 uwsgi: added "if_not_empty" flag support to the "uwsgi_param" directive. 2011-12-09 13:47:04 +00:00
Valentin Bartenev bf51ac2b4b FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive. 2011-12-09 13:32:51 +00:00
Valentin Bartenev c3078ac53d Added the ngx_http_upstream_param_set_slot(). 2011-12-09 13:19:57 +00:00
Ruslan Ermilov 076023d59d - Improved error message when parsing of the "buffer" parameter of the
"access_log" directive fails.

- Added a warning if "log_format" is used in contexts other than "http".
2011-12-06 21:07:10 +00:00
Valentin Bartenev 4226107c30 Removed unused function ngx_regex_capture_count().
The function has been unused since r3326.
2011-12-06 15:49:40 +00:00
Maxim Dounin 2b8b63d087 Fix for read_head with try_files and open_file_cache.
The of.read_ahead wasn't set in try_files code path, causing read_ahead
directive to be a nop if try_files and open_file_cache were used.
2011-12-06 13:23:37 +00:00
Maxim Dounin c6c5d937f1 Version bump. 2011-12-06 13:22:32 +00:00
Valentin Bartenev 64320d4c45 Added the "so_keepalive=" parameter to the "listen" directive.
The "so_keepalive" directive in mail module was deprecated.

Thanks to Vsevolod Stakhov for initial work.
2011-12-05 08:06:15 +00:00
Maxim Dounin 170357b9b3 release-1.1.10 tag 2011-11-30 10:01:11 +00:00
Maxim Dounin 0fa395d396 nginx-1.1.10-RELEASE 2011-11-30 10:00:50 +00:00
Ruslan Ermilov 6b46d334ab Compute the repository root from the checkout. 2011-11-30 07:36:09 +00:00
Maxim Dounin 7ef84c1b96 Fixed AIO on Linux, broken in r4306.
Events from eventfd do not have c->write set, and the stale event
check added in r4306 causes null pointer dereference.
2011-11-29 17:27:13 +00:00
Maxim Dounin f252141018 Version bump. 2011-11-29 17:25:31 +00:00
Maxim Dounin 2848d62f33 release-1.1.9 tag 2011-11-28 15:15:14 +00:00
Maxim Dounin 062215d6be nginx-1.1.9-RELEASE 2011-11-28 15:02:38 +00:00
Maxim Dounin e426504e21 Added (void) as we intentionally ignore returned values.
Requested by Igor Sysoev.
2011-11-28 11:01:42 +00:00
Maxim Dounin 98f8eccefb Allowed add_header for proxied 206 replies.
It was working for nginx's own 206 replies as they are seen as 200 in the
headers filter module (range filter goes later in the headers filter chain),
but not for proxied replies.
2011-11-28 10:00:47 +00:00
Valentin Bartenev 291486c4bd Added support for IP-literal in the Host header and request line (ticket #1).
Additional parsing logic added to correctly handle RFC 3986 compliant IPv6 and
IPvFuture characters enclosed in square brackets.

The host validation was completely rewritten. The behavior for non IP literals
was changed in a more proper and safer way:

 - Host part is now delimited either by the first colon or by the end of string
   if there's no colon. Previously the last colon was used as delimiter which
   allowed substitution of a port number in the $host variable.
   (e.g. Host: 127.0.0.1:9000:80)

 - Fixed stripping of the ending dot in the Host header when the host was also
   followed by a port number.
   (e.g. Host: nginx.com.:80)

 - Fixed upper case characters detection. Previously it was broken which led to
   wasting memory and CPU.
2011-11-28 09:15:33 +00:00
Maxim Dounin eaf1314ae3 Added escaping of double quotes in ngx_escape_html().
Patch by Zaur Abasmirzoev.
2011-11-25 16:36:02 +00:00
Maxim Dounin 9e3c5c1792 Unlock of shared memory zones on process crash.
If process exited abnormally while holding lock on some shared memory zone -
unlock it.  It may be not safe thing to do (as crash with lock held may
result in corrupted shared memory structure, and other processes will
subsequently crash while trying to access shared data), therefore complain
loudly if unlock succeeds.
2011-11-23 14:09:19 +00:00
Maxim Dounin 49e9547747 Fixed build without atomic operations. 2011-11-23 14:07:06 +00:00
Maxim Dounin 9d2d3aee6d Added shmtx interface to forcibly unlock mutexes.
It is currently used from master process on abnormal worker termination to
unlock accept mutex (unlocking of accept mutex was broken in 1.0.2).  It is
expected to be used in the future to unlock other mutexes as well.

Shared mutex code was rewritten to make this possible in a safe way, i.e.
with a check if lock was actually held by the exited process.  We again use
pid to lock mutex, and use separate atomic variable for a count of processes
waiting in sem_wait().
2011-11-23 13:55:38 +00:00
Ruslan Ermilov 38d6a346d7 Fixed "rotate" to always work when combined with "resize/crop". 2011-11-23 10:22:44 +00:00
Ruslan Ermilov 18b7122d6e Cosmetics. 2011-11-23 10:16:30 +00:00
Igor Sysoev 1da4d8e81c Fix of mp4 module seeking. 2011-11-23 07:22:15 +00:00
Maxim Dounin 259b961e7b Protection from stale write events in epoll.
Stale write event may happen if epoll_wait() reported both read and write
events, and processing of the read event closed descriptor.

Patch by Yichun Zhang (agentzh).
2011-11-22 17:02:21 +00:00
Maxim Dounin 0d5cf1a261 Fixed segfault on ssl servers without cert with SNI (ticket #54).
Non-default servers may not have ssl context created if there are no
certificate defined.  Make sure to check if ssl context present before
using it.
2011-11-22 16:27:45 +00:00
Ruslan Ermilov f00f3dc803 Made it possible to build/install from the SVN checkout. 2011-11-22 13:26:44 +00:00
Maxim Konovalov 80c62b4aa2 o AIX 7 defines sys_nerr in errno.h, therefore <errno.h> included
in the sys_nerr test.

o When sys_nerr and _sys_nerr are missed on a particular platform
and our euristic for a maximum errno detection applied always
print the maximum errno number we reached instead of printing void.[*]

* patch from Maxim Dounin

This commit makes possible to build nginx on AIX 7.1.
2011-11-21 11:51:41 +00:00
Maxim Konovalov 16825c7e67 svgz extension for compressed SVG added (close #56). 2011-11-21 09:20:50 +00:00
Ruslan Ermilov addbd0bf05 Fixed "keepalive_disable".
Patch by Alexander Usov.  The bug has been introduced in r4267.
2011-11-21 07:31:59 +00:00
Maxim Konovalov e410e4693d FreeBSD 10-current has recently gotten POSIX_FADV_* macros.
A fix for the broken build applied.

Patch from Igor Sysoev.
2011-11-18 18:42:00 +00:00
Maxim Dounin 87648fe191 Upstream: don't cache unfinished responses.
Check if received data length match Content-Length header (if present),
don't cache response if no match found.  This prevents caching of corrupted
response in case of premature connection close by upstream.
2011-11-18 15:09:08 +00:00
Maxim Dounin cf17f65fb6 Fixed flv header to match specification.
Used "\x5" in 5th byte to claim presence of both audio and video.  Used
previous tag size 0 in the beginning of the flv body (bytes 10 .. 13) as
required by specification (see http://www.adobe.com/devnet/f4v.html).

Patch by Piotr Sikora.
2011-11-18 14:41:01 +00:00
Ruslan Ermilov c884156af0 Silenced a warning for some compilers. 2011-11-16 13:27:33 +00:00
Ruslan Ermilov 60b802dc38 Now nginx uses TTL of a DNS response when calculating cache validity.
Previously it used a hardcoded value of 300 seconds.  Also added the
"valid=" parameter to the "resolver" directive that can be used to
override the cache validity time.

Patch by Kirill A. Korinskiy with minor changes.
2011-11-16 13:11:39 +00:00
Valentin Bartenev a19dfffc8f Fixed incorrect counting the length of headers in a SCGI request. 2011-11-16 12:51:27 +00:00
Maxim Dounin 758a031e89 Fixed handling of SIGWINCH/NOACCEPT signal.
After first upgrade it was ignored since r4020 (1.1.1, 1.0.9) as
ngx_daemonized wasn't set.
2011-11-15 20:35:41 +00:00
Maxim Dounin 3bf70b5143 Version bump. 2011-11-15 20:33:37 +00:00
Igor Sysoev eea444b4b1 release-1.1.8 tag 2011-11-14 15:38:02 +00:00
Igor Sysoev e5b23d4bb6 nginx-1.1.8-RELEASE 2011-11-14 15:37:54 +00:00
Igor Sysoev bef9d24ee8 Introduction of simple ngx_write_stderr() instead of ngx_log_stderr()
for output of ./configure options, etc., since ngx_log_stderr() output
length is limited by 2048 characters defined as NGX_MAX_ERROR_STR.
2011-11-14 14:59:00 +00:00
Igor Sysoev e477a6d9d8 Fix of "Content-Length" header of MP4 response if start argument was used.
Patch by Piotr Sikora.
2011-11-14 14:42:48 +00:00
Valentin Bartenev f66679d7fd Added image/webp and video/webm MIME types. 2011-11-14 14:16:51 +00:00
Valentin Bartenev 86fc57edd5 Renamed ngx_http_limit_zone_module to ngx_http_limit_conn_module. 2011-11-14 14:04:42 +00:00
Maxim Dounin 2c5c9e0c24 Reverted incorrect change in internal md5 (part of r3928). 2011-11-14 13:38:02 +00:00
Maxim Dounin a60f482c6b Fixed fastcgi/scgi/uwsgi_param inheritance.
The following problems were fixed:

1. Directive fastcgi_cache affected headers sent to backends in unrelated
   servers / locations (see ticket #45).

2. If-Unmodified-Since, If-Match and If-Range headers were sent to backends
   if fastcgi_cache was used.

3. Cache-related headers were sent to backends if there were no fastcgi_param
   directives and fastcgi_cache was used at server level.
2011-11-14 13:26:18 +00:00
Maxim Dounin f5cb08dc33 Separate functions to merge fastcgi/scgi/uwsgi params.
No functional changes.
2011-11-14 13:24:43 +00:00
Maxim Dounin 9209769d83 Fixed Upgrade header clearing with proxy_cache.
This was missed in proxy HTTP/1.1 support commit (r4127).
2011-11-14 13:21:10 +00:00
Maxim Dounin ab5978088b Fixed proxy_set_header inheritance with proxy_set_body. 2011-11-14 13:19:56 +00:00
Maxim Dounin 6f4903c804 Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Headers cleared with cache enabled (If-Modified-Since etc.) might be cleared
in unrelated servers/locations without proxy_cache enabled if proxy_cache was
used in some server/location.

Example config which triggered the problem:

    proxy_set_header X-Test "test";
    server { location /1 { proxy_cache name; proxy_pass ... } }
    server { location /2 { proxy_pass ... } }

Another one:

    server {
        proxy_cache name;
        location /1 { proxy_pass ... }
        location /2 { proxy_cache off; proxy_pass ... }
    }

In both cases If-Modified-Since header wasn't sent to backend in location /2.

Fix is to not modify conf->headers_source, but instead merge user-supplied
headers from conf->headers_source and default headers (either cache or not)
into separate headers_merged array.
2011-11-14 13:18:15 +00:00
Sergey Budnevitch e0ce48cd7d Fixed NGX_CONF_TAKE1/NGX_CONF_FLAG misuse. 2011-11-14 09:12:15 +00:00
Valentin Bartenev 49c77d2423 Limit zone: added the "limit_conn_zone" directive.
It supersedes old "limit_zone" directive (deprecated accordingly) and uses
syntax consistent with the "limit_req_zone" directive.
2011-11-10 16:25:08 +00:00
Valentin Bartenev 1e127d5be1 Limit zone: support for multiple "limit_conn" limits. 2011-11-10 16:08:13 +00:00
Valentin Bartenev 99b82c698d Limit zone: rbtree lookup moved to a separate function.
No functional changes.
2011-11-10 15:51:55 +00:00
Ruslan Ermilov 5518d9bceb Changed error message to be more appropriate in the imaginary
"open_file_cache max=0" case.
2011-11-10 09:13:09 +00:00
Ruslan Ermilov f9ce97f300 Belatedly fixed language in 1.1.7 relnotes. 2011-11-09 14:50:33 +00:00
Igor Sysoev 6cc6ee5f71 Fixed compression pointer processing in DNS response greater than 255 bytes.
Thanks to Ben Hawkes.
2011-11-09 13:54:07 +00:00
Igor Sysoev a1f95cd5d6 Fix of "keepalive_disable" directive. 2011-11-08 13:48:23 +00:00
Igor Sysoev 2263971f60 The "image_filter_sharpen" directive. 2011-11-08 13:17:14 +00:00
Igor Sysoev f62aef5432 Ancient incomplete ngx_http_status_module removal. 2011-11-01 15:16:28 +00:00
Igor Sysoev c334837744 Version bump. 2011-11-01 15:10:46 +00:00
Igor Sysoev 2c7edf2692 release-1.1.7 tag 2011-10-31 14:52:53 +00:00
Igor Sysoev badc4dc2da nginx-1.1.7-RELEASE 2011-10-31 14:52:46 +00:00
Igor Sysoev aac006c475 Silently ignoring a stale global SSL error left after disabled renegotiation. 2011-10-31 14:30:03 +00:00
Ruslan Ermilov ee6e8a7706 Fixed documentation pointer. 2011-10-31 10:38:20 +00:00
Maxim Dounin ec358eb17b Fixed segfault on configuration testing with ssl (ticket #37).
The following config caused segmentation fault due to conf->file not
being properly set if "ssl on" was inherited from the http level:

http {
    ssl on;
    server {
    }
}
2011-10-31 09:57:14 +00:00
Maxim Dounin 9f5881a6e2 Event pipe: reduced number of file buffers used.
If possible we now just extend already present file buffer in p->out chain
instead of keeping ngx_buf_t for each buffer we've flushed to disk.  This
saves about 120 bytes of memory per buffer flushed to disk, and resolves
high CPU usage observed in edge cases (due to coalescing these buffers on
send).
2011-10-31 09:54:55 +00:00
Maxim Dounin 5cd4f605e6 Event pipe: fixes for complex protocols.
1. In ngx_event_pipe_write_chain_to_temp_file() make sure to fully write
   all shadow buffers up to last_shadow.  With this change recycled buffers
   cannot appear in p->out anymore.  This also fixes segmentation faults
   observed due to ngx_event_pipe_write_chain_to_temp() not freeing any
   raw buffers while still returning NGX_OK.

2. In ngx_event_pipe_write_to_downstream() we now properly check for busy
   size as a size of buffers, not a size of data in these buffers.  This
   fixes situations where all available buffers became busy (including
   segmentation faults due to this).

3. The ngx_event_pipe_free_shadow_raw_buf() function is dropped.  It's
   incorrect and not needed.
2011-10-31 09:53:16 +00:00
Igor Sysoev 05f4f1ad57 Adding m4a and m4v MIME types (closed #42). 2011-10-28 15:24:31 +00:00
Ruslan Ermilov 48e5a840c4 Revamped "configure --help" text. 2011-10-26 13:18:33 +00:00
Igor Sysoev 85bd9c3bff Fix of building by Microsoft Visual C++ 10 compiler. 2011-10-26 08:16:59 +00:00
Igor Sysoev 255b55052d Decrease of log level of some SSL handshake errors. 2011-10-25 15:04:09 +00:00
Ruslan Ermilov d81aecd437 Fixed port range checking. 2011-10-25 13:48:43 +00:00
Ruslan Ermilov cccecee9c4 Fixed range checking for the "somaxconn" sysctl. 2011-10-25 13:48:05 +00:00
Igor Sysoev 21d8e3443c Support of several servers in the "resolver" directive.
Patch by Kirill A. Korinskiy.
2011-10-24 16:09:05 +00:00
Igor Sysoev e335487d34 Using of junk value in slab allocator similar to modern FreeBSD values. 2011-10-24 15:50:19 +00:00
Igor Sysoev cbf00c3223 malloc() debugging on MacOSX. 2011-10-24 15:46:48 +00:00
Igor Sysoev c8f532142f FreeBSD's MALLOC_OPTIONS must be set before any malloc() call.
The bug has been introduced in r3799.
2011-10-24 12:59:01 +00:00
Maxim Dounin 6b3aab136f Fixed another return in unix ngx_write_chain_to_file().
Previous patch missed special case for one iovec, it needs total bytes
written to be returned as well.
2011-10-21 11:04:46 +00:00
Maxim Dounin 1c5f1af3bd Fixed unix ngx_write_chain_to_file() to return total bytes written.
Previously result of last iteration's writev() was returned.  This was
unnoticed as return value was only used if chain contained only one or
two buffers.
2011-10-20 12:40:26 +00:00
Igor Sysoev 90b228b891 Fixing conflict with SDK off_t definition. 2011-10-20 07:12:45 +00:00
Igor Sysoev 0ae3a7cc9a Recent SDKs allow to build IPV6 only for Windows XP or above. 2011-10-20 07:00:04 +00:00
Maxim Dounin 42d7f26980 Fixed "expires @time" with unknown last modified time (ticket #32). 2011-10-17 17:32:08 +00:00
Maxim Dounin 040a8c9649 Fixed "expires @00h". 2011-10-17 17:30:18 +00:00
Igor Sysoev 6b0ba152f9 Removal of incomplete draft documentation processing. 2011-10-17 15:42:12 +00:00
Igor Sysoev d7b89da5bb Version bump. 2011-10-17 15:39:59 +00:00
Igor Sysoev b6fd551996 release-1.1.6 tag 2011-10-17 15:10:31 +00:00
Igor Sysoev 0d866c62d9 nginx-1.1.6-RELEASE 2011-10-17 15:10:23 +00:00
Igor Sysoev 7d9db607ad Moving RELEASE target in more safe place. 2011-10-17 15:09:34 +00:00
Maxim Dounin 20d87c6035 Added clearing of modules' contexts in ngx_http_named_location().
Patch by Yichun Zhang (agentzh).
2011-10-15 21:42:03 +00:00
Maxim Dounin c1308db7b2 Fixed utf8 decode (ticket #25).
Patch by Alexey Kuts.
2011-10-13 13:56:41 +00:00
Igor Sysoev 77ecc7fa14 Skipping location rewrite phase for server null location. 2011-10-13 12:43:22 +00:00
Maxim Dounin 0cbd517366 Better recheck of dead upstream servers.
Previously nginx used to mark backend again as live as soon as fail_timeout
passes (10s by default) since last failure.  On the other hand, detecting
dead backend takes up to 60s (proxy_connect_timeout) in typical situation
"backend is down and doesn't respond to any packets".  This resulted in
suboptimal behaviour in the above situation (up to 23% of requests were
directed to dead backend with default settings).

More detailed description of the problem may be found here (in Russian):
http://mailman.nginx.org/pipermail/nginx-ru/2011-August/042172.html

Fix is to only allow one request after fail_timeout passes, and
mark backend as "live" only if this request succeeds.

Note that with new code backend will not be marked "live" unless "check"
request is completed, and this may take a while in some specific workloads
(e.g. streaming).  This is believed to be acceptable.
2011-10-12 14:22:48 +00:00
Maxim Dounin c135f3d325 Clear old Location header (if any) while adding a new one.
This prevents incorrect behaviour when another redirect is issued within
error_page 302 handler.
2011-10-12 13:28:03 +00:00
Maxim Dounin 86955ecc8e Wording fix, "many data" is incorrect.
Noted by Piotr Sikora.
2011-10-12 13:24:59 +00:00
Ruslan Ermilov 8505259596 Fixed two minor bugs in "types" parsing code. 2011-10-12 09:36:21 +00:00
Ruslan Ermilov 76b38cbb6e Fixed grammar in a comment. 2011-10-12 09:34:53 +00:00
Ruslan Ermilov 9f37339314 Replaced magic constants representing default values of some directives
with appropriate #define's.
2011-10-12 09:33:43 +00:00
Ruslan Ermilov dde4df380d Stylistic change in checking the boolean expression. 2011-10-12 09:27:34 +00:00
Igor Sysoev 42477baeca Preallocating exact number of default MIME types entries. 2011-10-12 09:19:57 +00:00
Ruslan Ermilov 3d28a6e2fc Fixed configuration summary and manpage contents for the special
--error-log-path=stderr case.
2011-10-12 09:04:59 +00:00
Ruslan Ermilov 346252f283 Removed old warning that suggested to use "server_name_in_redirect off"
(now the default) in place of no longer supported "server_name *".
2011-10-12 07:20:20 +00:00
Maxim Dounin f0222130eb Additional headers for proxy/fastcgi/uwsgi/scgi_ignore_headers.
Now the following headers may be ignored as well: X-Accel-Limit-Rate,
X-Accel-Buffering, X-Accel-Charset.
2011-10-11 18:10:49 +00:00
Maxim Dounin 2780213915 Handling of Content-Encoding set from perl.
This fixes double gzipping in case of gzip filter being enabled while perl
returns already gzipped response.
2011-10-11 18:01:38 +00:00
Maxim Dounin d94c192db8 Fix for socket leak with "aio sendfile" and "limit_rate".
Second aio post happened when timer set by limit_rate expired while we have
aio request in flight, resulting in "second aio post" alert and socket leak.

The patch adds actual protection from aio calls with r->aio already set to
aio sendfile code in ngx_http_copy_filter().  This should fix other cases
as well, e.g. when sending buffered to disk upstream replies while still
talking to upstream.

The ngx_http_writer() is also fixed to handle the above case (though it's
mostly optimization now).

Reported by Oleksandr V. Typlyns'kyi.
2011-10-11 18:00:23 +00:00
Maxim Dounin b1a821099e Fix for connection drops with AIO.
Connections serving content with AIO to fast clients were dropped with
"client timed out" messages after send_timeout from response start.
2011-10-11 17:58:51 +00:00
Maxim Dounin 8eb18141de Autoindex: escape html in file names. 2011-10-11 17:57:41 +00:00
Maxim Dounin 103eeafae7 Autoindex: escape '?' in file names.
For files with '?' in their names autoindex generated links with '?' not
escaped.  This resulted in effectively truncated links as '?' indicates
query string start.

This is an updated version of the patch originally posted at [1].  It
introduces generic NGX_ESCAPE_URI_COMPONENT which escapes everything but
unreserved characters as per RFC 3986.  This approach also renders unneeded
special colon processing (as colon is percent-encoded now), it's dropped
accordingly.

[1] http://nginx.org/pipermail/nginx-devel/2010-February/000112.html

Reported by Konstantin Leonov.
2011-10-11 17:56:51 +00:00
Maxim Dounin 3a547a0e7e Improved access log escaping to better protect other software.
Some character sets (notably ISO-8859-1) have C1 control characters in
upper half, make sure to escape them.

Reported by Jesus Olmos Gonzalez.
2011-10-11 17:54:38 +00:00
Igor Sysoev b62324ec42 Fixing directive name in error message if types hash size is not enough. 2011-10-11 11:11:44 +00:00
Igor Sysoev d7107f233e Fixing mp4 module seeking on 32-bit platforms. 2011-10-11 10:12:44 +00:00
Ruslan Ermilov 3a5315c3ed Fixed macro name. 2011-10-10 08:38:28 +00:00
Ruslan Ermilov f6d26b14d0 The reference documentation is moving elsewhere. 2011-10-09 06:49:54 +00:00
Igor Sysoev ddcd00c88e Releasing memory of idle SSL connection. This saves about 34K per SSL
connection. The SSL_MODE_RELEASE_BUFFERS option is available since
OpenSSL 1.0.0d.
2011-10-07 12:15:20 +00:00
Igor Sysoev c90353c609 Disabling SSL compression. This saves about 300K per SSL connection.
The SSL_OP_NO_COMPRESSION option is available since OpenSSL 1.0.0.
2011-10-07 10:59:02 +00:00
Igor Sysoev cdb9a69b27 Version bump. 2011-10-07 10:41:13 +00:00
Ruslan Ermilov ec9d45d808 Improved ngx_parse_time() code readability. 2011-10-07 08:03:16 +00:00
Ruslan Ermilov 90afecc2bd Tweaked error messages. 2011-10-07 07:57:24 +00:00
Igor Sysoev 45c782872d Adding repository path missed in r4179. 2011-10-06 13:09:00 +00:00
Igor Sysoev b05a0d6d82 release-1.1.5 tag 2011-10-05 14:46:09 +00:00
Igor Sysoev 0253ff4992 nginx-1.1.5-RELEASE 2011-10-05 14:44:11 +00:00
Igor Sysoev 27ec2fb5e1 Adding RELEASE procedure in GNUmakefile. 2011-10-05 13:24:32 +00:00
Igor Sysoev 84e7d7c3b2 Version bump. 2011-10-05 13:13:25 +00:00
Maxim Dounin e5afd29e03 Fixed cache bypass caching of non-cacheable replies (ticket #21).
If cache was bypassed with proxy_cache_bypass, cache-controlling headers
(Cache-Control, Expires) wasn't considered and response was cached even
if it was actually non-cacheable.

Patch by John Ferlito.
2011-10-05 10:14:21 +00:00
Maxim Dounin 9273350a55 Added uwsgi_buffering and scgi_buffering directives.
Patch by Peter Smit.
2011-09-30 11:53:27 +00:00
Igor Sysoev b197f71f17 Using strtod() instead of atofp() to support a lot of digits after dot in
"start" parameter value.
2011-09-30 09:18:28 +00:00
Igor Sysoev 31f8ecc4db Fix of building on platforms with 32-bit off_t. (closed #23) 2011-09-29 15:19:36 +00:00
Maxim Dounin 70b6a7c830 Fixed segmentation fault with empty config on Windows.
See here for report:
http://mailman.nginx.org/pipermail/nginx-ru/2011-September/043288.html
2011-09-27 12:07:09 +00:00
Maxim Dounin 9a87e3af39 Fix for "ssl_session_cache builtin" (broken since 1.1.1, r3993). 2011-09-27 12:06:07 +00:00
Maxim Dounin 2b20643338 Better handling of late upstream creation.
Configuration with duplicate upstream blocks defined after first use, i.e.
like

    server {
        ...
        location / {
            proxy_pass http://backend;
        }
    }

    upstream backend { ... }
    upstream backend { ... }

now correctly results in "duplicate upstream" error.

Additionally, upstream blocks defined after first use now handle various
server directive parameters ("weight", "max_fails", etc.).  Previously
configuration like

    server {
        ...
        location / {
            proxy_pass http://backend;
        }
    }

    upstream backend {
        server 127.0.0.1 max_fails=5;
    }

incorrectly resulted in "invalid parameter "max_fails=5"" error.
2011-09-27 11:18:51 +00:00
Maxim Dounin a9ce95d4eb Cache: fix for sending of stale responses.
For normal cached responses ngx_http_cache_send() sends last buffer and then
request finalized via ngx_http_finalize_request() call, i.e. everything is
ok.

But for stale responses (i.e. when upstream died, but we have something in
cache) the same ngx_http_cache_send() sends last buffer, but then in
ngx_http_upstream_finalize_request() another last buffer is send.  This
causes duplicate final chunk to appear if chunked encoding is used (and
resulting problems with keepalive connections and so on).

Fix this by not sending in ngx_http_upstream_finalize_request()
another last buffer if we know response was from cache.
2011-09-27 11:17:11 +00:00
Maxim Dounin 33e55dc35f Cache: fix for sending of empty responses.
Revert wrong fix for empty responses introduced in 0.8.31 and apply new one,
rewritten to match things done by static module as close as possible.
2011-09-27 11:15:35 +00:00
Maxim Dounin 11129a676b Incorrect special case for "return 204" removed.
The special case in question leads to replies without body in
configuration like

    location / { error_page 404 /zero; return 404; }
    location /zero { return 204; }

while replies with empty body are expected per protocol specs.

Correct one will look like

    if (status == NGX_HTTP_NO_CONTENT) {

        rc = ngx_http_send_header(r);

        if (rc == NGX_ERROR || r->header_only) {
            return rc;
        }

        return ngx_http_send_special(r, NGX_HTTP_LAST);
    }

though it looks like it's better to drop this special case at all.
2011-09-27 11:14:02 +00:00
Maxim Dounin 7a5a17bc76 Fix for "return 202" not discarding body.
Big POST (not fully preread) to a

    location / {
        return 202;
    }

resulted in incorrect behaviour due to "return" code path not calling
ngx_http_discard_request_body().  The same applies to all "return" used
with 2xx/3xx codes except 201 and 204, and to all "return ... text" uses.

Fix is to add ngx_http_discard_request_body() call to ngx_http_send_response()
function where it looks appropriate.  Discard body call from emtpy gif module
removed as it's now redundant.

Reported by Pyry Hakulinen, see
http://mailman.nginx.org/pipermail/nginx/2011-August/028503.html
2011-09-27 11:13:00 +00:00
Maxim Dounin 723e834e74 Fix for double content when return is used in error_page handler.
Test case:

   location / {
       error_page 405 /nope;
       return 405;
   }

   location /nope {
       return 200;
   }

This is expected to return 405 with empty body, but in 0.8.42+ will return
builtin 405 error page as well (though not counted in Content-Length, thus
breaking protocol).

Fix is to use status provided by rewrite script execution in case
it's less than NGX_HTTP_BAD_REQUEST even if r->error_status set.  This
check is in line with one in ngx_http_script_return_code().

Note that this patch also changes behaviour for "return 302 ..." and
"rewrite ... redirect" used as error handler.  E.g.

    location / {
        error_page 405 /redirect;
        return 405;
    }

    location /redirect {
        rewrite ^ http://example.com/;
    }

will actually return redirect to "http://example.com/" instead of builtin 405
error page with meaningless Location header.  This looks like correct change
and it's in line with what happens on e.g. directory redirects in error
handlers.
2011-09-27 11:11:30 +00:00
Maxim Dounin 4877b5db37 Fix for incorrect 201 replies from dav module.
Replies with 201 code contain body, and we should clearly indicate it's
empty if it's empty.  Before 0.8.32 chunked was explicitly disabled for
201 replies and as a result empty body was indicated by connection close
(not perfect, but worked).  Since 0.8.32 chunked is enabled, and this
causes incorrect responses from dav module when HTTP/1.1 is used: with
"Transfer-Encoding: chunked" but no chunks at all.

Fix is to actually return empty body in special response handler instead
of abusing r->header_only flag.

See here for initial report:
http://mailman.nginx.org/pipermail/nginx-ru/2010-October/037535.html
2011-09-27 11:09:55 +00:00
Maxim Dounin caf9367fa3 Proxy: logging levels tuned, double logging fixed. 2011-09-25 20:04:20 +00:00
Maxim Dounin df43a6668c Proxy: whitespaces after chunk size allowed.
Whitespaces after chunk size seems to be be allowed by the "implied *LWS" rule
and emitted by some servers.
2011-09-25 20:03:27 +00:00
Maxim Dounin 281a08df08 Upstream: clearing of u->peer.connection on close.
This fixes crashes observed with some 3rd party balancer modules.  Standard
balancer modules (round-robin and ip hash) explicitly set pc->connection
(aka u->peer.connection) to NULL and aren't affected.
2011-09-25 20:00:36 +00:00
Ruslan Ermilov ba8897ccd0 Fixed error message. 2011-09-23 20:15:27 +00:00
Ruslan Ermilov 4032430310 Fixed markup. 2011-09-20 13:15:41 +00:00
Igor Sysoev b68ef288ad release-1.1.4 tag 2011-09-20 11:18:32 +00:00
Igor Sysoev c9825dd4b2 nginx-1.1.4-RELEASE 2011-09-20 11:18:24 +00:00
Maxim Dounin 38c1509782 Fix of separate pool for upstream connections (r4117).
Pool may not be created if connection was created but rejected in connect()
call.  Make sure to check if it is here before trying to destroy it.
2011-09-20 10:00:46 +00:00
Maxim Dounin 6a882e22a5 Fixed loss of chain links in ngx_event_pipe_read_upstream(). 2011-09-20 09:56:35 +00:00
Maxim Dounin 76b238fdc6 Fixed loss of chain links in fastcgi module. 2011-09-20 09:56:05 +00:00
Maxim Dounin d140fa50d0 Fix of cpu hog in event pipe.
If client closed connection in ngx_event_pipe_write_to_downstream(), buffers
in the "out" chain were lost.  This caused cpu hog if all available buffers
were in the "out" chain.  Fix is to call ngx_chain_update_chains() before
checking return code of output filter to avoid loosing buffers in the "out"
chain.

Note that this situation (all available buffers in the "out" chain) isn't
normal, it should be prevented by busy buffers limit.  Though right now it
may happen with complex protocols like fastcgi.  This should be addressed
separately.
2011-09-20 09:55:27 +00:00
Igor Sysoev cfd9a4c8b9 The "worker_aio_requests" directive.
The default value is 32 AIO simultaneous requests per worker. Previously
they were hardcoded to 1024, and it was too large, since Linux allocated
them early on io_setup(), but not on request itself. So with default value
of /proc/sys/fs/aio-max-nr equal to 65536 only 64 worker processes could
be run simultaneously. 32 AIO requests are enough for modern disks even if
server runs only 1 worker.
2011-09-20 07:30:09 +00:00
Ruslan Ermilov 0826f5639c Replaced "can not" with "cannot" and "could not" in a bunch of places.
Fixed nearby grammar errors.
2011-09-19 14:48:29 +00:00
Ruslan Ermilov d428332417 Cosmetics: replaced NGX_CONF_TAKE1 to NGX_CONF_FLAG for "sendfile"
and "chunked_transfer_encoding" directives, to be in line with all
directives taking a boolean argument.  Both flags will ensure that
a directive takes one argument.
2011-09-19 12:41:13 +00:00
Ruslan Ermilov 10a08b0ac7 Overhauled diagnostic messages. 2011-09-19 12:37:22 +00:00
Igor Sysoev f06fad3dae Fixing Linux AIO initiatialization: AIO operations are disabled if kernel
does not support them.  Previously worker just exited.
2011-09-16 13:41:52 +00:00
Igor Sysoev eae52dffe3 Fixing Linux AIO syscalls return value handling:
syscall(2) uses usual libc convention, it returns -1 on error and
sets errno. Obsolete _syscall(2) returns negative value of error.

Thanks to Hagai Avrahami.
2011-09-16 12:43:16 +00:00
Maxim Dounin 060e07cd79 Trailing space fix. 2011-09-16 12:08:52 +00:00
Maxim Dounin 01923d7828 Upstream keepalive module. 2011-09-15 19:28:18 +00:00
Maxim Dounin ec56a2df55 Proxy: basic HTTP/1.1 support (including keepalive).
By default we still send requests using HTTP/1.0.  This may be changed with
new proxy_http_version directive.
2011-09-15 19:23:20 +00:00
Maxim Dounin 23ffe41e56 Protocol version parsing in ngx_http_parse_status_line().
Once we know protocol version, set u->headers_in.connection_close to indicate
implicitly assumed connection close with HTTP before 1.1.
2011-09-15 19:22:35 +00:00
Maxim Dounin ecaa05db17 Upstream: Connection header processing. 2011-09-15 19:21:19 +00:00
Maxim Dounin 65b99d7de5 Upstream: Transfer-Encoding header processing. 2011-09-15 19:20:08 +00:00
Maxim Dounin c2b6b4a1fd Keepalive support in fastcgi.
By default follow the old behaviour, i.e. FASTCGI_KEEP_CONN flag isn't set
in request and application is responsible for closing connection once request
is done.  To keep connections alive fastcgi_keep_conn must be activated.
2011-09-15 19:05:23 +00:00
Maxim Dounin e164ce5c21 Keepalive support in memcached. 2011-09-15 19:04:25 +00:00
Maxim Dounin d9ebf8f430 Upstream: keepalive flag.
This patch introduces r->upstream->keepalive flag, which is set by protocol
handlers if connection to upstream is in good state and can be kept alive.
2011-09-15 19:03:15 +00:00
Maxim Dounin bdc085c52d Upstream: pipe length and input_filter_init in buffered mode.
As long as ngx_event_pipe() has more data read from upstream than specified
in p->length it's passed to input filter even if buffer isn't yet full.  This
allows to process data with known length without relying on connection close
to signal data end.

By default p->length is set to -1 in upstream module, i.e. end of data is
indicated by connection close.  To set it from per-protocol handlers upstream
input_filter_init() now called in buffered mode (as well as in
unbuffered mode).
2011-09-15 19:00:47 +00:00
Maxim Dounin e595f17abf Upstream: r->upstream->length type change to off_t.
Previous use of size_t may cause wierd effects on 32bit platforms with certain
big responses transferred in unbuffered mode.

Nuke "if (size > u->length)" check as it's not usefull anyway (preread
body data isn't subject to this check) and now requires additional check
for u->length being positive.
2011-09-15 18:43:19 +00:00
Maxim Dounin 80867ca67e Upstream: content_length_n API change.
We no longer use r->headers_out.content_length_n as a primary source of
backend's response length.  Instead we parse response length to
u->headers_in.content_length_n and copy to r->headers_out.content_length_n
when needed.
2011-09-15 18:33:43 +00:00
Maxim Dounin 2391d8641f Upstream: separate pool for peer connections.
This is required to support persistent https connections as various ssl
structures are allocated from connection's pool.
2011-09-15 18:21:24 +00:00
Maxim Dounin a6f1951c80 Workaround for cpu hog on errors with cached connections.
Just doing another connect isn't safe as peer.get() may expect peer.tries
to be strictly positive (this is the case e.g. with round robin with multiple
upstream servers).  Increment peer.tries to at least avoid cpu hog in
round robin balancer (with the patch alert will be seen instead).

This is not enough to fully address the problem though, hence TODO.  We
should be able to inform balancer that the error wasn't considered fatal
and it may make sense to retry the same peer.
2011-09-15 18:12:58 +00:00
Maxim Dounin ed448edfe1 API change: ngx_chain_update_chains() now requires pool.
The ngx_chain_update_chains() needs pool to free chain links used for buffers
with non-matching tags.  Providing one helps to reduce memory consumption
for long-lived requests.
2011-09-15 16:03:17 +00:00
Maxim Dounin 79e4313fff Buffers reuse in chunked filter.
There were 2 buffers allocated on each buffer chain sent through chunked
filter (one buffer for chunk size, another one for trailing CRLF, about
120 bytes in total on 32-bit platforms).  This resulted in large memory
consumption with long-lived requests sending many buffer chains.  Usual
example of problematic scenario is streaming though proxy with
proxy_buffering set to off.

Introduced buffers reuse reduces memory consumption in the above problematic
scenario.

See here for initial report:
http://mailman.nginx.org/pipermail/nginx/2010-April/019814.html
2011-09-15 15:25:42 +00:00
Igor Sysoev b80c69129d MP4 co64 atom support added. 2011-09-15 13:23:03 +00:00
Ruslan Ermilov f10c099442 Regenerated after previous commit. 2011-09-15 08:59:38 +00:00
Ruslan Ermilov a9e3ec2aed Added ngx_http_mp4_module documentation. 2011-09-15 08:59:13 +00:00
Ruslan Ermilov 24bf44a5bf Regenerated after previous commit. 2011-09-15 08:33:25 +00:00
Ruslan Ermilov 00ce0d0eb4 - The module name is now also output as an HTML header.
- Agreed that examples can only contain literal text.
- Agreed to call modules "ngx_*_module".
- Renamed XML element "http-error" to a more general "http-status".
- Fixed text of error codes to match the actual code.
2011-09-15 08:24:33 +00:00
Igor Sysoev 75cd8ce36c Fix of struct field name. 2011-09-15 05:15:16 +00:00
Igor Sysoev 56d96359d3 Style fix. 2011-09-14 15:26:11 +00:00
Igor Sysoev 8c973b170c Fixing building by gcc-4.7. 2011-09-14 15:25:46 +00:00
Igor Sysoev 405ff38ea9 Version bump. 2011-09-14 15:20:01 +00:00
Igor Sysoev 6a3154cbc6 release-1.1.3 tag 2011-09-14 15:00:51 +00:00
Igor Sysoev a48b67b447 nginx-1.1.3-RELEASE 2011-09-14 15:00:43 +00:00
Igor Sysoev d417024396 Fix of the previous commit: is_directio flag processing introduced in r4077
is still worthwhile.
2011-09-14 14:28:55 +00:00
Igor Sysoev 62b2cc5588 Bugfix: open_file_cache did not update file info on retest.
If file inode was not changed, cached file information was not updated
on retest.  As a result stale information might be cached forever if file
attributes was changed and/or file was extended.

This fix also makes obsolete r4077 change of is_directio flag handling,
since this flag is updated together with other file information.
2011-09-14 14:12:35 +00:00
Igor Sysoev ab450b390f Skipping traks with unsupported media formats. 2011-09-14 14:04:41 +00:00
Igor Sysoev 9bba34c064 Fix of case when start sample does not reside on chunk boundary. 2011-09-14 05:16:20 +00:00
Ruslan Ermilov 3f8c948364 In Mac OS X Lion, Apple deprecated the use of the system OpenSSL library
in favour of their CommonCrypto library.  This change adds a work-around
that allows nginx to still be built on Lion with OpenSSL.
2011-09-13 09:18:43 +00:00
Igor Sysoev 3cb11d071a Fix of debug message format. 2011-09-12 15:15:00 +00:00
Igor Sysoev 1e5c454a24 Fix of codec debug message. 2011-09-12 14:54:28 +00:00
Igor Sysoev 48f10c8e28 Fix of error message. 2011-09-12 14:46:06 +00:00
Igor Sysoev 1c836ecc0e Fix of error message. 2011-09-12 13:06:22 +00:00
Ruslan Ermilov 71165c6392 Regenerate after previous commits. 2011-09-12 09:50:33 +00:00
Ruslan Ermilov 2e56ed485b - The "example" element can now contain sub-elements.
- Added entities for Unicode quotes.
2011-09-12 09:49:56 +00:00
Ruslan Ermilov d627a9d08a HTTP errors are now output as "code (text)". 2011-09-12 09:48:33 +00:00
Igor Sysoev 72a0e6b2ff mp4_max_moov_size directive has been renamed to mp4_max_buffer_size. 2011-09-12 09:38:04 +00:00
Igor Sysoev c9eff09c04 bugfix of r4086: nginx could not be built without debug log. 2011-09-09 11:56:49 +00:00
Igor Sysoev 3049d5b079 Bugfix of r4086: directio was always enabled if mp4 file was sent as is. 2011-09-09 11:13:55 +00:00
Igor Sysoev e6828627d7 "video/mp4" mime type added. 2011-09-09 10:25:43 +00:00
Igor Sysoev 97b9bde764 ngx_http_mp4_module 2011-09-09 10:22:34 +00:00
Ruslan Ermilov 78af402ae5 Regenerate after previous commits. 2011-09-08 13:28:25 +00:00
Ruslan Ermilov ed6bc906fe Cleaned up links. 2011-09-08 13:27:18 +00:00
Ruslan Ermilov e22b65d209 Regenerate after previous commit. 2011-09-08 13:26:37 +00:00
Ruslan Ermilov 0db92e7d5a Basic inter-document and external linking support. 2011-09-08 13:26:06 +00:00
Ruslan Ermilov 134f6e5f0a Regenerate after previous commit. 2011-09-06 13:43:04 +00:00
Ruslan Ermilov cf38eb8e59 Finished initial translation of the Core and HTTP Core modules. 2011-09-06 13:42:40 +00:00
Ruslan Ermilov 0f08a4f1bc Regenerate after previous commit. 2011-09-06 10:42:17 +00:00
Ruslan Ermilov c9e169e0d6 New elements: "dq", "pathname"; new list type: "tag". 2011-09-06 10:41:44 +00:00
Maxim Dounin e725734d23 Bugfix: open_file_cache lost is_directio flag.
On file retest open_file_cache lost is_directio if file wasn't changed.
This caused unaligned operations under Linux to fail with EINVAL.
It wasn't noticeable with AIO though, as errors wasn't properly logged.
2011-09-05 16:36:19 +00:00
Igor Sysoev cc810027b8 Version bump. 2011-09-05 16:26:51 +00:00
Igor Sysoev 30a73a9b3b release-1.1.2 tag 2011-09-05 13:14:34 +00:00
Igor Sysoev 2242c127e4 nginx-1.1.2-RELEASE 2011-09-05 13:14:27 +00:00
Maxim Dounin 9b09a660d2 Bugfix: read event was not blocked after reading body.
Read event should be blocked after reading body, else undefined behaviour
might occur on additional client activity.  This fixes segmentation faults
observed with proxy_ignore_client_abort set.
2011-09-05 12:43:31 +00:00
Ruslan Ermilov 23443b6c16 Regenerate after previous commit. 2011-09-05 09:58:31 +00:00
Ruslan Ermilov 96bcf5255f Translate "types" and "underscores_in_headers" directives. 2011-09-05 09:58:00 +00:00
Ruslan Ermilov a833f47c06 Regenerate HTML for the previous revision. 2011-09-05 09:40:50 +00:00
Ruslan Ermilov 9c1d3e7188 Initial English translation of Core and HTTP Core modules. 2011-09-05 09:39:24 +00:00
Ruslan Ermilov f397eb62a4 XSLT regeneration for the previous commit. 2011-09-05 09:33:54 +00:00
Ruslan Ermilov 4ef437eb26 DTD and XSLS changes for modules. 2011-09-05 09:32:00 +00:00
Maxim Dounin ecfe0113d6 Proper setting of read->eof in pipe code.
Setting read->eof to 0 seems to be just a typo.  It appeared in
nginx-0.0.1-2003-10-28-18:45:41 import (r164), while identical code in
ngx_recv.c introduced in the same import do actually set read->eof to 1.

Failure to set read->eof to 1 results in EOF not being generally detectable
from connection flags.  On the other hand, kqueue won't report any read
events on such a connection since we use EV_CLEAR.  This resulted in read
timeouts if such connection was cached and used for another request.
2011-09-01 15:10:41 +00:00
Maxim Dounin 253721c4b0 Proper SSL shutdown handling.
If connection has unsent alerts, SSL_shutdown() tries to send them even
if SSL_set_shutdown(SSL_RECEIVED_SHUTDOWN|SSL_SENT_SHUTDOWN) was used.
This can be prevented by SSL_set_quiet_shutdown().  SSL_set_shutdown()
is required nevertheless to preserve session.
2011-09-01 13:49:36 +00:00
Igor Sysoev ebc3990334 Now if client requests more ranges than "max_ranges" permits,
nginx disables ranges and returns just the source response.
2011-09-01 13:03:55 +00:00
Igor Sysoev 990a7d7fa5 The "max_ranges" directive.
"max_ranges 0" disables ranges support at all,
"max_ranges 1" allows the single range, etc.
By default number of ranges is unlimited, to be precise, 2^31-1.
2011-08-31 09:40:55 +00:00
Igor Sysoev b8c461aa54 Style fix: removal of tabs introduced in the previous commit. 2011-08-31 09:26:07 +00:00
Igor Sysoev 4476ee96c8 *) fix of r4060: start value should be tested after the "found" label;
*) optimization: start value may be tested against end value only,
   since end value here may not be greater than content_length.
2011-08-30 20:34:58 +00:00
Igor Sysoev 5726f0d357 Unsatisfiable range with start value greater than content length
was not properly skipped. The bug has been introduced in r4057.
2011-08-30 14:25:35 +00:00
Igor Sysoev 060297520c ngx_http_range_parse() should be static. 2011-08-30 13:07:33 +00:00
Igor Sysoev 95d4ca17b8 Ranges processing small optimization. 2011-08-30 13:06:12 +00:00
Igor Sysoev 559cd34ba9 Now unsatisfiable ranges are processed according to RFC 2616. 2011-08-30 13:01:55 +00:00
Igor Sysoev 2fb9408b38 Ranges processing small optimization. 2011-08-30 12:45:24 +00:00
Igor Sysoev 8b30429bd1 Style fix. 2011-08-30 12:28:01 +00:00
Igor Sysoev cbbf90d9b8 Now if total size of all ranges is greater than source response size,
then nginx disables ranges and returns just the source response.
This fix should not affect well-behaving applications but will defeat
DoS attempts exploiting malicious byte ranges.
2011-08-26 09:42:50 +00:00
Igor Sysoev d7c1fe5f5b Cache size accounting fix: actual cache size on disk was less than
needed by sum of sizes of files loaded by worker processes themselves
while cache loader was running.

The bug has been introduced in r3900.
2011-08-25 17:29:34 +00:00
Maxim Dounin 8f54c88bdd Better handling of various per-server ssl options with SNI.
SSL_set_SSL_CTX() doesn't touch values cached within ssl connection
structure, it only changes certificates (at least as of now, OpenSSL
1.0.0d and earlier).

As a result settings like ssl_verify_client, ssl_verify_depth,
ssl_prefer_server_ciphers are only configurable on per-socket basis while
with SNI it should be possible to specify them different for two servers
listening on the same socket.

Workaround is to explicitly re-apply settings we care about from context
to ssl connection in servername callback.

Note that SSL_clear_options() is only available in OpenSSL 0.9.8m+.  I.e.
with older versions it is not possible to clear ssl_prefer_server_ciphers
option if it's set in default server for a socket.
2011-08-23 14:36:31 +00:00
Igor Sysoev cb0498da6c Version bump. 2011-08-23 14:22:34 +00:00
Ruslan Ermilov 6db2ed0cfb Restore the lost negation. 2011-08-23 13:39:22 +00:00
Igor Sysoev 5b129859e5 Removing incomplete draft documentation from release tarball and zip. 2011-08-23 13:35:02 +00:00
Igor Sysoev 6afda56a48 Grammar fixes in CHANGES. 2011-08-23 13:29:47 +00:00
Igor Sysoev 69954e741c CHANGES conversion from KOI8-R to UTF-8. 2011-08-23 12:50:54 +00:00
Igor Sysoev 0bc89850bb Grammar fixes in CHANGES. 2011-08-23 10:18:35 +00:00
Igor Sysoev 6a904d417f XSLT regeneration for the previous commit. 2011-08-23 10:11:09 +00:00
Igor Sysoev 0a4c8438b6 Traling spaces removal in text CHANGES files. 2011-08-23 10:10:25 +00:00
Igor Sysoev b587ba834c XSLT regeneration for r4023. 2011-08-23 09:48:44 +00:00
Ruslan Ermilov 1b075335d6 Get rid of " <br/>" hacks. 2011-08-23 09:01:13 +00:00
Ruslan Ermilov 1636327379 - support <br/> in the middle of input
- fixed "<br>" lookup (eliminates the need in " <br/>" hacks)
- fixed maximum length for unbreakable input
- fixed space lookup (allows a space at column 77 to break a line)
2011-08-23 09:00:24 +00:00
Igor Sysoev 3fbcbcda80 release-1.1.1 tag 2011-08-22 13:56:14 +00:00
Igor Sysoev 8ee9429c07 nginx-1.1.1-RELEASE 2011-08-22 13:56:08 +00:00
Igor Sysoev c68fd722ae SIGWINCH/NOACCEPT signal is disabled now in non-daemon mode.
Non-daemon mode is currently used by supervisord, daemontools and so on
or during debugging. The NOACCEPT signal is only used for online upgrade
which is not supported when nginx is run under supervisord, etc.,
so this change should not break existant setups.
2011-08-22 12:34:48 +00:00
Igor Sysoev 38f69601e9 The change in adaptive loader behaviour introduced in r3975:
now cache loader processes either as many files as specified by loader_files
or works no more than time specified by loader_threshold during each iteration.

loader_threshold was previously used to decrease loader_files or
to increase loader_timeout and this might eventually result in
downgrading loader_files to 1 and increasing loader_timeout to large values
causing loading cache for forever.
2011-08-22 10:16:49 +00:00
Maxim Dounin 3bbcc2c24d Fix buffer overrun under Windows. 2011-08-22 10:07:27 +00:00
Maxim Dounin d8829c8f29 Move SO_ACCEPTFILTER and TCP_DEFER_ACCEPT checks into configure.
NetBSD 5.0+ has SO_ACCEPTFILTER support merged from FreeBSD, and having
accept filter check in FreeBSD-specific ngx_freebsd_config.h prevents it
from being used on NetBSD.  Therefore move the check into configure (and
do the same for Linux-specific TCP_DEFER_ACCEPT, just to be in line).
2011-08-21 11:37:37 +00:00
Maxim Dounin 8a3f0cdbe7 Fix ignored headers handling in fastcgi/scgi/uwsgi.
The bug had appeared in r3561 (fastcgi), r3638 (scgi), r3567 (uwsgi).
2011-08-19 20:11:39 +00:00
Ruslan Ermilov 75639f81d9 XSLT regeneration for r3998. 2011-08-19 08:39:27 +00:00
Ruslan Ermilov 6af6d60ce8 - Added missing dependencies for the CHANGES{,ru} targets.
- Pass string params to xsltproc.
- Removed extraneous rule bodies.
2011-08-19 08:33:47 +00:00
Maxim Dounin 0e8a6088fc Complain on invalid log levels.
Previously only first log level was required to be correct, while error_log
directive in fact accepts list of levels (e.g. one may specify "error_log ...
debug_core debug_http;").  This resulted in (avoidable) wierd behaviour on
missing semicolon after error_log directive, e.g.

    error_log /path/to/log info
    index index.php;

silently skipped index directive and it's arguments (trying to interpret
them as log levels without checking to be correct).
2011-08-18 21:48:13 +00:00
Maxim Dounin fe81a004a4 Upstream: properly allocate memory for tried flags.
Previous allocation only took into account number of non-backup servers, and
this caused memory corruption with many backup servers.

See report here:
http://mailman.nginx.org/pipermail/nginx/2011-May/026531.html
2011-08-18 17:04:52 +00:00
Maxim Dounin 3edafa1da6 Fixing cpu hog with all upstream servers marked "down".
The following configuration causes nginx to hog cpu due to infinite loop
in ngx_http_upstream_get_peer():

    upstream backend {
        server 127.0.0.1:8080 down;
        server 127.0.0.1:8080 down;
    }

    server {
       ...
       location / {
           proxy_pass http://backend;
       }
    }

Make sure we don't loop infinitely in ngx_http_upstream_get_peer() but stop
after resetting peer weights once.

Return 0 if we are stuck.  This is guaranteed to work as peer 0 always exists,
and eventually ngx_http_upstream_get_round_robin_peer() will do the right
thing falling back to backup servers or returning NGX_BUSY.
2011-08-18 16:52:38 +00:00
Maxim Dounin 4d7a28e8ce Fixing proxy_set_body and proxy_pass_request_body with SSL.
Flush flag wasn't set in constructed buffer and this prevented any data
from being actually sent to upstream due to SSL buffering.  Make sure
we always set flush in the last buffer we are going to sent.

See here for report:
http://nginx.org/pipermail/nginx-ru/2011-June/041552.html
2011-08-18 16:34:24 +00:00
Igor Sysoev 76de74e303 Fix names of the referer hash size directives introduced in r3940. 2011-08-18 16:27:30 +00:00
Maxim Dounin a9983c9d98 Rebuild manpage only if needed. 2011-08-18 15:57:59 +00:00
Maxim Dounin 13ce1f0bca Fix body with request_body_in_single_buf.
If there were preread data and request body was big enough first part
of the request body was duplicated.

See report here:
http://mailman.nginx.org/pipermail/nginx/2011-July/027756.html
2011-08-18 15:52:00 +00:00
Maxim Dounin cbf91014ed Correctly set body if it's preread and there are extra data.
Previously all available data was used as body, resulting in garbage after
real body e.g. in case of pipelined requests.  Make sure to use only as many
bytes as request's Content-Length specifies.
2011-08-18 15:27:57 +00:00
Maxim Dounin d8a0ae2edb Lower optimization level for Sun Studio before 12.1.
At least Sun Studio 12 has problems with bit-fields exposed by nginx code
(caught by test suite).  They seems to be fixed in Sun Studio 12.1.  As a
workaround use "-fast -xalias_level=any" for older versions, it resolves
the problem.
2011-08-18 15:10:23 +00:00
Maxim Dounin a5c11a1449 Detect POSIX semaphores in librt on Solaris (ticket #3).
Patch by Denis Ivanov.
2011-08-17 08:35:54 +00:00
Maxim Dounin c122b33c8c Configure: catch up with new Linux version numbering (ticket #5).
Catch up with new Linux version numbering scheme as announced at [1] and
suppress unrecognized versions to actually use default 0.

[1] https://lkml.org/lkml/2011/5/29/204
2011-08-13 15:15:50 +00:00
Ruslan Ermilov 77013cc642 - Replaced explicit link to bugtracker with a support link
(which will soon link to Trac).

- Commented out reference to non-existing nginx.conf(5).
2011-08-10 12:30:19 +00:00
Ruslan Ermilov e805d2dfe9 Mention our preferred way of accepting bug reports. 2011-08-10 08:03:34 +00:00
Ruslan Ermilov 3d182f0ee5 Don't ignore xmllint errors. 2011-08-09 15:18:07 +00:00
Ruslan Ermilov 279e434a03 Regen after makefile changes. 2011-08-09 15:15:36 +00:00
Igor Sysoev 08c06ac475 using sed instead of perl 2011-08-05 13:42:37 +00:00
Igor Sysoev 38dd8df531 skeleton for documentation processing 2011-08-05 09:25:34 +00:00
Igor Sysoev b4696fb265 update documentation build procedure 2011-08-05 09:00:19 +00:00
Igor Sysoev fded0a4ad0 fix gzip quantity: "q=0." and "q=1." are valid values according to RFC 2011-08-05 08:51:29 +00:00
Igor Sysoev 3aec2da367 refactor gzip quantity introduced in r3981: it ignored "q=1.000" 2011-08-04 14:50:59 +00:00
Igor Sysoev 12bbdf5d86 A new fix for the case when ssl_session_cache defined, but ssl is not
enabled in any server. The previous r1033 does not help when unused zone
becomes used after reconfiguration, so it is backed out.

The initial thought was to make SSL modules independed from SSL implementation
and to keep OpenSSL code dependance as much as in separate files.
2011-08-04 11:12:30 +00:00
Igor Sysoev 388cd91b9b removal of error message about %name log_format parameters,
they have been deleted long ago in 0.5.0-RELEASE
2011-08-03 16:01:36 +00:00
Igor Sysoev 3159d39551 fix typo introduced in r3985 2011-08-02 12:43:01 +00:00
Igor Sysoev 70dc387541 bump version 2011-08-02 12:39:38 +00:00
Igor Sysoev a6768f4d09 release-1.1.0 tag 2011-08-01 14:47:46 +00:00
Igor Sysoev 38cc0ed695 nginx-1.1.0-RELEASE 2011-08-01 14:47:40 +00:00
Igor Sysoev d3a9feaa10 fix r3981 again for case "Accept-Encoding: gzip" 2011-08-01 14:38:09 +00:00
Igor Sysoev 823636ccfa always set timer in discard body handler, this fixes the cases
when request for static file is redirected by error_page to an SSI page

patch by Maxim Dounin
2011-08-01 13:52:54 +00:00
Igor Sysoev ed02960ae0 lingering_close "off|on|always"
patch by Maxim Dounin
2011-08-01 13:26:55 +00:00
Igor Sysoev b462160df5 do not send RST on normal lingering close read timeout,
if reset_timedout_connection is on

patch by Maxim Dounin
2011-08-01 13:08:03 +00:00
Igor Sysoev ac5194b27d fix r3981 for case "Accept-Encoding: gzip" 2011-08-01 11:21:46 +00:00
Igor Sysoev 3acb487e7a enable lingering close for pipelined requests
patch by Maxim Dounin
2011-08-01 11:08:57 +00:00
Igor Sysoev 8a618d7b78 Accept-Encoding refactoring: "gzip; q=0" support 2011-08-01 11:02:12 +00:00
Igor Sysoev 74b7224e64 Accept-Encoding refactoring: test first the most common case "gzip," 2011-07-30 07:34:12 +00:00
Igor Sysoev b51a8f84b8 Accept-Encoding refactoring: remove ancient MSIE 4.x test for gzip 2011-07-30 06:20:06 +00:00
Igor Sysoev bf7712e9c0 test length of proxy_pass with variables
patch by Lanshun Zhou
2011-07-30 06:11:46 +00:00
Igor Sysoev 270ae7c96a update r3945 with more descriptive error message 2011-07-29 15:33:03 +00:00
Igor Sysoev 99c2b31cf1 copy OpenSSL-1.0.0d LICENSE for nginx/Windows zip 2011-07-29 15:15:16 +00:00
Igor Sysoev 78121b835a loader_files, loader_sleep, and loader_threshold 2011-07-29 15:09:02 +00:00
Igor Sysoev aff99d61e2 set correct configuration file values while adding path
patch by Maxim Dounin
2011-07-25 10:22:38 +00:00
Igor Sysoev 51bebc3999 rename ngx_http_file_cache_manager_sleep() to ngx_http_file_cache_loader_sleep()
and do not use it all in cache manager: this is a vestige of the times when
cache manager loaded cache
2011-07-25 09:45:00 +00:00
Igor Sysoev fadd7a6f27 do not close connection if cache file is too small: replace it with valid one 2011-07-24 20:04:47 +00:00
Igor Sysoev 6ddf7392f4 elimination of reading cache files by cache loader 2011-07-24 19:46:53 +00:00
Igor Sysoev 8d616ae929 fix r3968 2011-07-24 19:43:52 +00:00
Igor Sysoev b99f788f44 update the previous commit:
removing dependencies on file uniq since WIN32_FIND_DATA has no such field
2011-07-24 17:36:26 +00:00
Igor Sysoev 7369918aad The cache loader performs two tasks: inserting cache objects in inactivity
list and evaluating total cache size. Reading just directory is enough for
this purpose. Elimination of reading cache files saves at least one disk I/O
operation per file.

Preparation for elimination of reading cache files by cache loader:
removing dependencies on the reading:
*) cache node valid_sec and valid_msec are used only for caching errors;
*) upstream buffer size can be used instead of cache node body_start.
2011-07-24 16:47:31 +00:00
Igor Sysoev 99e64f7855 fuse two if's in one condition 2011-07-24 16:10:06 +00:00
Igor Sysoev 936f7f61ba style fix 2011-07-24 16:06:24 +00:00
Igor Sysoev 44780efc2a do not try to reuse and save a SSL session for a peer created on the fly
by ngx_http_upstream_create_round_robin_peer(), since the peer lives
only during request so the saved SSL session will never be used again
and just causes memory leak

patch by Maxim Dounin
2011-07-22 16:30:17 +00:00
Igor Sysoev 11a9044a50 finalizing with rc == 0 in unbuffered proxy mode caused nginx to wait
for another send_timeout before actually closing client's connection
if client timed out while still talking to upstream server

patch by Maxim Dounin
2011-07-22 13:30:16 +00:00
Igor Sysoev 91888ffb08 fix SSL connection issues on platforms with 32-bit off_t
patch by Maxim Dounin
2011-07-22 12:53:04 +00:00
Igor Sysoev 43fe0ac347 fix build by gcc46 with -Wunused-value option
patch by Maxim Dounin
2011-07-22 10:43:50 +00:00
Igor Sysoev ab70e781fe ECDHE support
patch by Adrian Kotelba
2011-07-20 15:42:40 +00:00
Igor Sysoev 12d6867fce MSIE export versions are rare now, so RSA 512 key is generated on demand
and is shared among all hosts instead of pregenerating for every HTTPS host
on configuraiton phase. This decreases start time for configuration with
large number of HTTPS hosts.
2011-07-20 12:59:24 +00:00
Igor Sysoev 67d73e89bd bump version: 1.1.0 development version 2011-07-20 09:29:25 +00:00
Igor Sysoev 3fa1c069c3 release-1.0.5 tag 2011-07-19 13:38:44 +00:00
Igor Sysoev 5abe948e5c nginx-1.0.5-RELEASE 2011-07-19 13:38:37 +00:00
Igor Sysoev 1da8924944 fix segfault if cache key is larger than upstream buffer size
patch by Lanshun Zhou
2011-07-19 11:24:16 +00:00
Igor Sysoev 71056ac928 $uid_reset 2011-07-19 11:21:50 +00:00
Igor Sysoev bc7788c128 fix r3756: release lock to allow other process to delete cache node
patch by Maxim Dounin
2011-07-19 10:35:02 +00:00
Igor Sysoev 13a9ba6c2f fix building by MSVC 2011-07-18 15:00:05 +00:00
Igor Sysoev 7cd1f7dd1a revert r3935 and fix "stalled cache updating" alert
by freeing cache at upstream finalize phase
patch by Maxim Dounin
2011-06-28 13:26:08 +00:00
Igor Sysoev 12ec081b1c referer_hash_max_size and referer_hash_bucket_size directives
patch by Witold Filipczyk
2011-06-28 10:40:44 +00:00
Igor Sysoev d18a220446 use !aNULL to disable all anonymous cipher suites
patch by Rob Stradling
2011-06-27 15:47:51 +00:00
Igor Sysoev 6f831d591b bump version 2011-06-27 15:34:44 +00:00
Igor Sysoev b3fe9ea406 release-1.0.4 tag 2011-06-01 09:29:59 +00:00
Igor Sysoev eb2d5244d4 nginx-1.0.4-RELEASE 2011-06-01 09:29:58 +00:00
Igor Sysoev fb92a06b92 fix "stalled cache updating" alert,
when non-cachable HEAD response did not not free an expired cache node
2011-06-01 08:02:34 +00:00
Igor Sysoev 3a5713a9d3 concatenate auto/os/features and auto/unix 2011-05-31 08:25:10 +00:00
Igor Sysoev 3630c03e27 delete unused auto/threads 2011-05-31 08:20:16 +00:00
Igor Sysoev 177d2c6887 Support POSIX semaphores on Linux.
This configure test must run before auto/make, because it adds library.
auto/unix was placed after auto/make just for historical reasons.

Patch by Denis F. Latypoff
2011-05-31 08:17:27 +00:00
Igor Sysoev 7c18f623b1 revert r3875 since now map uses case sensetive regexes by default 2011-05-30 14:24:17 +00:00
Igor Sysoev f4190fa7c3 change ngx_http_map_find(): use case sensitive regexes 2011-05-30 12:36:17 +00:00
Igor Sysoev cf54b536c9 fix building on FreeBSD 6 or earlier against system md5 2011-05-27 13:30:53 +00:00
Igor Sysoev 310aa7f418 make built-in ngx_md5_update() interface consistent with other implemenations 2011-05-27 10:00:46 +00:00
Igor Sysoev d544cc6bdf fix building --without-http_auth_basic_module,
the bug has been introduced in r3923
2011-05-26 07:32:48 +00:00
Igor Sysoev f7ff3c02b7 bump version 2011-05-26 07:31:40 +00:00
Igor Sysoev 27f4dcd998 release-1.0.3 tag 2011-05-25 14:55:11 +00:00
Igor Sysoev c5d6cf14f0 nginx-1.0.3-RELEASE 2011-05-25 14:50:50 +00:00
Igor Sysoev 2cd05c70d8 "$apr1", "{PLAIN}", and "{SSHA}" password methods in auth basic module
patch by Maxim Dounin
2011-05-16 14:54:50 +00:00
Igor Sysoev 666ccc58dd fix testing IPv4 address mapped to IPv6, when only IPv6 access rules are defined 2011-05-16 14:01:23 +00:00
Igor Sysoev cce4e7f016 support IPv4 mapped to IPv6 in geo module 2011-05-16 13:54:42 +00:00
Igor Sysoev fa2fccaa50 support IPv4 mapped to IPv6 in geoip module 2011-05-16 13:50:58 +00:00
Igor Sysoev 3d79014224 fix debug logging 2011-05-13 10:06:56 +00:00
Igor Sysoev a26f0e761e fix a broken cached response if bypass/no_cache directive values are different,
the bug has been introduced in r3700
2011-05-13 10:05:38 +00:00
Igor Sysoev e1f1a48fc9 log "Abort trap" or similar messages 2011-05-11 11:50:19 +00:00
Igor Sysoev dde0a2b00d geoip_org
patch by Alexander Uskov
2011-05-11 09:34:21 +00:00
Igor Sysoev 8e6d533c50 fix typo 2011-05-11 09:25:37 +00:00
Igor Sysoev e9a3637986 bump version 2011-05-11 09:19:48 +00:00
Igor Sysoev af8f49783d release-1.0.2 tag 2011-05-10 12:27:53 +00:00
Igor Sysoev 9cd822482c nginx-1.0.2-RELEASE 2011-05-10 12:27:52 +00:00
Igor Sysoev 70baea38c6 gdImageCopyRotated() may images of even height or width
patch by Adam Bocim
2011-05-10 12:04:57 +00:00
Igor Sysoev 188aab8d3c use POSIX semaphores in shmtx instead of sched_yield()
number of spinlock spins are increased twice
2011-05-10 11:39:13 +00:00
Igor Sysoev f5232e7ea0 fix r3902 2011-05-04 12:21:25 +00:00
Igor Sysoev 7e49ff1e95 bump version 2011-05-04 12:20:32 +00:00
Igor Sysoev 6434d441a9 release-1.0.1 tag 2011-05-03 12:12:05 +00:00
Igor Sysoev 20d637fd9b nginx-1.0.1-RELEASE 2011-05-03 12:12:04 +00:00
Igor Sysoev 2201ceb82f test zero value in an "if" directive consistently with predicates fixed in r3894
thanks to Maxim Dounin
2011-05-03 09:52:27 +00:00
Igor Sysoev ed6565a1f6 revert r3864, it may cause kernel panic on some kernels while working with IPv6 2011-04-23 17:27:55 +00:00
Igor Sysoev b8d1c9dab7 fix building by gcc 4.6 without --with-debug 2011-04-23 17:25:06 +00:00
Igor Sysoev e7cb09ba9b fix r3822
Solaris strerror() invalid error code behaviour depends on version:
    Solaris 10 returns "Unknown error" and sets errno to EINVAL,
    Solaris 9 returns "Unknown error" and leaves errno intact,
    Solaris 2 returns NULL.
2011-04-23 13:15:56 +00:00
Igor Sysoev e1856644bc style fix: remove trailing spaces 2011-04-23 13:11:17 +00:00
Igor Sysoev c812ffa114 Use more precise stat.st_blocks to account cache size on Unix
instead of file length rounded to a file system block size.
There is no similar way on Windows, so rounding to a cache->bsize is kept.
2011-04-22 10:06:43 +00:00
Igor Sysoev d1e5cfaaa6 allow to use $upstream_... variables in SSI 2011-04-21 10:07:07 +00:00
Igor Sysoev 3151544e79 fix r3713
thanks to Igor A. Valcov
2011-04-19 12:29:16 +00:00
Igor Sysoev 9453076bce fix the previous commit 2011-04-17 15:28:05 +00:00
Igor Sysoev d3292d115b an internal MD5 implemenation
patch by Maxim Dounin
2011-04-15 15:58:06 +00:00
Igor Sysoev 1d27a9f698 fix segfault in IPv6 parsing while processing invalid IPv4 address X.YYYY.Z
patch by Maxim Dounin
2011-04-15 13:50:27 +00:00
Igor Sysoev 67d4b8130f values starting with '0' were incorrectly assumed to be false
patch by Maxim Dounin
2011-04-15 12:24:18 +00:00
Igor Sysoev cd2b7082f0 use MurmurHash2 for split_clients, because
its distribution is much better than CRC32's one
2011-04-15 10:59:57 +00:00
Igor Sysoev 4210c99839 ngx_murmur_hash2() 2011-04-15 10:59:24 +00:00
Igor Sysoev 76049aa0c7 bump version 2011-04-15 10:58:44 +00:00
Igor Sysoev ed2307c447 release-1.0.0 tag 2011-04-12 09:04:33 +00:00
Igor Sysoev 9dfbfee4bb nginx-1.0.0-RELEASE 2011-04-12 09:04:32 +00:00
Igor Sysoev dd3ad295ed use memmove() in appropriate places 2011-04-12 08:02:46 +00:00
Igor Sysoev 647e73ae93 "satisfy any" disabled custom 401 error page 2011-04-11 14:17:31 +00:00
Igor Sysoev bc01fa7735 fix CPU hog in cache manager
patch by Maxim Dounin
2011-04-08 15:27:53 +00:00
Igor Sysoev 0f37b7f1f8 fix "image_filter rotate 180" and crop case
the bug has been introduced in r3879
2011-04-07 09:12:30 +00:00
Igor Sysoev 9d244d8af1 bump version 2011-04-07 09:08:52 +00:00
Igor Sysoev e34b78920e release-0.9.7 tag 2011-04-04 12:50:24 +00:00
Igor Sysoev e23f423785 nginx-0.9.7-RELEASE 2011-04-04 12:50:22 +00:00
Igor Sysoev 018038fcf1 reuse keepalive connections if there are no free worker connections
patch by Maxim Dounin
2011-04-04 12:26:53 +00:00
Igor Sysoev f410fb55e9 fix case when a host in fastcgi_pass, scgi_pass, and uwsgi_pass
is given by expression and refers to a defined upstream
2011-04-04 10:43:21 +00:00
Igor Sysoev 5ae8408327 image filter rotate
patch by Adam Bocim
2011-04-04 09:57:32 +00:00
Igor Sysoev 5593d7d6a9 bump version 2011-04-04 09:46:00 +00:00
Igor Sysoev 7df4787d2e release-0.9.6 tag 2011-03-21 15:33:27 +00:00
Igor Sysoev 350278c81d nginx-0.9.6-RELEASE 2011-03-21 15:33:26 +00:00
Igor Sysoev f3bf2ea833 map tests values in low case only, so caseless regex has no sense 2011-03-21 15:18:59 +00:00
Igor Sysoev aae8e442e0 $time_iso8601 log variable
patch by Michael Lustfield
2011-03-16 15:46:57 +00:00
Igor Sysoev 216a4a99fb allow regex as "map" parameter 2011-03-16 15:32:31 +00:00
Igor Sysoev 62000c1e54 remove semicolon, because it is already in "nginx: " prefix 2011-02-21 11:47:28 +00:00
Igor Sysoev e1f2062340 fix warnings 2011-02-21 11:44:26 +00:00
Igor Sysoev 568ea1678d copy OpenSSL-0.9.8r LICENSE for nginx/Windows zip 2011-02-21 10:04:02 +00:00
Igor Sysoev f91ab5b683 bump version 2011-02-21 10:03:28 +00:00
Igor Sysoev cd5722119e release-0.9.5 tag 2011-02-21 09:43:59 +00:00
Igor Sysoev 3befb21ff2 nginx-0.9.5-RELEASE 2011-02-21 09:43:57 +00:00
Igor Sysoev 48762acc93 fix xhtml mime type
thanks to Michael Lustfield
the previous value has been suggested by Konstantin Arkhipov
2011-02-21 08:57:02 +00:00
Igor Sysoev 4f10cd2aa0 fix u->one_addr handling in ngx_inet_resolve_host()
patch by Maxim Dounin
2011-02-17 15:01:16 +00:00
Igor Sysoev 314f69a843 use backlog -1 on Linux
thanks to Andrei Nigmatulin
2011-02-17 14:14:50 +00:00
Igor Sysoev ebe6354e20 always test proxy_redirect with slash, this fixes a case when nginx uses
proxy_pass "http://www", upstream redirects to "http://www.host/uri",
and nginx rewrites it as ".host/uri"
patch by Maxim Dounin
2011-02-17 11:54:35 +00:00
Igor Sysoev 40f5d7aeaf set current atime while setting mtime
patch by Andrei Nigmatulin
2011-02-11 08:02:35 +00:00
Igor Sysoev 50115d0f44 fix "error_page 497 https://" case
patch by Maxim Dounin
the bug has been introduced in r3782
2011-02-01 16:18:55 +00:00
Igor Sysoev b175af94e8 utf8 parameter of geoip_country and geoip_city
patch by Denis F. Latypoff
2011-01-27 12:51:59 +00:00
Igor Sysoev 19889d0f73 bump version 2011-01-27 12:43:11 +00:00
Igor Sysoev b37a451807 release-0.9.4 tag 2011-01-21 11:05:58 +00:00
Igor Sysoev 3e6ffeac04 nginx-0.9.4-RELEASE 2011-01-21 11:04:39 +00:00
Igor Sysoev e8b064d09d server_name $hostname 2011-01-20 15:31:24 +00:00
Igor Sysoev ea64e25f78 style fix: remove trailing spaces 2011-01-20 15:29:53 +00:00
Igor Sysoev 50cdb44e5b move setting conf->server_name in merge phase 2011-01-20 15:15:50 +00:00
Igor Sysoev 09baa4699f use SwitchToThread() instead of Sleep(0), because the later
may not yield control, if there is no thread with higher priority
2011-01-20 13:06:21 +00:00
Igor Sysoev d4d034d2d0 fix building on Fedora 14
patch by Kirill A. Korinskiy
2011-01-20 12:33:17 +00:00
Igor Sysoev c65b2f995b fix large stderr handling without http cache
patch by Maxim Dounin
the bug has been introduced in r3461
2011-01-20 12:23:00 +00:00
Igor Sysoev 92d1aa578f copy OpenSSL-0.9.8q LICENSE for nginx/Windows zip 2011-01-20 11:07:35 +00:00
Igor Sysoev 28305d2eb7 introduce 494 code "Request Header Too Large" 2011-01-20 10:37:58 +00:00
Igor Sysoev c0fd8c8b6c 2011 year 2011-01-20 10:18:12 +00:00
Igor Sysoev e8a5844caf use boolean expression instead of "if" 2010-12-15 14:10:33 +00:00
Igor Sysoev c9f00163dd rename NGX_HTTP_OWN_CODES to NGX_HTTP_NGINX_CODES 2010-12-14 23:04:26 +00:00
Igor Sysoev 98aba275bb bump version 2010-12-14 22:54:04 +00:00
Igor Sysoev b99dd4e4ef release-0.9.3 tag 2010-12-13 11:05:53 +00:00
Igor Sysoev 213882be02 nginx-0.9.3-RELEASE 2010-12-13 11:05:52 +00:00
Igor Sysoev a1b711bf3e allow "env" to work in the single process mode 2010-12-13 10:55:15 +00:00
Igor Sysoev 0f210fb519 always run regex in server_name to get captures for IPv6 addresses,
the same fix for IPv4 addresses has been made in r2584
2010-12-12 21:13:27 +00:00
Igor Sysoev c498ccbcea test wildcard tail hash existance for IPv6 addresses,
the same fix for IPv4 addresses has been made in r2581
2010-12-12 21:10:59 +00:00
Igor Sysoev d5af35b46c style fix 2010-12-12 20:11:31 +00:00
Igor Sysoev ba6a713ae9 remove semicolon, because it is already in "nginx: " prefix 2010-12-11 10:59:26 +00:00
Igor Sysoev 2f3314cc94 test for maximum errno value, since Solaris has no sys_nerr 2010-12-06 14:51:20 +00:00
Igor Sysoev aae3ef5e7b style fix 2010-12-06 14:50:27 +00:00
Igor Sysoev 5c3d5f7c0a test for _sys_nerr only if sys_nerr was not found 2010-12-06 14:49:17 +00:00
Igor Sysoev debeecae69 bump version 2010-12-06 14:40:40 +00:00
Igor Sysoev fdbcb35ef2 release-0.9.2 tag 2010-12-06 11:36:31 +00:00
Igor Sysoev 5572ba03e0 nginx-0.9.2-RELEASE 2010-12-06 11:36:30 +00:00
Igor Sysoev c94a439f6e remove SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG becuase of CVE-2010-4180 2010-12-06 11:17:03 +00:00
Igor Sysoev d9f29017b3 "If-Unmodified-Since" support 2010-12-06 11:11:05 +00:00
Igor Sysoev afd360373a fix building by msvc8 introduced by the previous commit 2010-12-02 14:20:51 +00:00
Igor Sysoev c14dd25380 fallback to accept() if accept4() is not implemented,
the issue has been introduced in r3787
2010-12-02 10:05:41 +00:00
Igor Sysoev ae32ef647d fix building by Cygwin: Cygwin defines _sys_nerr instead of sys_nerr,
the issue has been introduced in r3788
2010-12-01 19:22:37 +00:00
Igor Sysoev 4c6900ea97 bump version 2010-11-30 13:26:21 +00:00
Igor Sysoev 31f3f116ca release-0.9.1 tag 2010-11-30 13:10:33 +00:00
Igor Sysoev 0df784d01b nginx-0.9.1-RELEASE 2010-11-30 13:10:32 +00:00
Igor Sysoev bbefcb5555 add audio/ogg 2010-11-30 12:56:29 +00:00
Igor Sysoev eec11ec886 fix comment 2010-11-29 19:41:53 +00:00
Igor Sysoev 4995ee42dd revert processing NGX_OK in rewrite phase changed in r3798,
this broke "return 204" and "return code text"
2010-11-29 19:40:54 +00:00
Igor Sysoev 2f68562516 bump version 2010-11-29 19:39:26 +00:00
Igor Sysoev 114425b91f release-0.9.0 tag 2010-11-29 15:29:32 +00:00
Igor Sysoev 2e9507bd4d nginx-0.9.0-RELEASE 2010-11-29 15:29:31 +00:00
Igor Sysoev 551ac295a6 add man page in release tarball and fix man building procedure 2010-11-29 15:23:06 +00:00
Igor Sysoev 23c92060f0 add the first release date 2010-11-29 15:21:24 +00:00
Igor Sysoev 95a39b48a6 add "nginx: " prefix when logging to the stderr 2010-11-29 15:01:06 +00:00
Igor Sysoev 6212e4fefe move ngx_strerror_init() at the very start 2010-11-29 15:00:02 +00:00
Igor Sysoev 87d6b1ac22 revert processing NGX_OK and NGX_DONE in rewrite phase changed in r3634 2010-11-29 14:01:17 +00:00
Igor Sysoev af62198836 allocate last zero byte in ngx_crypt() 2010-11-29 09:23:25 +00:00
Igor Sysoev d64bd4e211 style fix 2010-11-26 13:58:28 +00:00
Igor Sysoev adcde1d75a fix building by icc8 2010-11-26 13:36:36 +00:00
Igor Sysoev c43de25a8a keepalive_disable 2010-11-26 12:40:56 +00:00
Igor Sysoev bfe2d1055b allow variable as "map" value 2010-11-26 12:25:51 +00:00
Igor Sysoev 9cf9e107de use "\" to escape "default", "include", and "hostnames" values instead of "!" 2010-11-25 15:36:24 +00:00
Igor Sysoev 25c24ada4c allow empty value as "map" parameter 2010-11-25 15:24:29 +00:00
Igor Sysoev e3c472c877 allow expressions in the first "map" parameter 2010-11-25 15:22:43 +00:00
Igor Sysoev 250ea2c2fa add nginx.8 man page 2010-11-25 14:12:31 +00:00
Igor Sysoev 38e68ea0c1 use copied strerror() messages and autoconfigured sys_nerr value 2010-11-25 11:04:03 +00:00
Igor Sysoev a0b669ace6 Linux accept4() support 2010-11-25 10:15:04 +00:00
Igor Sysoev c504b4fde5 bump version 2010-11-24 13:41:37 +00:00
Igor Sysoev e89c6ff49d release-0.8.53 tag 2010-10-18 12:03:27 +00:00
Igor Sysoev 8c7a427c2b nginx-0.8.53-RELEASE 2010-10-18 12:03:26 +00:00
Igor Sysoev 8c2cfe6ce5 allow override redirect status in error_page 2010-10-18 10:14:00 +00:00
Igor Sysoev 054ecd9e8e change order of limit_req lookup result processing 2010-10-14 09:20:01 +00:00
Igor Sysoev 655e2a925f an excess was logged as 0.000 if requests were limited without delay:
*) use a real excess value instead of non-updated limit_req rbtree node field,
*) move inactivity queue handling inside ngx_http_limit_req_lookup()
   since the node is not required outside the lookup function;

the bug has been introduced in r3184
2010-10-13 20:58:41 +00:00
Igor Sysoev acd0513b8d always update an aio_senfile connection flag accodring to a current
location configuration, this clears the flag for requests passed
via a keep-alive connection
2010-10-12 12:18:39 +00:00
Igor Sysoev acddda123b update event flags after successful io_submit() 2010-10-12 12:11:11 +00:00
Igor Sysoev 438ababa71 file AIO read may be posted inside loop 2010-10-12 12:06:52 +00:00
Igor Sysoev b2f8d93893 add default listen port at the end of server block parsing instead of
merge phase: otherwise the first server without an listen directive
did not become the default server if there was no explicit default server;
the bug has been introduced in r3218
2010-10-11 18:48:18 +00:00
Igor Sysoev 38f3439bcb fix testing, the bug has been introduced in r3218 2010-10-08 11:42:05 +00:00
Igor Sysoev 661df40ad7 gzip_disable degradation 2010-10-04 15:03:00 +00:00
Igor Sysoev 06957e0754 ngx_http_degraded() 2010-10-04 14:59:41 +00:00
Igor Sysoev d7221b4161 bump version 2010-10-04 13:50:09 +00:00
Igor Sysoev 667b025362 release-0.8.52 tag 2010-09-28 06:59:59 +00:00
Igor Sysoev f2dcde3ba1 nginx-0.8.52-RELEASE 2010-09-28 06:59:58 +00:00
Igor Sysoev c3578e20b9 nginx uses SSL mode for a listen socket with any option set,
the bug has been introduced in r3765
2010-09-28 06:50:52 +00:00
Igor Sysoev 784456acf9 bump version 2010-09-28 06:46:58 +00:00
Igor Sysoev b3a096c846 release-0.8.51 tag 2010-09-27 13:08:41 +00:00
Igor Sysoev 3175386126 nginx-0.8.51-RELEASE 2010-09-27 13:08:40 +00:00
Igor Sysoev 7e40763f4b allow duplicate listen ssl options 2010-09-27 11:48:12 +00:00
Igor Sysoev 6b147bd969 decrease resolver errors level to error 2010-09-27 11:23:45 +00:00
Igor Sysoev 2e909f2c3f worker_rlimit_core should be off_t 2010-09-15 15:24:21 +00:00
Igor Sysoev e32ac73eca fix typo 2010-09-13 12:44:43 +00:00
Igor Sysoev c9edd102b9 discard "secure_link_expires on|off" 2010-09-06 14:19:18 +00:00
Igor Sysoev 19f3290ab9 bump version 2010-09-06 11:07:07 +00:00
Igor Sysoev 825e2012bd release-0.8.50 tag 2010-09-02 14:59:19 +00:00
Igor Sysoev 119f9a25fc nginx-0.8.50-RELEASE 2010-09-02 14:59:18 +00:00
Igor Sysoev d2409610ec new ngx_http_secure_link_module with secure_link, secure_link_md5, and
secure_link_expires
2010-09-02 14:37:16 +00:00
Igor Sysoev f819e3b7ed fix race condition if during reconfiguration two cache managers try
to delete old inactive entries: one of them removes a entry just locked by
other manager from the queue and the rbtree as long inactive entry,
causes the latter manager to segfault leaving cache mutex locked,
the bug has been introduced in r3727
2010-09-02 14:31:47 +00:00
Igor Sysoev 0084867ae8 gzip_disable msie6 ignored other patterns 2010-09-02 14:02:57 +00:00
Igor Sysoev 198d1ed567 gzip_disable compiled always the first pattern only 2010-09-02 14:01:58 +00:00
Igor Sysoev e017f64590 gzip_disable msie6 did not inherited if nginx was built without PCRE 2010-09-02 13:54:28 +00:00
Igor Sysoev b9ff0e4dca add "Global\" prefix for signal events 2010-09-02 13:49:05 +00:00
Igor Sysoev 7c48ce89c5 the -q switch 2010-09-02 13:43:02 +00:00
Igor Sysoev e23463da18 if a location is specified by regex, then always compile an "alias",
even into one static string script: this elimates testing this
too specific case inside ngx_http_map_uri_to_path()
2010-08-26 12:33:08 +00:00
Igor Sysoev f20a3d0603 bump version 2010-08-25 12:30:08 +00:00
Igor Sysoev 4ae89a30ef release-0.8.49 tag 2010-08-09 08:24:14 +00:00
Igor Sysoev 4d296543f7 nginx-0.8.49-RELEASE 2010-08-09 08:24:13 +00:00
Igor Sysoev 6a921ab39d image_filter_jpeg_quality supports variables 2010-08-06 15:55:05 +00:00
Igor Sysoev 734b2c0cf1 zero fcn->updating after node allocation 2010-08-04 13:34:23 +00:00
Igor Sysoev e597feff7d error status codes could be cached for next request only,
the bug has been introduced in r3712
2010-08-04 12:55:27 +00:00
Igor Sysoev a589d16bf0 we can free GeoIPRecord just after GeoIP_region_name_by_code(),
because it returns a statically allocated string
2010-08-03 18:38:08 +00:00
Igor Sysoev 63eedfba66 fix segfault, the bug has been introduced in r3738 2010-08-03 18:27:56 +00:00
Igor Sysoev eb3fc51370 bump version 2010-08-03 18:24:18 +00:00
Igor Sysoev 0b3fab8e40 release-0.8.48 tag 2010-08-03 15:10:57 +00:00
Igor Sysoev 0b66561297 nginx-0.8.48-RELEASE 2010-08-03 15:10:56 +00:00
Igor Sysoev b143dd16b6 $geoip_region_name 2010-08-03 15:01:34 +00:00
Igor Sysoev 3646cca88b $geoip_dma_code and $geoip_area_code 2010-08-03 14:19:49 +00:00
Igor Sysoev c0a7183186 fix fastcgi_split_path_info, if URI was not fully captured 2010-08-03 13:35:48 +00:00
Igor Sysoev 515376efd2 *) make code consistent to fastcgi, etc
*) remove STUB comment
2010-08-03 12:59:14 +00:00
Igor Sysoev eb53669ca0 use NULL instead of 0 2010-08-03 12:53:06 +00:00
Igor Sysoev d809597b13 delete surplus assignment 2010-08-03 09:42:53 +00:00
Igor Sysoev f94de11f91 inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
a limit_except block if no handler was defined for the block
2010-08-03 09:24:25 +00:00
Igor Sysoev 7653d2eeff ngx_http_conf_get_module_srv_conf() and ngx_http_conf_get_module_loc_conf()
may be used at merge phase
2010-08-02 15:28:04 +00:00
Igor Sysoev 0bbbba3b7a fix directive type 2010-08-02 12:47:52 +00:00
Igor Sysoev 949db916b2 change logic slightly 2010-08-02 12:34:15 +00:00
Igor Sysoev ec4192e27c change order 2010-08-02 12:32:33 +00:00
Igor Sysoev dd3154c088 *) delete cache key node after a cache file removal
*) move fileless cache key node removal in ngx_http_file_cache_delete()
2010-08-02 12:27:58 +00:00
Igor Sysoev 67136f60fd escape ";" in arguments 2010-07-30 13:25:19 +00:00
Igor Sysoev b57124ccad count cache key node usage for cached error statuses 2010-07-30 12:41:55 +00:00
Igor Sysoev a57b388f4b do not free unused cache node if cache min_uses > 1,
the bug has been introduced in r3695, r3708, r3711
2010-07-30 10:20:08 +00:00
Igor Sysoev a85cd6842d return 415 on too big image in image filter 2010-07-29 15:40:03 +00:00
Igor Sysoev a032e72d9e change default server_name_in_redirect value to off,
since default server_name is empty
2010-07-29 10:01:31 +00:00
Igor Sysoev 49e8b9cadd use an empty name as default server_name instread of hostname 2010-07-29 10:00:04 +00:00
Igor Sysoev 53b9fea5c9 allow server_name "" as the first name 2010-07-29 09:55:54 +00:00
Igor Sysoev 5dc8096d12 decrease SSL handshake error level to info 2010-07-29 09:30:15 +00:00
Igor Sysoev 709119e682 copy OpenSSL-0.9.8o LICENSE for nginx/Windows zip 2010-07-29 09:10:12 +00:00
Igor Sysoev 244db2bb0a bump version 2010-07-29 08:10:22 +00:00
Igor Sysoev bb854b6325 release-0.8.47 tag 2010-07-28 16:16:49 +00:00
Igor Sysoev b4a3977998 nginx-0.8.47-RELEASE 2010-07-28 16:16:48 +00:00
Igor Sysoev 5b762f5847 move debug logging inside ngx_http_file_cache_free() 2010-07-28 15:56:56 +00:00
Igor Sysoev 86fd5fba67 fix $request_time for subrequests 2010-07-28 15:51:50 +00:00
Igor Sysoev 808be9559e several changes in cache cleanup handling:
*) now ngx_http_file_cache_cleanup() uses ngx_http_file_cache_free()
*) ngx_http_file_cache_free() interface has been changed to accept r->cache
   ngx_http_file_cache_cleanup() must use r->cache, but not r, because
   there can be several r->cache's during request processing, r->cache may
   be NULL at request finalising, etc.
*) test if updating request does not complete correctly
2010-07-28 15:49:34 +00:00
Igor Sysoev 74b9ebd872 fix r3708 and r3695: valid_sec is set only for caching error status codes 2010-07-27 19:11:17 +00:00
Igor Sysoev 9b63f57c7c fix r3707: cache node should be freed be a response is not cached 2010-07-27 15:26:33 +00:00
Igor Sysoev 55f4158eb2 fix typo 2010-07-27 13:04:13 +00:00
Igor Sysoev a5fdf95e28 fix r3695: this commit
*) freed valid keys zone node
*) and did not decrease cache size, so cache manager process ete CPU time,
   if cache checking max_size was enabled
2010-07-27 11:22:59 +00:00
Igor Sysoev d492527779 an intercepted error code was not cached 2010-07-19 15:31:46 +00:00
Igor Sysoev 53bd67c0ec style fix 2010-07-19 15:29:16 +00:00
Igor Sysoev c6827a6834 initialize r->cache->file.fd with NGX_INVALID_FILE 2010-07-19 15:28:22 +00:00
Igor Sysoev cdade23c45 bump version 2010-07-19 15:27:06 +00:00
Igor Sysoev ed03d68577 release-0.8.46 tag 2010-07-19 11:31:31 +00:00
Igor Sysoev 4f51725207 nginx-0.8.46-RELEASE 2010-07-19 11:31:30 +00:00
Igor Sysoev 2581a4ccc1 add warnings for proxy_no_cache and fastcgi_no_cache 2010-07-19 09:55:43 +00:00
Igor Sysoev 0c224f68cb proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass 2010-07-19 09:36:04 +00:00
Igor Sysoev 02a017cbcb rename ngx_http_file_cache_create() to ngx_http_file_cache_new() 2010-07-16 10:01:49 +00:00
Igor Sysoev 06189be984 ngx_http_file_cache_create() 2010-07-15 14:01:02 +00:00
Igor Sysoev 3f9edd109f ngx_http_file_cache_name() 2010-07-15 13:46:32 +00:00
Igor Sysoev f1a6cfa6bb style fix 2010-07-15 13:10:05 +00:00
Igor Sysoev 6a857ea7ff delete empty cache zone node if we could not get response to cache 2010-07-15 13:08:51 +00:00
Igor Sysoev 3d8690f9ec fix scgi_no_cache and uwsgi_no_cache initialization 2010-07-14 11:29:19 +00:00
Igor Sysoev c424307308 use ngx_http_test_predicates(), ngx_http_set_predicate_slot()
delete ngx_http_cache(), ngx_http_no_cache_set_slot()
2010-07-14 11:15:45 +00:00
Igor Sysoev 99c55deb3e ngx_http_test_predicates(), ngx_http_set_predicate_slot() 2010-07-14 11:13:59 +00:00
Igor Sysoev 4d45e2c8cf bump version 2010-07-14 11:09:56 +00:00
Igor Sysoev 3ec5e3b179 release-0.8.45 tag 2010-07-13 11:59:37 +00:00
Igor Sysoev 75aa3101c1 nginx-0.8.45-RELEASE 2010-07-13 11:59:36 +00:00
Igor Sysoev f19e0aab2a allow setfib=0 2010-07-13 10:17:09 +00:00
Igor Sysoev 3e8bd94065 use xmlSAXHandler._private field to store xslt filter context 2010-07-12 12:52:01 +00:00
Igor Sysoev 4b5641e11e fix building by msvc7 2010-07-08 16:17:11 +00:00
Igor Sysoev e3c981d93c stop ./configure on Win32 if no library sources was specified,
the bug has been introduced in r2894
2010-07-08 15:57:36 +00:00
Igor Sysoev 68ba88903d do not use prebuild OpenSSL Win32 libraries 2010-07-08 15:51:47 +00:00
Igor Sysoev 2c58299c1f fix typo 2010-07-08 14:02:09 +00:00
Igor Sysoev bf8cb5a0ed style fix 2010-07-08 13:49:21 +00:00
Igor Sysoev 5c381b7c0f update r->buffered after processing SSI command,
the bug has been probably introduced in r2378
2010-07-07 10:17:19 +00:00
Igor Sysoev 2b77360fcf bump version 2010-07-07 10:09:44 +00:00
Igor Sysoev 6d32090705 release-0.8.44 tag 2010-07-05 15:23:56 +00:00
Igor Sysoev 8f145af23a nginx-0.8.44-RELEASE 2010-07-05 15:23:55 +00:00
Igor Sysoev cec9b84e05 listen setfib=X 2010-07-05 13:49:16 +00:00
Igor Sysoev 7d9ed15393 fix case of partially matched patterns on buffer border in sub_filter 2010-07-05 13:45:10 +00:00
Igor Sysoev d07e981e89 fix recognition of SSLv2 Client Hello Packet large than 255 bytes 2010-07-05 13:35:20 +00:00
Igor Sysoev df89ec501a try to use C99 variadic macros first:
AIX 5.3's XL C has problems with GCC style variadic macros
2010-07-05 13:02:25 +00:00
Igor Sysoev 8f15f4dfcb fix building by owc12: GetLongPathName() is available since Win2K only 2010-07-05 12:47:35 +00:00
Igor Sysoev 1598fcb41f HP/UX uses EWOULDBLOCK instead of EAGAIN 2010-07-03 20:16:55 +00:00
Igor Sysoev 28573708e3 do not use a cache headers set to hide 2010-07-02 10:05:40 +00:00
Igor Sysoev 195938733b treat Set-Cookie as a header that forbids caching 2010-07-02 09:49:27 +00:00
Igor Sysoev f88daee0f0 update the previous commit 2010-07-02 09:28:50 +00:00
Igor Sysoev 3ad024c19a use shared ngx_http_upstream_ignore_headers_masks[] 2010-07-02 09:25:38 +00:00
Igor Sysoev 749e620d74 bump version 2010-07-01 12:56:32 +00:00
Igor Sysoev 805d6f1e02 release-0.8.43 tag 2010-06-30 15:11:44 +00:00
Igor Sysoev c3e76b9223 nginx-0.8.43-RELEASE 2010-06-30 15:11:43 +00:00
Igor Sysoev 1122815ff7 remove r->zero_body unused since the previous commit 2010-06-30 14:42:15 +00:00
Igor Sysoev 8ad792ae98 Fix processing
error_page 502 504 /zero;
    location = /zero { return 204; }

The bug has been introduced in r3634.
The fix also allow to use:
    error_page 502 504 = /zero;
    location = /zero { return 200; }

This case still does not work:
    error_page 502 504 /zero;
    location = /zero { return 200; }
2010-06-30 14:39:28 +00:00
Igor Sysoev 2424416b03 change logic introduced in r3649:
*) now $uid_set is cacheable again
*) allow to see at any processing stage that uid cookie is remarked
2010-06-30 14:30:55 +00:00
Igor Sysoev 0097d487ab style fix: remove tabs 2010-06-30 14:28:54 +00:00
Igor Sysoev e4fed15a90 set uid values for main request only 2010-06-30 13:15:20 +00:00
Igor Sysoev 1796c210b5 fix IPv6 listen socket handling while reconfiguring 2010-06-30 12:01:56 +00:00
Igor Sysoev bd8b974fce fix ngx_write_file() buf 2010-06-30 10:33:02 +00:00
Igor Sysoev 67b65ce86b test binary geo range base size 2010-06-30 10:13:51 +00:00
Igor Sysoev c04281e30c test the second binary geo range base existence 2010-06-30 10:12:46 +00:00
Igor Sysoev f63ef664f5 test binary geo ranges base only for ranges 2010-06-30 10:05:56 +00:00
Igor Sysoev e39a4d11e2 test binary gep range base mtime 2010-06-30 10:02:05 +00:00
Igor Sysoev a0f059a4ee binary geo ranges base cache 2010-06-29 16:06:20 +00:00
Igor Sysoev f00e3577dc ngx_create_file_mapping() 2010-06-29 15:18:50 +00:00
Igor Sysoev d920c9a32a change duplicate default geo range processing 2010-06-29 13:36:16 +00:00
Igor Sysoev cfdf464b50 fix building without IPv6 after the previous commit 2010-06-25 13:17:33 +00:00
Igor Sysoev e89740a95e Now $uid_set may be used at any time, r2013 states the same is wrong.
Besides, now $uid_set is not cacheable and may have two values:
before and after header filter processing.
This allows to log case, when uid cookie is remarked.
2010-06-25 12:16:31 +00:00
Igor Sysoev fbd33432dd make logic more clear 2010-06-25 12:06:37 +00:00
Igor Sysoev e0963f0de2 delete stale comments 2010-06-25 12:05:12 +00:00
Igor Sysoev 09eb3358d2 eliminate a number of ranges: about 18,000 /16 networks are empty,
this change saves about 70K/140K on 32/64-bit platforms
2010-06-24 15:26:05 +00:00
Igor Sysoev f3a714a6ba fix a bug when ngx_cpymem() returns a cast type:
p = (type *) ngx_cpymem(...)
2010-06-24 15:17:06 +00:00
Igor Sysoev 35881a0c52 break cycle early 2010-06-24 13:16:19 +00:00
Igor Sysoev 2d311b77d0 style fix 2010-06-23 16:34:54 +00:00
Igor Sysoev 0bde90b418 change ngx_http_variable_value_node_t to more generic ngx_str_node_t 2010-06-23 15:31:33 +00:00
Igor Sysoev e4f22f050b bump version 2010-06-23 14:49:57 +00:00
Igor Sysoev aef864f874 release-0.8.42 tag 2010-06-21 10:16:25 +00:00
Igor Sysoev 5969286d32 nginx-0.8.42-RELEASE 2010-06-21 10:16:24 +00:00
Igor Sysoev 8c0c0c4231 ngx_http_scgi_module 2010-06-18 15:51:14 +00:00
Igor Sysoev 276042367d Test regex location if URI matches exactly to non-exact location.
Revert a feature introduced in r2028. The feature confuses mostly,
the only gain was not to test regex for a frequent request such as
"/" in "locaiton /".
2010-06-18 15:38:31 +00:00
Igor Sysoev 88948dcdf3 use ngx_http_send_response() in empty_gif 2010-06-18 15:17:07 +00:00
Igor Sysoev d456038185 add files missed in the previuos commit 2010-06-18 15:16:18 +00:00
Igor Sysoev 2e8a1ca65e return code text 2010-06-18 15:15:20 +00:00
Igor Sysoev 4a758b76a5 ngx_http_send_response() 2010-06-18 15:08:44 +00:00
Igor Sysoev b09cdc4156 303 See Other 2010-06-18 14:58:52 +00:00
Igor Sysoev 841fae0f47 style fix 2010-06-15 15:30:00 +00:00
Igor Sysoev 8a82f68f61 fix r3628 2010-06-15 15:27:06 +00:00
Igor Sysoev 4795124a2f make code more obviuos 2010-06-15 15:21:37 +00:00
Igor Sysoev 7938b9625b use ngx_http_parse_status_line() 2010-06-15 15:15:06 +00:00
Igor Sysoev b509ddb93d ngx_http_parse_status_line() 2010-06-15 15:13:34 +00:00
Igor Sysoev cff6dbbb59 update the previous commit 2010-06-15 15:09:18 +00:00
Igor Sysoev d6298ddcdf support CGI-style response 2010-06-15 14:30:13 +00:00
Igor Sysoev 2c23ca7eb0 style fix 2010-06-15 12:45:33 +00:00
Igor Sysoev 595da77924 bump version 2010-06-15 12:41:13 +00:00
Igor Sysoev a853558d70 release-0.8.41 tag 2010-06-15 09:45:07 +00:00
Igor Sysoev 3bdf455287 nginx-0.8.41-RELEASE 2010-06-15 09:45:06 +00:00
Igor Sysoev 7a1aa4fe6c allow spaces in URI 2010-06-15 09:31:19 +00:00
Igor Sysoev a293dff49e do not free() stack allocated buffer 2010-06-14 18:09:52 +00:00
Igor Sysoev db8805fdc6 PATCH method 2010-06-10 11:08:28 +00:00
Igor Sysoev 11d171a379 allow Destination URL without host 2010-06-10 08:17:16 +00:00
Igor Sysoev 9de72f1418 delete empty Server and Date header used only in proxy mode 2010-06-08 19:33:53 +00:00
Igor Sysoev 39267a6353 change variable names 2010-06-08 16:15:47 +00:00
Igor Sysoev ccbf3076c9 install uwsgi_params 2010-06-08 15:25:48 +00:00
Igor Sysoev c549637101 delete surplus flush 2010-06-08 13:43:20 +00:00
Igor Sysoev 04944c154c do not try to calculate procent sum if there was an error 2010-06-08 09:06:57 +00:00
Igor Sysoev 78e422da42 delete useless code 2010-06-07 14:37:56 +00:00
Igor Sysoev 77722cd81a fix rewritten Refresh header length 2010-06-07 14:33:50 +00:00
Igor Sysoev 6f632aaadf 202 Accepted status code 2010-06-07 13:38:39 +00:00
Igor Sysoev 9f09773a48 bump version 2010-06-07 13:34:56 +00:00
Igor Sysoev c44d079d38 release-0.8.40 tag 2010-06-07 12:38:33 +00:00
Igor Sysoev 5793afad4f nginx-0.8.40-RELEASE 2010-06-07 12:38:32 +00:00
Igor Sysoev 0ff90bffc8 fix "/dir/%3F../" and "/dir/%23../" cases 2010-06-04 16:05:55 +00:00
Igor Sysoev 7d26dffc7d test default NTFS stream "::$DATA" 2010-06-04 15:37:49 +00:00
Igor Sysoev df4aaffdbe *) delete no longer used unix domain sockets
*) fix unix domain socket comparison
2010-06-04 13:34:23 +00:00
Igor Sysoev 0d06bbd47b uwsgi cache 2010-06-04 12:55:01 +00:00
Igor Sysoev a87c600c92 uwsgi_bind 2010-06-04 12:32:08 +00:00
Igor Sysoev 206160c263 allow uwsgi_param to override client headers using HTTP_ parameters 2010-06-04 12:26:27 +00:00
Igor Sysoev e6ae3f1444 uwsgi_store 2010-06-04 11:31:01 +00:00
Igor Sysoev 9adbc7b876 add uwsgi_param and client request headers debug logging 2010-06-04 10:03:57 +00:00
Igor Sysoev 26053d5645 do not pass if-... headers for cacheable fastcgi responses 2010-06-04 09:17:09 +00:00
Igor Sysoev b063eefdff rename variable to conform to the next commit 2010-06-03 16:42:07 +00:00
Igor Sysoev 26c10e0d6f use local headers_names array instead of stored in configuration
and allocate its elements from temporary pool
2010-06-03 14:50:59 +00:00
Igor Sysoev c7ede0111e allow fastcgi_param to override client headers using HTTP_ parameters 2010-06-03 14:41:30 +00:00
Igor Sysoev 6da92b13e4 add client request headers debug logging in fastcgi 2010-06-03 13:49:59 +00:00
Igor Sysoev 039f9c5fe3 remove the special static fastcgi_param values processing,
because it is anyway very seldom case
2010-06-02 15:08:29 +00:00
Igor Sysoev 7359de27c7 print default module temporary directory path in summary
only if the module is enabled
2010-06-01 20:32:32 +00:00
Igor Sysoev 9f71b6998d style fix 2010-06-01 20:27:03 +00:00
Igor Sysoev dfa107e626 improve uwsgi_string processing 2010-06-01 20:24:30 +00:00
Igor Sysoev 8a8cd22128 delete unneeded declaration 2010-06-01 20:23:14 +00:00
Igor Sysoev 4c6994067b delete unused ngx_http_uwsgi_add_variables() 2010-06-01 20:21:56 +00:00
Igor Sysoev d47f1055fc improve uwsgi_modifierX processing:
*) use ngx_conf_set_num_slot()
*) check bounds
*) check duplicates
2010-06-01 20:19:57 +00:00
Igor Sysoev fed79c9d28 remove LICENSE text 2010-06-01 19:57:52 +00:00
Igor Sysoev da28ba8702 style fix 2010-06-01 17:46:01 +00:00
Igor Sysoev a53fb650d4 ./configure --http-uwsgi-temp-path=PATH 2010-06-01 17:44:51 +00:00
Igor Sysoev 7bb84c2b00 fix the previous commit when value is static string: remove the special
static values processing, because it is anyway very seldom case
2010-06-01 17:30:23 +00:00
Igor Sysoev 3b34cf727f remove useless copy: key name should be just copied before value length 2010-06-01 17:25:36 +00:00
Igor Sysoev 04d69c444a simplify binary little endian length processing 2010-06-01 17:04:56 +00:00
Igor Sysoev b2e22ec7d0 use ngx_str_set() and ngx_str_null() 2010-06-01 16:12:00 +00:00
Igor Sysoev d95fe917dd fix copyrights 2010-06-01 16:10:05 +00:00
Igor Sysoev 63603bd691 fix style, some names, and building by MSVC8 2010-06-01 16:00:42 +00:00
Igor Sysoev 91f8c9e53d style fix: remove tabs and trailing spaces 2010-06-01 15:55:04 +00:00
Igor Sysoev 171cb44cd0 import original ngx_http_uwsgi_module version 2010-06-01 15:53:11 +00:00
Igor Sysoev 07ba9d63e8 bump version 2010-06-01 15:20:14 +00:00
Igor Sysoev 19eafa3ff8 release-0.8.39 tag 2010-05-31 15:10:05 +00:00
Igor Sysoev 224c98a31c nginx-0.8.39-RELEASE 2010-05-31 15:10:04 +00:00
Igor Sysoev 17d0809b81 fix IPv6 and Unix domain sockets inheritance while online upgrade 2010-05-31 14:49:11 +00:00
Igor Sysoev 3927155f8f fix building by ICC8, the bug had been introduced in r3476 2010-05-31 14:44:17 +00:00
Igor Sysoev b4153c3846 fix handling an inherited alias in inclusive location 2010-05-31 14:41:54 +00:00
Igor Sysoev fd2bece65b fix a try_files/alias case when alias uses captures and
try_files  .html  ""  /  =404;
2010-05-27 13:44:22 +00:00
Igor Sysoev 829cad2a35 do not add tested file to a location regex string,
instead, set URI to the tested file, or keep URI unchanged,
if the tested file is a directory,
the later allows to handle a directory autoredirect
2010-05-27 13:24:19 +00:00
Igor Sysoev 0be95c195f fix the previous commit 2010-05-27 13:15:24 +00:00
Igor Sysoev d9ea5f598c improve debug logging: "try to use file/dir" 2010-05-27 13:09:09 +00:00
Igor Sysoev 10a651e7f3 bump version 2010-05-27 12:55:05 +00:00
Igor Sysoev b3a742622a release-0.8.38 tag 2010-05-24 12:47:50 +00:00
Igor Sysoev 3b41f7b0f6 nginx-0.8.38-RELEASE 2010-05-24 12:47:49 +00:00
Igor Sysoev 1fdb674a82 remove r->zero_in_uri 2010-05-24 12:35:10 +00:00
Igor Sysoev 8bf98c72ca proxy_no_cache and fastcgi_no_cache 2010-05-24 11:01:05 +00:00
Igor Sysoev b70b136a77 fix delay in limit_req 2010-05-24 07:43:39 +00:00
Igor Sysoev e4281c4f4d autodetect redirect if URI is rewritten to a string starting with $scheme 2010-05-23 19:36:12 +00:00
Igor Sysoev ccf572ef43 delete warnings of proxy_upstream_max_fails, proxy_upstream_fail_timeout,
fastcgi_upstream_max_fails, fastcgi_upstream_fail_timeout,
memcached_upstream_max_fails, and memcached_upstream_fail_timeout
directives obsolete since 0.5.0 version
2010-05-20 11:46:01 +00:00
Igor Sysoev 7d27b6664b allow to use $uid_got in SSI and perl module 2010-05-18 16:24:56 +00:00
Igor Sysoev 70028733bd bump version 2010-05-18 16:20:02 +00:00
Igor Sysoev 01caecaad5 release-0.8.37 tag 2010-05-17 06:08:53 +00:00
Igor Sysoev a073a73342 nginx-0.8.37-RELEASE 2010-05-17 06:08:52 +00:00
Igor Sysoev df46eaa53a fix SSI include stub for valid empty responses 2010-05-14 12:18:44 +00:00
Igor Sysoev 63b4ff086e do not cache response if it has "no-store" or "private"
in "Cache-Control" header
2010-05-14 12:04:58 +00:00
Igor Sysoev d3c2bfa988 ngx_str_set() and ngx_str_null() 2010-05-14 09:56:37 +00:00
Igor Sysoev 27c8b20db8 use ngx_min() and ngx_max() 2010-05-14 09:55:33 +00:00
Igor Sysoev 899a35a7f8 fix segfault: ngx_http_upstream_cleanup() cleans r->cleanup,
the bug had been introduced in r3419
2010-05-14 09:22:58 +00:00
Igor Sysoev 294b17b1c4 ngx_http_split_clients_module 2010-05-14 09:02:10 +00:00
Igor Sysoev 472e63df9e ngx_atofp() 2010-05-14 09:01:30 +00:00
Igor Sysoev 9b4376cb32 remove unused ./configure define's 2010-05-13 13:58:18 +00:00
Igor Sysoev f6865b658c allow hash key values more than 255 bytes, it does not actually increase mean
hash element size, because due to aligning a byte after key is not used
anyway in 3/4 cases on 32-bit platforms and in 7/8 cases on 64-bit platforms
2010-05-13 12:52:45 +00:00
Igor Sysoev bfd5cb3079 style fix: remove blank line 2010-05-13 10:22:48 +00:00
Igor Sysoev c99fb40847 style fix: remove blank line 2010-05-12 15:56:54 +00:00
Igor Sysoev f916cd3c3c fix rounding issues in %f format 2010-05-12 13:13:11 +00:00
Igor Sysoev 3c97adcad5 use double in %f format to allow %.15f precision 2010-05-12 13:12:31 +00:00
Igor Sysoev 319f13b417 Zimbra IMAP server may return only 4 bytes: "+ \r\n" 2010-04-23 09:53:52 +00:00
Igor Sysoev 1ebdd0e355 bump version 2010-04-23 08:14:57 +00:00
Igor Sysoev 8bfd901029 release-0.8.36 tag 2010-04-22 17:37:22 +00:00
Igor Sysoev f46476235b nginx-0.8.36-RELEASE 2010-04-22 17:37:21 +00:00
Igor Sysoev 5238859639 use lstat() for WebDAV DELETE, COPY, and MOVE to handle symlinks 2010-04-22 17:15:42 +00:00
Igor Sysoev 97e75a75d5 change processing variables accessed by SSI and perl module:
*) the indexed variables are always flushed
*) never show warning for not found variables
2010-04-22 14:02:45 +00:00
Igor Sysoev 0a728401cb make $arg_ variables non-cacheable 2010-04-22 13:35:30 +00:00
Igor Sysoev 9086b6dc95 do not log misleading errno in "not a regular file" error 2010-04-21 16:01:52 +00:00
Igor Sysoev 8952445365 use non-blocking open() not to hang on FIFO files, etc. 2010-04-21 15:59:36 +00:00
Igor Sysoev cbcb42a853 build nginx/Windows against OpenSSL-0.9.8n, since nginx-0.8.35
built against OpenSSL-1.0.0 crashed on Windows XP somewhere
in the NTDLL.DLL on the master process exit
2010-04-21 15:09:17 +00:00
Igor Sysoev cbc7df4b19 do not store an encoded variable value as a new cached variable value 2010-04-21 14:58:21 +00:00
Igor Sysoev 57a1d56e62 fix building without HTTP cache, the bug had been introduced in r3461 2010-04-06 11:49:36 +00:00
Igor Sysoev 38d7b13350 copy OpenSSL-1.0.0 LICENSE for nginx/Windows zip 2010-04-02 14:20:48 +00:00
Igor Sysoev 85bf60cd00 fix building OpenSSL-1.0.0 on 64-bit Linux:
make installs the libraries in lib64 directory
2010-04-02 14:19:45 +00:00
Igor Sysoev 9ae58746a4 bump version 2010-04-02 14:18:23 +00:00
Igor Sysoev f71aa36002 release-0.8.35 tag 2010-04-01 15:44:12 +00:00
Igor Sysoev 7bc1a2091f nginx-0.8.35-RELEASE 2010-04-01 15:44:11 +00:00
Igor Sysoev e5436ffa92 MSVC8 compatibility with OpenSSL 1.0.0 2010-04-01 15:18:29 +00:00
Igor Sysoev 5a7f376945 revert partially r1555 and fix the error "memcached sent invalid trailer" 2010-04-01 15:16:22 +00:00
Igor Sysoev ee16f19cf6 escape ampersand in argument while rewrite 2010-04-01 12:45:59 +00:00
Igor Sysoev d307d7265a change ngx_http_ssi_filter and ngx_http_charset_filter order 2010-04-01 10:19:02 +00:00
Igor Sysoev d83f883d86 chunked_transfer_encoding 2010-04-01 10:18:00 +00:00
Igor Sysoev ea20bebc3a do not add a port in redirect if we listen on unix domain socket 2010-03-31 13:30:50 +00:00
Igor Sysoev 29b222315b fix typo 2010-03-30 15:04:41 +00:00
Igor Sysoev 3a6088e3e8 do not set file time in ngx_copy_file() if the time is -1,
this fixes an issue when file is moved across devices
2010-03-30 14:15:25 +00:00
Igor Sysoev 612ae4088b fix comments 2010-03-26 21:17:26 +00:00
Igor Sysoev cae7ae5963 use "rep; nop" instead of "pause" on Solaris/amd64 2010-03-26 13:38:41 +00:00
Igor Sysoev f55bd6a5dd fix a comment and a style fix 2010-03-26 11:27:32 +00:00
Igor Sysoev 8248b0826a reset a parsing state to parse correctly an upstream response,
if 400 or 414 response has been redirected to upstream
2010-03-25 13:27:52 +00:00
Igor Sysoev 4153ebe965 zlib 1.2.4 compatibility 2010-03-25 10:07:38 +00:00
Igor Sysoev b172591b1c *) introduce ngx_time_sigsafe_update() to update the error log time only
*) change ngx_time_update() interface
2010-03-25 09:10:10 +00:00
Igor Sysoev 72d46f41f8 *) use previously cached GMT offset value to update time from a signal handler
*) change ngx_time_update() interface since there are no notification methods
   those return time
2010-03-13 18:08:07 +00:00
Igor Sysoev 748e22aa4d do not update time in the timer signal handler,
since localtime_r() is not Async-Signal-Safe function
2010-03-12 14:31:47 +00:00
Igor Sysoev 8dd13e234f use sys_errlist[] in signal handler instead
of non Async-Signal-Safe strerror_r()
2010-03-12 11:15:26 +00:00
Igor Sysoev 300def0abe "proxy_redirect default" may not be used if a proxy_pass uses variables 2010-03-10 14:41:49 +00:00
Igor Sysoev 0aed82ca26 fix proxy_redirect name in error message 2010-03-10 14:37:18 +00:00
Igor Sysoev 2ddd471c41 fix segfault if there was non cached large FastCGI stderr output before header,
the bug had been introduced in r3461
2010-03-10 13:51:47 +00:00
Igor Sysoev 30fd180bf0 bump version 2010-03-10 13:49:17 +00:00
Igor Sysoev bb3127ad4f release-0.8.34 tag 2010-03-03 17:00:10 +00:00
Igor Sysoev 5541e4c826 nginx-0.8.34-RELEASE 2010-03-03 17:00:09 +00:00
Igor Sysoev 88f9f25ffd add 7z MIME type 2010-03-03 16:37:57 +00:00
Igor Sysoev ee89ba0db0 add OpenSSL_add_all_algorithms(), this fixes the error
"ASN1_item_verify:unknown message digest algorithm" occurred if
client certificate is signed using sha256WithRSAEncryption
2010-03-03 16:23:14 +00:00
Igor Sysoev 9d47c23803 make $request_method non-cacheable 2010-03-03 16:14:07 +00:00
Igor Sysoev b6e86ba98a remove code disabled since 0.1.29 version 2010-03-03 15:14:04 +00:00
Igor Sysoev 6bf4bd2ecd use a right "Location" header name, however, it did not harm,
since ngx_http_variable_sent_location() never use key name field
2010-03-03 15:08:06 +00:00
Igor Sysoev a591dc315a fix cached FastCGI response with large stderr output before header 2010-03-03 10:43:38 +00:00
Igor Sysoev 793c860b96 allow HTTPS referers 2010-03-03 10:21:12 +00:00
Igor Sysoev 473801023f compare long file names in case-insensitive mode,
the bug had been introduced in r3418
2010-03-03 10:05:54 +00:00
Igor Sysoev 2b623925f0 Set SSL session context for "ssl_session_cache none".
This fixes a bug when client certficate is used and nginx closes connection
with the message: "SSL_GET_PREV_SESSION:session id context uninitialized".
2010-03-02 08:41:47 +00:00
Igor Sysoev 3f90fb5e80 fix a geo range if the range includes two or more /16 networks
and does not begin at /16 network boundary
2010-02-25 17:26:01 +00:00
Igor Sysoev f83b903fb2 decrease SSL handshake error level to info 2010-02-19 20:54:58 +00:00
Igor Sysoev 5e2a777c4d SSI %s timefmt has no timezone offset 2010-02-19 13:53:11 +00:00
Igor Sysoev a0592a1b95 use content type of the parent request in SSI stub block output
instead of default one
2010-02-19 13:42:59 +00:00
Igor Sysoev 07d96f462a style fix: remove tabs 2010-02-18 14:47:09 +00:00
Igor Sysoev c0c6c600d9 fix $upstream_http_ variable prefix length 2010-02-15 19:38:59 +00:00
Igor Sysoev bffced632f delete surplus code 2010-02-12 09:48:04 +00:00
Igor Sysoev bf124da2ac const char *fmt in ngx_conf_log_error() 2010-02-12 09:45:05 +00:00
Igor Sysoev 19f0776167 delete ngx_http_perl_cleanup_t unused since r909 2010-02-12 09:40:46 +00:00
Igor Sysoev 217672772c fix request counter for $r->sleep(), the bug was introduced in r3050 2010-02-12 09:32:02 +00:00
Igor Sysoev 56345a23b1 bump version 2010-02-12 09:31:01 +00:00
Igor Sysoev 1a436983bf release-0.8.33 tag 2010-02-01 13:36:32 +00:00
Igor Sysoev e07bab2761 nginx-0.8.33-RELEASE 2010-02-01 13:36:31 +00:00
Igor Sysoev fee764f888 do not disable keepalive after POST requests for MSIE 7+ 2010-02-01 12:58:07 +00:00
Igor Sysoev 9493da5b70 disable keepalive for Safari:
https://bugs.webkit.org/show_bug.cgi?id=5760
2010-02-01 12:01:01 +00:00
Igor Sysoev e24a34c1a6 delete u->cleanup mark, this fixes large values in $upstream_response_time,
the bug had been introduced in r3007
2010-01-29 16:45:14 +00:00
Igor Sysoev 8af69cca7c disable Win32 short file names 2010-01-28 14:17:51 +00:00
Igor Sysoev c9a1681d53 skip URI trailing spaces under Win32 2010-01-28 14:09:28 +00:00
Igor Sysoev c830e70829 Fix segfault when while discarding body a write event handler is called,
runs ngx_http_core_run_phases(), and starts a request processing again.
The write event has clear type and remained in a keepalive connection.
The bug was introduced in r3050.
2010-01-28 08:33:24 +00:00
Igor Sysoev 364804b573 bump version 2010-01-28 08:22:45 +00:00
Igor Sysoev f972c92b31 release-0.8.32 tag 2010-01-11 15:35:45 +00:00
Igor Sysoev 15e5bd73a7 nginx-0.8.32-RELEASE 2010-01-11 15:35:44 +00:00
Igor Sysoev 72fc307f7a allow a chunked body for 201 responses 2010-01-11 15:14:23 +00:00
Igor Sysoev cc7b3735a3 fix ngx_utf8_cpystrn(): it did not fully copy utf-8 string 2010-01-11 13:39:24 +00:00
Igor Sysoev b9f7606000 named captures worked for two names only 2010-01-11 11:21:46 +00:00
Igor Sysoev c770367df8 add context to a resolver log 2010-01-11 11:01:02 +00:00
Igor Sysoev f1f1d3d3e5 2010 year 2010-01-01 14:53:56 +00:00
Igor Sysoev d4aa91d201 use "localhost" in "Host" header line, if unix socket is used in "auth_http" 2009-12-25 15:43:40 +00:00
Igor Sysoev e61fc75357 fix negative time in "Cache-Control" if "expires modified" sets time in the past 2009-12-25 15:00:08 +00:00
Igor Sysoev da2493bf47 bump version 2009-12-25 14:57:10 +00:00
Igor Sysoev d7c45d5dff release-0.8.31 tag 2009-12-23 15:44:32 +00:00
Igor Sysoev d03ea94cb0 nginx-0.8.31-RELEASE 2009-12-23 15:44:31 +00:00
Igor Sysoev 51451a2446 allow to handle 301/302 in error_page 2009-12-23 15:31:16 +00:00
Igor Sysoev 12ed8a8269 fix a cached zero-length body case 2009-12-23 14:46:45 +00:00
Igor Sysoev 44096861e4 fix typo 2009-12-23 14:22:17 +00:00
Igor Sysoev 9bcdcce406 $geoip_city_continent_code, $geoip_latitude, $geoip_longitude 2009-12-22 17:33:03 +00:00
Igor Sysoev 23c40479f0 fix the "If-None-Match" header name 2009-12-22 16:41:34 +00:00
Igor Sysoev b118177a47 fix building by gcc 4.x with -O2/3/s in some Linux distributions:
dereferencing type-punned pointer will break strict-aliasing rules
2009-12-22 15:29:56 +00:00
Igor Sysoev e0c443005d fix building by gcc 4.4 with -O2/3/s:
dereferencing pointer 'sin' does break strict-aliasing rules
2009-12-22 15:15:45 +00:00
Igor Sysoev 1ef86261e3 force image filter conversion if JPEG application data consume more than 5% 2009-12-22 13:03:49 +00:00
Igor Sysoev 4c41f72694 style fix 2009-12-22 10:45:29 +00:00
Igor Sysoev 0c750a8974 fix building by gcc 4.x with -O2/3/s in some Linux distributions:
dereferencing type-punned pointer will break strict-aliasing rules
the bug has been introduced in r3065
2009-12-21 21:56:48 +00:00
Igor Sysoev 90fbee3778 do not add NGX_GCC_OPT twice: it is added later with -W 2009-12-21 17:51:30 +00:00
Igor Sysoev fd35538c22 fix caseless locations, the bug had been introduced in r3326 2009-12-17 14:25:46 +00:00
Igor Sysoev aac970ea24 test degradation parameters 2009-12-17 12:45:13 +00:00
Igor Sysoev 0bf5c53d75 fix r3331:
*) now pools are aligned to 16 bytes
*) forbidden to set non-aligned pool sizes
2009-12-17 12:25:46 +00:00
Igor Sysoev ca4cf0097d fix Win32 error message when an temporary file replaces an existent file:
return at once if ngx_win32_rename_file() was not failed
and do not try to delete already the renamed temporary file
2009-12-17 10:05:39 +00:00
Igor Sysoev c4b933ff17 bump version 2009-12-16 14:59:33 +00:00
Igor Sysoev 4791a0c2cb release-0.8.30 tag 2009-12-15 14:34:10 +00:00
Igor Sysoev 2a2365bde9 nginx-0.8.30-RELEASE 2009-12-15 14:34:09 +00:00
Igor Sysoev ca6d8b6471 add conf/fastcgi.conf 2009-12-15 13:54:41 +00:00
Igor Sysoev c51c4d122c fix Win32 error messages when an temporary file replaces an existent file:
*) do not rename an already renamed file
*) now ngx_win32_rename_file() returns error code
*) do not log failure inside ngx_win32_rename_file()
2009-12-15 13:47:02 +00:00
Igor Sysoev 50ff8c8960 default large_client_header_buffers' buffer size should be 8K as compatible
with Apache's one
2009-12-09 06:37:41 +00:00
Igor Sysoev 036018227f print libatomic configure summary 2009-12-08 12:53:54 +00:00
Igor Sysoev 81251e33b2 backout r3315 and test r->header_only last, since it's not actually
frequent here: 304 and HEAD responses are not set it before the filter
2009-12-07 15:41:57 +00:00
Igor Sysoev 95ae6b5c15 fix libatomic usage on arm, cris, hppa, m68k, and sparc platforms 2009-12-07 15:32:38 +00:00
Igor Sysoev fa26e879c7 fix double free(), introduced in r3268 2009-12-07 15:13:46 +00:00
Igor Sysoev 1b4e36f4ab remove stale comment 2009-12-02 13:03:54 +00:00
Igor Sysoev 93b141bcd4 bump version 2009-12-02 13:02:43 +00:00
Igor Sysoev 1deb5fe21d release-0.8.29 tag 2009-11-30 13:28:13 +00:00
Igor Sysoev 0b8360cde0 nginx-0.8.29-RELEASE 2009-11-30 13:28:12 +00:00
Igor Sysoev 4a8cf7faad support "*" in gzip_types, ssi_types, etc 2009-11-30 13:15:10 +00:00
Igor Sysoev b56979c3da chmod unix listen domain socket to 0666 2009-11-30 11:26:24 +00:00
Igor Sysoev 6b812fbd04 log proxied HTTP/0.9 responses status as "009" 2009-11-29 20:49:29 +00:00
Igor Sysoev cb2e3fbbc9 fix handling cached HTTP/0.9 response 2009-11-29 20:48:01 +00:00
Igor Sysoev cfcec22156 fix server_name regex named captures given by "?P<...>" 2009-11-29 20:39:32 +00:00
Igor Sysoev 36f3d115fc test invalid --with-ld-opt in right place 2009-11-27 22:02:04 +00:00
Igor Sysoev c4cf77686e atomic operations test-run 2009-11-27 22:00:39 +00:00
Igor Sysoev c0ce24e72d update comments 2009-11-25 18:03:59 +00:00
Igor Sysoev 959ee5a29a fix comment 2009-11-25 17:56:53 +00:00
Igor Sysoev c4b8a56c05 libatomic_ops support 2009-11-25 17:55:25 +00:00
Igor Sysoev e43dac2e19 GCC 4.1 builtin atomic operations 2009-11-25 17:34:35 +00:00
Igor Sysoev 601d5df98c bump version 2009-11-25 17:04:00 +00:00
Igor Sysoev bdb08396c9 release-0.8.28 tag 2009-11-23 15:53:13 +00:00
Igor Sysoev aa8028a4f9 nginx-0.8.28-RELEASE 2009-11-23 15:53:12 +00:00
Igor Sysoev b29ff35cc8 add NGX_PROCESS_HELPER process status 2009-11-23 15:46:21 +00:00
Igor Sysoev 2adc3ccc51 decrease SSL handshake error level to info 2009-11-23 14:09:57 +00:00
Igor Sysoev 08e0fd2785 fix building without PCRE, the bug had been introduced in r3326 2009-11-23 13:13:58 +00:00
Igor Sysoev 59ef8fca12 bump version 2009-11-23 13:09:33 +00:00
Igor Sysoev d5bb429793 release-0.8.27 tag 2009-11-17 16:53:18 +00:00
Igor Sysoev 7b44cae304 nginx-0.8.27-RELEASE 2009-11-17 16:53:17 +00:00
Igor Sysoev b8f7d889d4 a cache manager thread handle was overwritten by a cache loader thread handle,
this caused an exit delay, the bug had been introduced in r3023
2009-11-17 16:46:27 +00:00
Igor Sysoev 6e0099e9a7 add comment from r2716 commit message 2009-11-17 10:31:39 +00:00
Igor Sysoev ebb51a5def use global perl variable in perl_destruct()/perl_free()
for non-mulitiplicity perl
2009-11-17 10:28:12 +00:00
Igor Sysoev 3b1acdc631 fix pcre allocation on Win32, the bug had been introduced in r3326 2009-11-17 10:24:45 +00:00
Igor Sysoev 829324178d bump version 2009-11-17 09:59:45 +00:00
Igor Sysoev 5f55e969a5 release-0.8.26 tag 2009-11-16 19:25:38 +00:00
Igor Sysoev 977038f9f3 nginx-0.8.26-RELEASE 2009-11-16 19:25:37 +00:00
Igor Sysoev 726741e0bd evaluate maximum captures size on configuration phase 2009-11-16 19:11:38 +00:00
Igor Sysoev df3c5d435c fix captures in "rewrite", the bug had been introduced in r3326 2009-11-16 19:10:45 +00:00
Igor Sysoev 15aa7e34c7 fix building without --with-debug, introduced in r3328 2009-11-16 16:00:52 +00:00
Igor Sysoev c635cd4708 bump version 2009-11-16 16:00:12 +00:00
Igor Sysoev 4f101b833a release-0.8.25 tag 2009-11-16 13:47:11 +00:00
Igor Sysoev 1a1f223af9 nginx-0.8.25-RELEASE 2009-11-16 13:47:10 +00:00
Igor Sysoev b8214d476a backout r3325: postpone filter is a body only filter 2009-11-16 13:22:10 +00:00
Igor Sysoev 6726e438b3 align to minimum of a page and a pool sizes 2009-11-16 12:50:10 +00:00
Igor Sysoev ea31a5f0d0 ngx_min() 2009-11-16 12:48:41 +00:00
Igor Sysoev 16d2d705c3 large allocation should not be aligned to a page size 2009-11-16 12:47:44 +00:00
Igor Sysoev 901288f8c0 add alignment in debug log 2009-11-16 12:46:05 +00:00
Igor Sysoev 572e4d890e ngx_http_degradation_module 2009-11-16 12:20:00 +00:00
Igor Sysoev 3c50475589 regex named captures 2009-11-16 12:19:02 +00:00
Igor Sysoev 241de169b9 remove subrequest test in range header, chunked, and header filters: they
are run after postpone filter which sends data only in main request context
2009-11-16 12:13:17 +00:00
Igor Sysoev 82891ea30f allow "proxy_pass http://$backend" without URI part 2009-11-15 11:36:12 +00:00
Igor Sysoev fae7db9ae3 fix posix_fadvise() error handling 2009-11-15 09:16:58 +00:00
Igor Sysoev 2169ef146b update allocation error messages 2009-11-15 09:03:08 +00:00
Igor Sysoev 7448d395ac fix posix_memalign() error handling 2009-11-15 08:56:40 +00:00
Igor Sysoev f50c6bd9fc ngx_regex_exec() calling optimiztion:
*) change NGX_REGEX_NO_MATCHED to PCRE_ERROR_NOMATCH
*) declare ngx_regex_exec() as #define
*) optimize SSI regex a little
2009-11-13 20:41:41 +00:00
Igor Sysoev 72edbfbb36 style fix: lcf > clcf 2009-11-13 19:59:54 +00:00
Igor Sysoev 7ece42d1d4 do not log error if $r->variable was not found 2009-11-12 15:50:34 +00:00
Igor Sysoev 62312c8297 add MSIE padding for Chrome too 2009-11-12 14:24:22 +00:00
Igor Sysoev 777449eb07 r->chrome 2009-11-12 14:23:18 +00:00
Igor Sysoev 78869cac6b test frequent r->header_only before three response status 2009-11-12 13:44:16 +00:00
Igor Sysoev b013fc68ac refactor gzip_vary handling 2009-11-12 13:41:56 +00:00
Igor Sysoev fe58dec9f5 nginx sent gzipped responses to clients those do not support gzip,
if "gzip_static on" and "gzip_vary off"; the bug had been introduced in r3136
2009-11-11 21:12:41 +00:00
Igor Sysoev e79bc93439 bump version 2009-11-11 21:06:36 +00:00
Igor Sysoev b4e0d84c86 release-0.8.24 tag 2009-11-11 14:53:18 +00:00
Igor Sysoev ec6847be39 nginx-0.8.24-RELEASE 2009-11-11 14:53:17 +00:00
Igor Sysoev 120ac6558f remove "Content-Encoding: gzip" in 304 response
sent by ngx_http_gzip_static_module
2009-11-11 14:32:49 +00:00
Igor Sysoev e57dc3e2cd use ngx_resolver_alloc() instead of ngx_resolver_calloc()
since all fields are filled
2009-11-11 14:29:20 +00:00
Igor Sysoev 864ec240a9 fix resolving an empty name (".") 2009-11-11 14:27:24 +00:00
Igor Sysoev b4e71d2ad6 fix "set_real_ip_from unix:" inheritance 2009-11-11 13:41:16 +00:00
Igor Sysoev a14a24b08a fix building without --with-debug, introduced in r3294 2009-11-11 12:32:06 +00:00
Igor Sysoev 1f091b0755 bump version 2009-11-11 12:30:36 +00:00
Igor Sysoev 96685872f2 release-0.8.23 tag 2009-11-11 11:05:23 +00:00
Igor Sysoev b7a0dcf2b6 nginx-0.8.23-RELEASE 2009-11-11 11:05:22 +00:00
Igor Sysoev dd3d898df0 disable SSL renegotiation (CVE-2009-3555) 2009-11-11 10:59:07 +00:00
Igor Sysoev f2db0e7b34 *) fix resolving an empty name ("."),
*) add quotes in an error message,
*) backout r3299 in ngx_mail_smtp_handler.c
2009-11-09 19:15:11 +00:00
Igor Sysoev 0836b35c2d fix "PTR ." case in address resolver 2009-11-09 18:04:05 +00:00
Igor Sysoev 79706060bf fix segfault in resolver:
ngx_resolve_name_done() and ngx_resolve_addr_done() did not delete
contexts from a resolver node waiting list.
2009-11-09 17:45:56 +00:00
Igor Sysoev b47c9ffa1a cf->conf_file->file.name.data may be uninitialized, if an allocation failed;
found by Clang Static Analyzer
2009-11-05 17:10:48 +00:00
Igor Sysoev 33a1975d98 delete useless statement 2009-11-05 17:09:02 +00:00
Igor Sysoev 152504f0c2 export aio presence knowledge to prevent using "aio sendfile",
if aio does not present
2009-11-05 13:12:30 +00:00
Igor Sysoev bfd1a3c03c Fix a bug introduced in r2032: After a child process has read a terminate
message from a channel, the process tries to read the channel again.
The kernel (at least FreeBSD) may preempt the process and sends a SIGIO
signal to a master process. The master process sends a new terminate message,
the kernel switches again to the the child process, and the child process
reads the messages instead of an EAGAIN error. And this may repeat over
and over. Being that the child process can not exit the cycle and test
the termination flag set by the message handler.

The fix disallow the master process to send a new terminate message on
SIGIO signal reception. It may send the message only on SIGALARM signal.
2009-11-04 19:41:08 +00:00
Igor Sysoev 12f76d6832 allow to inherit unix domain sockets while online upgrade 2009-11-04 18:36:43 +00:00
Igor Sysoev ca6e7a42b6 allow to work single "set_real_ip_from unix:" 2009-11-04 11:37:06 +00:00
Igor Sysoev 2a2237f139 bump version 2009-11-04 11:20:54 +00:00
Igor Sysoev 96aea7427c release-0.8.22 tag 2009-11-03 18:52:38 +00:00
Igor Sysoev afd398a099 nginx-0.8.22-RELEASE 2009-11-03 18:52:37 +00:00
Igor Sysoev 2f387509eb fix segfault if there is single large_client_header_buffers
and a request line fills it completely
2009-11-03 18:12:20 +00:00
Igor Sysoev c8312b7e09 posix_fadvise64() had been implemented in Linux 2.5.60 2009-11-03 16:29:47 +00:00
Igor Sysoev da26dde047 use setproctitle("%s", title) 2009-11-03 16:28:21 +00:00
Igor Sysoev 51135fd6d0 fix segfault if no rules are defined, introduced in r3279 2009-11-03 16:04:07 +00:00
Igor Sysoev 0c73f1c6dc fix segfault in SSL if limit_rate is used 2009-11-03 15:38:33 +00:00
Igor Sysoev d9946897aa fix segfault if $limit_rate was logged 2009-11-03 15:05:38 +00:00
Igor Sysoev e16b14bcd4 fix "if (!-x ...)" 2009-11-03 14:57:27 +00:00
Igor Sysoev 98a524f8b9 fix directive name in error message: "set_realip_from" to "set_real_ip_from" 2009-11-03 14:41:56 +00:00
Igor Sysoev cb70a07432 fix directive name in error message: "realip_from" to "set_realip_from" 2009-11-03 13:45:22 +00:00
Igor Sysoev b6143dacae IPv6 support in ngx_http_access_module 2009-11-03 13:42:45 +00:00
Igor Sysoev 21d080bbf9 ngx_ptocidr() supports IPv6 2009-11-03 13:42:25 +00:00
Igor Sysoev a9c848d7b1 make ngx_inet6_ntop() non-static 2009-11-03 12:44:55 +00:00
Igor Sysoev aba252b4d4 optimize some cycles:
*) delete surplus variable;
*) on i386/amd64 "while (n) / n--" is smaller than "while (n--)",
   because the platforms have no postfix operations
2009-11-02 17:12:09 +00:00
Igor Sysoev 04e0208608 set_real_ip_from unix: 2009-11-02 16:46:07 +00:00
Igor Sysoev 43cf5e6fd8 support IPv6 addresses in Real IP headers 2009-11-02 16:24:27 +00:00
Igor Sysoev eff6a4b08c change ngx_parse_addr() interface 2009-11-02 16:11:06 +00:00
Igor Sysoev 328c1a11b5 proxy_bind, fastcgi_bind, and memcached_bind 2009-11-02 15:24:02 +00:00
Igor Sysoev af3ab6a42d ngx_parse_addr() 2009-11-02 15:20:42 +00:00
Igor Sysoev 3f26bb637b rename ngx_peer_addr_t to ngx_addr_t 2009-11-02 15:14:17 +00:00
Igor Sysoev 7194f99ae5 use sin6_addr.s6_addr instead of "(u_char *) & .sin6_addr" 2009-11-02 14:32:46 +00:00
Igor Sysoev 1c068187ae replace inet_addr() with ngx_inet_addr() 2009-11-02 13:51:10 +00:00
Igor Sysoev ab6bce4d62 use ngx_inet6_addr() 2009-11-02 12:58:30 +00:00
Igor Sysoev 556a6d8758 ngx_inet6_addr() 2009-11-02 12:50:00 +00:00
Igor Sysoev 27e4420f7c style fix 2009-11-02 12:41:56 +00:00
Igor Sysoev beed596292 delete unused field c->local_socklen 2009-11-01 19:29:49 +00:00
Igor Sysoev b126ba528d remove a broken 0.1.x to 0.2+ upgrade procedure 2009-10-30 19:42:12 +00:00
Igor Sysoev 68229407ec do not unlink unix domain socket file while online upgrade 2009-10-30 19:18:21 +00:00
Igor Sysoev 1d70f24717 unlink unix domain socket file after testing 2009-10-30 19:16:50 +00:00
Igor Sysoev fbfff592d0 fix segfaults if no listen directive was set in default server {} block:
ngx_http_add_listen() uses server's connection_pool_size and
client_header_timeout values, therefore it must be called after
the values have been merged, the bug had been introduced in r3218
2009-10-29 15:53:50 +00:00
Igor Sysoev e9a86ece98 style fix 2009-10-28 10:47:00 +00:00
Igor Sysoev 10d7ffb402 fix segfault if http {} block is empty, the bug had been introduced in r3218 2009-10-28 10:45:40 +00:00
Igor Sysoev 7d6f92be00 bump version 2009-10-28 10:31:06 +00:00
Igor Sysoev 7f478e0630 release-0.8.21 tag 2009-10-26 14:09:26 +00:00
Igor Sysoev 0b26c7153b nginx-0.8.21-RELEASE 2009-10-26 14:09:25 +00:00
Igor Sysoev 084aa41f44 fix r3211 2009-10-26 12:00:37 +00:00
Igor Sysoev 5a3b8ba4bb http listen unix domain sockets 2009-10-26 11:43:32 +00:00
Igor Sysoev 136dc062a8 fix r3225 and r3227: preserve default_server bit during listen options
overwriting
2009-10-22 10:17:54 +00:00
Igor Sysoev 4300aabb91 do not run regex for empty host name since regex always fails in this case,
the bug had been introduced in r2196
2009-10-22 09:48:42 +00:00
Igor Sysoev 7329f87195 test a duplicate listen in a server 2009-10-22 08:15:16 +00:00
Igor Sysoev c08d08988d fix r3225: it overrode the listen options by default server default options 2009-10-22 08:14:02 +00:00
Igor Sysoev 55d772a207 listen default_server parameter 2009-10-21 19:18:50 +00:00
Igor Sysoev dddbdb293f allow to set listen options in any server 2009-10-21 19:16:38 +00:00
Igor Sysoev f0cf92c39b add listen address in error message 2009-10-21 19:13:27 +00:00
Igor Sysoev 911b118ad5 use lowcase only hostname 2009-10-21 17:04:13 +00:00
Igor Sysoev b0c029db2e rename core_srv_conf fields to more understandable default_server and server 2009-10-21 16:52:10 +00:00
Igor Sysoev c4c811a390 *) move sockaddr to the listen options
*) rename ngx_http_listen_t to ngx_http_listen_opt_t
2009-10-21 16:47:44 +00:00
Igor Sysoev 82649a7014 fix r3218:
Initially building lists of ports, addresses, and server names had been
placed at final configuration stage, because complete set of the "listen"s
and the "server_names" were required for this operation. r3218 broke it,
because the "listen"s go usually first in configuration, and
cscf->server_names is empty at this stage, therefore no virtual names
were configured.

Now server configurations are stored in array for each address:port
to configure virtual names. Also regex captures flag is moved from
server names to core server configuration.
2009-10-21 16:27:48 +00:00
Igor Sysoev 953b792f9f refactor http listen code: remove duplicate options fields 2009-10-21 08:48:04 +00:00
Igor Sysoev 0e746b5fe3 refactor http listen code:
*) add listen's to the global cmcf->ports array instead of server's one
*) rename ngx_http_listen_conf_t to ngx_http_listen_opt_t
2009-10-21 08:19:46 +00:00
Igor Sysoev 57d9977593 fix two previous commits: an early parallel body discarding completion
disables incomplete ngx_http_writer()
2009-10-20 11:48:28 +00:00
Igor Sysoev 34291eede6 allow discarding body while a long response transfer 2009-10-19 16:13:38 +00:00
Igor Sysoev c611788bf6 restore discard body handler after ngx_http_set_writer() set it to
ngx_http_test_reading(), the bug was introduced in r3050
2009-10-19 16:12:13 +00:00
Igor Sysoev 0f682303e1 fix ngx_http_finalize_request() code after a body has been discarded 2009-10-19 16:06:57 +00:00
Igor Sysoev 1960ffb1e5 prevent handling discarded body as a pipelined request 2009-10-19 14:08:35 +00:00
Igor Sysoev e2ceea31ed add lingering timeout if a response is short and a request body is being
discarded, the bug was introduced in r3050
2009-10-19 14:08:09 +00:00
Igor Sysoev 44f43e3676 add SNI support in -V output 2009-10-19 12:35:01 +00:00
Igor Sysoev 4a4cf37c5b fix typo 2009-10-19 12:33:09 +00:00
Igor Sysoev 4a09fbf4f3 ngx_http_parse_time() should support full 32-bit time 2009-10-15 13:19:34 +00:00
Igor Sysoev 0459b338ae use ngx_uint_t instead of int,
strange to say this reduce function size by 16 bytes
2009-10-15 13:09:58 +00:00
Igor Sysoev 2aa3c016b0 bump version 2009-10-15 13:01:42 +00:00
Igor Sysoev 2e0f91279b release-0.8.20 tag 2009-10-14 12:57:26 +00:00
Igor Sysoev 4e94fe1631 nginx-0.8.20-RELEASE 2009-10-14 12:57:25 +00:00
Igor Sysoev 9f5117c645 update r3201: ngx_http_random_index_module should behave consistently
in spite of the dirent.d_type presence
2009-10-14 12:39:41 +00:00
Igor Sysoev 832500ff82 ignore EACCES errors for top level directories in ngx_create_full_path() 2009-10-14 11:46:09 +00:00
Igor Sysoev 5371898ba2 do not create Win32 drive letter in ngx_create_full_path() 2009-10-14 11:36:16 +00:00
Igor Sysoev 6d3af5b69b *) reset cached dirent.d_type after stat()
this fixes slash after link to a directory in ngx_http_autoindex_module;
*) use cached dirent.d_type as hint on all systems

the issues has been introduced in r2235
2009-10-14 11:33:35 +00:00
Igor Sysoev e357ac62d1 nginx did not close log file set by --error-log-path,
the bug was introduced in r2744
2009-10-09 14:43:09 +00:00
Igor Sysoev 5cf5131725 test comma separator in "Cache-Control" 2009-10-08 14:22:00 +00:00
Igor Sysoev 688426595e hide cacheable Set-Cookie and P3P FastCGI response headers 2009-10-07 15:15:41 +00:00
Igor Sysoev 03b930b4a7 use only strong ciphers by default 2009-10-07 14:46:13 +00:00
Igor Sysoev 1eb07cc5a7 use real file cache length, this fixes cache size counting for responses
without "Content-Length" header and 304 responses.
2009-10-07 12:55:58 +00:00
Igor Sysoev a1575e77b9 bump version 2009-10-07 12:48:05 +00:00
Igor Sysoev 6c05f31567 release-0.8.19 tag 2009-10-06 16:19:43 +00:00
Igor Sysoev ba09a8dab0 nginx-0.8.19-RELEASE 2009-10-06 16:19:42 +00:00
Igor Sysoev f99c3ac6ad fix r3184 2009-10-06 16:08:15 +00:00
Igor Sysoev 7c00ea743e disable SSLv2 and low ciphers by default 2009-10-06 14:24:53 +00:00
Igor Sysoev bbc8096382 bump version 2009-10-06 13:52:26 +00:00
Igor Sysoev 279b55f208 release-0.8.18 tag 2009-10-06 12:44:51 +00:00
Igor Sysoev e0bd2ffb45 nginx-0.8.18-RELEASE 2009-10-06 12:44:50 +00:00
Igor Sysoev b4fa957f5d limit_conn_log_level 2009-10-06 10:14:29 +00:00
Igor Sysoev 62ceeca882 limit_req_log_level 2009-10-06 10:14:21 +00:00
Igor Sysoev 669682f3b0 fix building by gcc45 2009-10-06 09:46:16 +00:00
Igor Sysoev ab8819282d make limit_req to conform to the leaky bucket algorithm 2009-10-06 09:37:18 +00:00
Igor Sysoev 0feac5d304 omit '\0' from "Location" header on MKCOL request 2009-10-06 09:32:21 +00:00
Igor Sysoev 82a641b2b2 clear r->lingering_close to disable preventively calling
ngx_http_set_lingering_close() while request cleanup
2009-10-02 11:32:56 +00:00
Igor Sysoev c1f49cc1bf clear r->keepalive to disable preventively calling
ngx_http_set_keepalive() while request cleanup
2009-10-02 11:30:47 +00:00
Igor Sysoev da861a9d6b update r3167: do not set r->discard_body if the body has been just discarded 2009-10-02 09:46:04 +00:00
Igor Sysoev 38f83a56bb read_ahead 2009-09-30 13:21:52 +00:00
Igor Sysoev 3eeeddb17d Linux/SPARC malloc() returns an address aligned to 8. This conflicts with
our SPARC 16-byte alignment and some allocations may be done out of pool.
ngx_memalign(ngx_pagesize) fixes this issue.
2009-09-30 12:56:44 +00:00
Igor Sysoev 52f53f5a89 log 499 instead 0, the bug was introduced in r3050 2009-09-30 12:05:08 +00:00
Igor Sysoev 56175447e1 allow several perl_modules 2009-09-30 11:46:01 +00:00
Igor Sysoev 74ba9acbf0 use ngx_conf_set_str_array_slot() for perl_require 2009-09-28 16:07:14 +00:00
Igor Sysoev af20ad9b94 optimize error handling 2009-09-28 15:57:28 +00:00
Igor Sysoev a7e20e9ae4 bump version 2009-09-28 15:56:28 +00:00
Igor Sysoev 954dd87d42 release-0.8.17 tag 2009-09-28 13:08:10 +00:00
Igor Sysoev f1ee1efa1a nginx-0.8.17-RELEASE 2009-09-28 13:08:09 +00:00
Igor Sysoev 7cd2c4569a fix request counter in resolver handling, the bug was introduced in r3050 2009-09-28 12:31:47 +00:00
Igor Sysoev 4c0fe89b52 allow "make clean" for OpenSSL, the bug was introduced in r2874 2009-09-28 12:24:09 +00:00
Igor Sysoev 57338e1c39 we do not need to increase request counter in this place,
the bug had appeared in r3115
2009-09-28 11:12:45 +00:00
Igor Sysoev 36931c954c fix r3078: do not increase request counter if body has been just discarded 2009-09-26 13:24:15 +00:00
Igor Sysoev 16def50dcd use parents around NGX_ATOMIC_T_LEN value 2009-09-25 20:25:47 +00:00
Igor Sysoev c55184f023 uniform ngx_directio_on/off() interface with other file functions 2009-09-25 14:17:28 +00:00
Igor Sysoev 3629664881 handle short pwrite() to log an error cause: ENOSPC, EDQUOT, or EFBIG 2009-09-25 13:55:46 +00:00
Igor Sysoev 03f5b99e8f fix discarding body 2009-09-25 11:55:33 +00:00
Igor Sysoev f774310fb2 check unsafe Destination 2009-09-25 09:30:06 +00:00
Igor Sysoev 0219125f74 low ENAMETOOLONG logging level 2009-09-25 09:13:08 +00:00
Igor Sysoev 674aae5596 fix r3155 2009-09-24 20:09:12 +00:00
Igor Sysoev f203d9a2dd test incomplete WriteFile() 2009-09-24 20:05:21 +00:00
Igor Sysoev 22f02ef444 log file name for read/write errors 2009-09-24 20:04:10 +00:00
Igor Sysoev 2de155129f delete Win95 code 2009-09-24 19:55:35 +00:00
Igor Sysoev 585300cc3b fix debug log message 2009-09-24 14:47:10 +00:00
Igor Sysoev e996d64b80 $ssl_session_id 2009-09-24 14:45:28 +00:00
Igor Sysoev 5b9b51d058 update the previous commit: use ngx_strlow() 2009-09-24 13:23:25 +00:00
Igor Sysoev a54e87ba58 $host is always in low case:
*) move low case convertation from ngx_http_find_virtual_server()
   to ngx_http_validate_host()
*) add in ngx_http_validate_host() capability to copy host name in the pool
   allocated memory
2009-09-24 13:15:50 +00:00
Igor Sysoev 39a88d570c low default connection errors level from alert to error 2009-09-23 15:28:33 +00:00
Igor Sysoev a3f0bc2dca bump version 2009-09-23 15:27:17 +00:00
Igor Sysoev 2024db8434 release-0.8.16 tag 2009-09-22 14:35:22 +00:00
Igor Sysoev 6e58458536 nginx-0.8.16-RELEASE 2009-09-22 14:35:21 +00:00
Igor Sysoev 4b09c07edd fail if file size was changed 2009-09-22 09:44:57 +00:00
Igor Sysoev b5fe12fc54 fix typo in addition_types directive name 2009-09-22 09:06:15 +00:00
Igor Sysoev 4a2799b5bf fix request counter for post_action, the bug was introduced in r3050 2009-09-21 18:34:22 +00:00
Igor Sysoev 7cb0e98803 allow to log invalid $request in access_log always,
before it was logged only if error_log was set to info or debug level
2009-09-21 15:55:56 +00:00
Igor Sysoev 8c150cba15 fix resolver cache rbtree comparison 2009-09-19 16:15:13 +00:00
Igor Sysoev 3b3b8717c8 restore environ, this fixes segfault on reconfiguration failure when
perl module creates new environment
2009-09-18 09:21:14 +00:00
Igor Sysoev fdbadce11c fix comment 2009-09-18 09:12:40 +00:00
Igor Sysoev 0f8436cb3c *) issue warning instead of failure: this is too common case
*) use ngx_log_error(), since OpenSSL does not set an error on the failure
2009-09-18 09:10:16 +00:00
Igor Sysoev 5ca259f7a1 fix memory leak in resolver 2009-09-16 13:48:11 +00:00
Igor Sysoev bb161c9190 win32 ngx_file_info() utf8 support 2009-09-16 13:30:13 +00:00
Igor Sysoev 66d84fb497 preserve errno while ngx_free() 2009-09-16 13:28:20 +00:00
Igor Sysoev 9645217922 do not pass buf with empty cached response,
this fixes "zero size buf in output" alert
2009-09-15 15:12:03 +00:00
Igor Sysoev 7aeea86d84 nginx always sent "Vary: Accept-Encoding",
if both gzip_static and gzip_vary were on
2009-09-15 11:57:29 +00:00
Igor Sysoev b9142139b2 image_filter_transparency 2009-09-15 11:55:17 +00:00
Igor Sysoev acb4e8fa4c fix alpha-channel transparency in PNG 2009-09-15 09:47:12 +00:00
Igor Sysoev bbb7f62992 allow perl "sub{..." 2009-09-15 09:37:16 +00:00
Igor Sysoev 16555b4bb3 bump version 2009-09-15 09:36:09 +00:00
Igor Sysoev f69b05e9cd release-0.8.15 tag 2009-09-14 13:07:18 +00:00
Igor Sysoev b17cb34b7e nginx-0.8.15-RELEASE 2009-09-14 13:07:17 +00:00
Igor Sysoev 8600cd7cbf test space between "~" and regex in server_name and invalid_referers 2009-09-14 09:48:48 +00:00
Igor Sysoev 2780b6716f handle "/../" case more reliably 2009-09-14 07:42:01 +00:00
Igor Sysoev 56d294cb36 fix request counter for X-Accel-Redirect, the bug was introduced in r3050 2009-09-13 13:45:32 +00:00
Igor Sysoev ce0855993c fix case when the output filter should add incoming buffers
while waiting on file AIO completion
2009-09-13 06:28:17 +00:00
Igor Sysoev ab0034ef90 style fix 2009-09-13 06:25:54 +00:00
Igor Sysoev ed3943c469 fix transparency in GIF 2009-09-12 09:46:28 +00:00
Igor Sysoev 27aea8e769 If .domain.com, .sub.domain.com, and .domain-some.com were defined,
then .sub.domain.com was matched by .domain.com: wildcard names hash
was built incorrectly due to sorting order issue of "." vs "-".
They were sorted as
    com.domain  com.domain-some  com.domain.sub
while they should be sorted as
    com.domain  com.domain.sub   com.domain-some
for correct hash building
2009-09-12 09:28:37 +00:00
Igor Sysoev 38d9491169 style fix 2009-09-11 13:57:50 +00:00
Igor Sysoev a40b803413 fix request counter for rewrite or internal redirection cycle,
the bug was introduced in r3050
2009-09-10 16:34:09 +00:00
Igor Sysoev fc3b7088f8 fail if no file aio was found 2009-09-10 12:08:30 +00:00
Igor Sysoev 2cb1f9c44c increase request counter before an upstream cleanup because the cleanup
decreases the counter via ngx_http_finalize_request(r, NGX_DONE),
the bug was introduced in r3050
2009-09-08 11:37:50 +00:00
Igor Sysoev 7aecf9eb35 fix request counter handling in perl module for $r->internal_redirect()
and $r->has_request_body(), the bug was introduced in r3050
2009-09-08 11:33:32 +00:00
Igor Sysoev fc9404e1d9 do not pass incoming buf chain twice if data are ready,
the bug was introduced in r3072
2009-09-07 12:10:07 +00:00
Igor Sysoev b72ec2f8fd bump version 2009-09-07 12:08:58 +00:00
Igor Sysoev 2c40e73ae0 release-0.8.14 tag 2009-09-07 08:25:46 +00:00
Igor Sysoev f9ad8f6902 nginx-0.8.14-RELEASE 2009-09-07 08:25:45 +00:00
Igor Sysoev f4c28a108f fix the previous commit 2009-09-04 18:51:17 +00:00
Igor Sysoev c8e1886c35 preload just a single byte to avoid testing file overrun 2009-09-04 16:59:23 +00:00
Igor Sysoev add85d5506 clean cache updating state if a response has uncacheable code or
cache prohibitive headers
2009-09-04 09:57:38 +00:00
Igor Sysoev 0ce7f4ff37 fix request counter handling for perl handler, introduced in r3050 2009-09-04 09:54:16 +00:00
Igor Sysoev 8f8f9c00d5 log offset passed to sendfile() 2009-09-04 09:53:09 +00:00
Igor Sysoev c1a47a7d14 small optimization 2009-09-04 09:50:58 +00:00
Igor Sysoev 683ddf4866 discrease slightly ngx_http_parse_header_line() size:
this line is not required for LF, however, this case is very seldom
2009-09-02 07:02:49 +00:00
Igor Sysoev 36d8fd81b9 discard request body before returning 413 error,
this fixes custom 413 page redirection bug introduced in r1456
2009-09-01 12:47:34 +00:00
Igor Sysoev 96b44e1bfb fix request counter handling while discarding body, introduced in r3050 2009-09-01 12:40:27 +00:00
Igor Sysoev bb5c3b7b73 use %*s instead of %V 2009-09-01 12:35:52 +00:00
Igor Sysoev d77c42a16a fix segfault when a header starts with "\rX"
and logging is set to info or debug level
2009-09-01 12:32:37 +00:00
Igor Sysoev 02e136d3b5 bump version 2009-09-01 12:07:00 +00:00
Igor Sysoev 24aabeaf03 release-0.8.13 tag 2009-08-31 15:02:37 +00:00
Igor Sysoev 3316eae4c1 nginx-0.8.13-RELEASE 2009-08-31 15:02:36 +00:00
Igor Sysoev 8ca38f6248 retry aio sendfile if data are ready 2009-08-31 14:00:16 +00:00
Igor Sysoev aa266affa1 fix building on FreeBSD without --with-file-aio 2009-08-31 13:51:13 +00:00
Igor Sysoev b7b77c3d2e bump version 2009-08-31 13:50:37 +00:00
Igor Sysoev 00843c2117 release-0.8.12 tag 2009-08-31 11:32:17 +00:00
Igor Sysoev 1ee066dfe5 nginx-0.8.12-RELEASE 2009-08-31 11:32:16 +00:00
Igor Sysoev 2728c0673f fix request counter handling for try_files, introduced in r3050 2009-08-31 11:21:04 +00:00
Igor Sysoev ac0738c727 aio sendfile 2009-08-30 09:52:39 +00:00
Igor Sysoev 047dd9221f *) ngx_http_ephemeral
*) use preallocated terminal_posted_request
2009-08-30 09:47:11 +00:00
Igor Sysoev f7a065f3cc refactor EAGAIN/EINTR processing 2009-08-30 09:42:29 +00:00
Igor Sysoev 4ba390c27a use local variable and fix debug log message 2009-08-29 18:42:31 +00:00
Igor Sysoev 9edbc5f15a fix request counter for memcached, introduced in r3050 2009-08-29 18:40:28 +00:00
Igor Sysoev bf1cd619c4 bump version 2009-08-29 18:39:32 +00:00
Igor Sysoev 7ba0460a11 release-0.8.11 tag 2009-08-28 13:21:07 +00:00
Igor Sysoev 4b58c424fb nginx-0.8.11-RELEASE 2009-08-28 13:21:06 +00:00
Igor Sysoev 09b4b25b45 fix build by msvc, introduced in r3054 2009-08-28 11:46:12 +00:00
Igor Sysoev 21e795c0cb do not create cache key in AIO invocation 2009-08-28 11:23:50 +00:00
Igor Sysoev d4098ed5af fix sending a cached file using AIO 2009-08-28 11:22:27 +00:00
Igor Sysoev e849ebecbf do not disable gzip for MSIE 6.0 SV1 in "gzip_disable msie6" 2009-08-28 08:19:02 +00:00
Igor Sysoev 1df9c8bb1f directio_alignment 2009-08-28 08:15:55 +00:00
Igor Sysoev 6ae55a7a8f FreeBSD and Linux AIO support 2009-08-28 08:12:35 +00:00
Igor Sysoev 1f2d427a5a style fix 2009-08-28 07:50:45 +00:00
Igor Sysoev efe229f72f axe r->connection->destroyed testing 2009-08-26 16:14:57 +00:00
Igor Sysoev 8f4cc60ca3 request reference counter 2009-08-26 16:04:05 +00:00
Igor Sysoev ad3d1e2d49 twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
and SIGIO signals quickly increase delay to the level when SIGKILL is sent
2009-08-26 15:12:28 +00:00
Igor Sysoev 4906bcc5c0 style fix 2009-08-26 15:09:09 +00:00
Igor Sysoev 4bfa9c2a25 fix typo 2009-08-26 15:03:53 +00:00
Igor Sysoev cca6badcce ignore SIGSYS 2009-08-26 05:19:57 +00:00
Igor Sysoev 879f37db1a *) move small declarations in appropriate places and delete the surplus
header files
*) delete insignificant comments
2009-08-25 09:09:13 +00:00
Igor Sysoev b74d0828eb style fix 2009-08-25 09:06:21 +00:00
Igor Sysoev 10e5dbf3bc bump version 2009-08-25 08:47:58 +00:00
Igor Sysoev cb8d108a53 release-0.8.10 tag 2009-08-24 11:10:37 +00:00
Igor Sysoev 2e11b681bd nginx-0.8.10-RELEASE 2009-08-24 11:10:36 +00:00
Igor Sysoev 861ed123ea fix Linux "uname -r" version matching 2009-08-24 11:04:46 +00:00
Igor Sysoev 9a2fa68d46 strict testing "access_log off" 2009-08-23 17:06:33 +00:00
Igor Sysoev ec4e1e246c process upstream ETag header 2009-08-23 16:10:39 +00:00
Igor Sysoev b1075ac09b the flags should be bit-wide only 2009-08-23 12:58:41 +00:00
Igor Sysoev e39382a9f5 *) share temporary number between workers
*) randomize collision offset
2009-08-21 09:06:35 +00:00
Igor Sysoev 44b492b961 test EXDEV after path creation 2009-08-20 15:53:57 +00:00
Igor Sysoev e5fd73a2c1 fix copy failure logging and stale files removal, introduced in r3025 2009-08-20 13:41:32 +00:00
Igor Sysoev a946793b04 fix copy destination name length, introduced in r3025 2009-08-20 13:37:26 +00:00
Igor Sysoev 6274328a49 fix memory leak if GeoIP City database was used 2009-08-19 17:44:33 +00:00
Igor Sysoev d111c9738f bump version 2009-08-19 09:09:12 +00:00
Igor Sysoev 6e76a0c27c release-0.8.9 tag 2009-08-17 17:59:57 +00:00
Igor Sysoev 893da85efc nginx-0.8.9-RELEASE 2009-08-17 17:59:56 +00:00
Igor Sysoev 66cdc9c036 fix building on 64-bit platforms, introduced in r3025 2009-08-13 13:48:41 +00:00
Igor Sysoev 1566757897 fix debug point for left open sockets 2009-08-13 08:40:25 +00:00
Igor Sysoev 55b58a744e refactor fastcgi stderr handling 2009-08-12 14:38:44 +00:00
Igor Sysoev 56c6e01f77 allow cross device temporary files atomic copying:
*) ngx_copy_file()
*) delete ngx_ext_rename_file_t.log_rename_error and .rename_error fields
2009-08-12 12:05:33 +00:00
Igor Sysoev 2980e4b813 NGX_ENOPATH 2009-08-11 14:25:04 +00:00
Igor Sysoev b54f778f30 win32 cache loader support 2009-08-11 08:14:43 +00:00
Igor Sysoev 3efbe81b91 style fix 2009-08-11 07:55:39 +00:00
Igor Sysoev b4d15b0fe7 unlock incompletely loaded cache 2009-08-10 15:57:42 +00:00
Igor Sysoev 403c28f9d7 delete mistaken sleep in the previous commit 2009-08-10 14:45:52 +00:00
Igor Sysoev 3f34af3bcc cache loader process 2009-08-10 13:27:14 +00:00
Igor Sysoev 02e4312888 test cache path levels while reconfiguration 2009-08-10 13:18:40 +00:00
Igor Sysoev 756a8387fc introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly 2009-08-10 13:07:15 +00:00
Igor Sysoev 1b1967a383 bump version 2009-08-10 12:49:06 +00:00
Igor Sysoev 6052a85699 release-0.8.8 tag 2009-08-10 08:26:28 +00:00
Igor Sysoev 8f1135c40a nginx-0.8.8-RELEASE 2009-08-10 08:26:27 +00:00
Igor Sysoev 781c4595a9 fix segfault introduced in r3007 2009-08-07 13:16:42 +00:00
Igor Sysoev 31a2949d21 fix a garbage in a split fastcgi header 2009-08-04 12:19:17 +00:00
Igor Sysoev 899ba0a82a continue to parse available fastcgi record after a split header,
this fixes the erroneous message "upstream prematurely closed connection
while reading response header from upstream"
2009-08-04 11:51:10 +00:00
Igor Sysoev fde40de45e bump version 2009-07-31 12:41:02 +00:00
Igor Sysoev ba50292546 release-0.8.7 tag 2009-07-27 15:24:02 +00:00
Igor Sysoev 67ae72b15c nginx-0.8.7-RELEASE 2009-07-27 15:24:01 +00:00
Igor Sysoev 23ed5215b3 ngx_http_upstream_create() to cleanup the previous upstream after
internal redirect
2009-07-27 13:25:29 +00:00
Igor Sysoev 43042aaed6 clear "Accept-Ranges" for SSI responses 2009-07-27 13:18:40 +00:00
Igor Sysoev be626636e8 fix handling "Last-Modified" and "Accept-Ranges" for upstream responses 2009-07-27 13:14:45 +00:00
Igor Sysoev 3b483ac151 allow to proxy_pass_header/fastcgi_pass_header "X-Accel-Redirect",
"X-Accel-Limit-Rate", "X-Accel-Buffering", and "X-Accel-Charset"
2009-07-27 12:06:12 +00:00
Igor Sysoev 9017dd7071 fix memory corruption in $ssl_client_cert 2009-07-27 11:51:12 +00:00
Igor Sysoev 34babb0f7b fix return value 2009-07-27 11:04:28 +00:00
Igor Sysoev a3dbeb661d fix segfault if 400 or 414 errors are handled intricately 2009-07-24 19:20:29 +00:00
Igor Sysoev 8b3212e2ec fix libxml2 error message 2009-07-24 13:32:41 +00:00
Igor Sysoev 707b3b9c26 variables support in image_filter 2009-07-23 13:14:58 +00:00
Igor Sysoev ebece66ba7 delete ancient define 2009-07-23 12:59:11 +00:00
Igor Sysoev 4065d9b81e delete OpenSSL pre-0.9.7 compatibility: the sources were not actually
compatible with OpenSSL 0.9.6 since ssl_session_cache introduction
2009-07-23 12:54:20 +00:00
Igor Sysoev 148a9f2728 ssl_crl 2009-07-23 12:21:26 +00:00
Igor Sysoev 93eb5d0d07 *) $ssl_client_verify
*) "ssl_verify_client ask" was changed to "ssl_verify_client optional"
2009-07-22 17:41:42 +00:00
Igor Sysoev b316011ab5 fix r2972, it caused "zero size buf" alert. 2009-07-22 13:06:27 +00:00
Igor Sysoev fa12a7338b geo module supports trusted proxies 2009-07-22 09:43:14 +00:00
Igor Sysoev 8240c35f1a fix help message 2009-07-21 13:27:19 +00:00
Igor Sysoev bcecbd9d23 do not test "..." case since it's Win9x family feature only 2009-07-20 12:23:04 +00:00
Igor Sysoev f29f295e74 do auto redirect for proxy_pass/fastcgi_pass with variables 2009-07-20 11:44:38 +00:00
Igor Sysoev 206c370fda bump version 2009-07-20 11:43:15 +00:00
Igor Sysoev db9f52ca93 release-0.8.6 tag 2009-07-20 08:24:32 +00:00
Igor Sysoev eed46ffd11 nginx-0.8.6-RELEASE 2009-07-20 08:24:31 +00:00
Igor Sysoev 83a626137c ngx_http_geoip_module 2009-07-20 07:10:43 +00:00
Igor Sysoev f07b03129e preserve XML wellFormed field before freeing memory 2009-07-17 08:04:52 +00:00
Igor Sysoev 0f4a796463 style fix 2009-07-15 14:50:51 +00:00
Igor Sysoev d4e29865c1 name of file specified in --conf-path was not honored during installation
the bug had been appeared in r1353
2009-07-14 09:41:18 +00:00
Igor Sysoev 629fee53b6 use caseless regex locations on caseless filesystems: MacOSX, Win32, Cygwin 2009-07-14 08:53:37 +00:00
Igor Sysoev 3dec9bfc1f skip URI trailing dots under Win32 2009-07-14 08:51:20 +00:00
Igor Sysoev b48093291a ngx_http_set_exten() is always successful since 0.3.46 2009-07-14 08:38:28 +00:00
Igor Sysoev 0f9733506d bump version 2009-07-14 08:18:38 +00:00
Igor Sysoev fe37a17934 release-0.8.5 tag 2009-07-13 11:48:00 +00:00
Igor Sysoev 8362511b1f nginx-0.8.5-RELEASE 2009-07-13 11:47:59 +00:00
Igor Sysoev 17d53c6b95 allow underscore in request method 2009-07-13 09:33:34 +00:00
Igor Sysoev 6b5ecddc08 handle Win32 ReadFile() EOF state in Unix way 2009-07-13 09:32:49 +00:00
Igor Sysoev c49fd6f714 style fix 2009-07-09 14:03:12 +00:00
Igor Sysoev 4539fc985a fix client write event handling in ngx_http_limit_req_module 2009-07-09 14:02:09 +00:00
Igor Sysoev 8bddeb6f2e fix ngx_http_send_special() for subrequests handled by perl 2009-07-09 13:32:51 +00:00
Igor Sysoev 5b8c2ba857 bump version 2009-07-09 13:20:51 +00:00
Igor Sysoev f5a2b068bc release-0.8.4 tag 2009-06-22 09:17:25 +00:00
Igor Sysoev cf8844cfb6 nginx-0.8.4-RELEASE 2009-06-22 09:17:24 +00:00
Igor Sysoev a2912b2875 fix building --without-http-cache, broken in r2953 2009-06-22 09:10:50 +00:00
Igor Sysoev 517650cd3e bump version 2009-06-22 08:59:48 +00:00
Igor Sysoev b608f62359 release-0.8.3 tag 2009-06-19 10:56:36 +00:00
Igor Sysoev 2b44f40ab6 nginx-0.8.3-RELEASE 2009-06-19 10:56:35 +00:00
Igor Sysoev e397c4aa92 fix segfault if there is error_page 401, proxy_intercept_errors is on
and backend does not return "WWW-Authenticate" header
2009-06-18 14:28:50 +00:00
Igor Sysoev f0e2dfe24f $upstream_cache_status 2009-06-18 13:34:47 +00:00
Igor Sysoev ac926cf9d1 ignore ngx_atomic_fetch_add() result
this fixes building at least by gcc 4.2.1 on Mac OS X 10.6
2009-06-18 13:14:51 +00:00
Igor Sysoev 27bbe3ef50 fix ./configure error message 2009-06-18 13:01:05 +00:00
Igor Sysoev 8033be0e94 fix building --without-http-cache, broken in r2930 2009-06-15 14:25:08 +00:00
Igor Sysoev 0822906e29 bump version 2009-06-15 14:22:20 +00:00
Igor Sysoev bedddd4ec6 release-0.8.2 tag 2009-06-15 08:15:12 +00:00
Igor Sysoev f1b1ca006c nginx-0.8.2-RELEASE 2009-06-15 08:15:11 +00:00
Igor Sysoev 6fd9878b5d add response file uniq while loading cold cache on demand 2009-06-12 20:32:42 +00:00
Igor Sysoev e6e748db0a initialize use_event field in open file cache
the bug had been introduced in r2071
2009-06-12 14:23:29 +00:00
Igor Sysoev 37d0ec0eb5 style fix 2009-06-11 05:51:37 +00:00
Igor Sysoev ba537094fc bump version 2009-06-10 11:46:34 +00:00
Igor Sysoev 70c3ec8efa release-0.8.1 tag 2009-06-08 12:55:50 +00:00
Igor Sysoev 72f1f96715 nginx-0.8.1-RELEASE 2009-06-08 12:55:49 +00:00
Igor Sysoev 15462ba9b7 inherit proxy_set_header, proxy_hide_header, and fastcgi_hide_header
only if cache settings are similar
2009-06-08 12:33:11 +00:00
Igor Sysoev 234be393c1 update r2925 2009-06-07 18:22:58 +00:00
Igor Sysoev 24ad43fb00 proxy_cache_use_stale/fastcgi_cache_use_stale updating 2009-06-06 18:49:47 +00:00
Igor Sysoev 34dbc704c3 delete useless r->cache->uses 2009-06-06 17:48:54 +00:00
Igor Sysoev fbcb805295 remove remnants 2009-06-06 14:13:49 +00:00
Igor Sysoev 05e1e263c7 win32 master process had aready closed listening sockets 2009-06-06 12:53:55 +00:00
Igor Sysoev dd0d5fba54 a signaller process should stop configuration processing just after
it is able to get pid file, this allows to not open log files, etc.
2009-06-06 12:41:31 +00:00
Igor Sysoev e3dfe78e79 *) exit if no workers could not be started
*) do not quit old workers if no new workers could not be started
2009-06-06 12:36:44 +00:00
Igor Sysoev 1f3306cf61 fix debug logging 2009-06-05 17:44:49 +00:00
Igor Sysoev fba28d6726 do not test a pool block space if we can not allocated from the block 4 times 2009-06-05 13:27:12 +00:00
Igor Sysoev 22373a503a change surplus for() to while() 2009-06-05 12:33:49 +00:00
Igor Sysoev 94605ebb2f test GIF87a 2009-06-05 07:29:47 +00:00
Igor Sysoev 5addd428b5 try to reuse last 4 free large allocation links
this fixes a pool growing for multi-requests keepalive connections
2009-06-03 13:57:28 +00:00
Igor Sysoev d15561923c librt must be tested before creating Makefile
the bug has been introduced in r2817
2009-06-03 04:53:01 +00:00
Igor Sysoev ccc69aa9da bump version 2009-06-03 04:51:52 +00:00
Igor Sysoev 8fe7a545db release-0.8.0 tag 2009-06-02 16:22:27 +00:00
Igor Sysoev d12de55a57 nginx-0.8.0-RELEASE 2009-06-02 16:22:26 +00:00
Igor Sysoev 4caaeef170 return NULL instead of NGX_CONF_ERROR on a create conf failure 2009-06-02 16:09:44 +00:00
Igor Sysoev a416242212 fix return value on failure 2009-06-02 16:08:38 +00:00
Igor Sysoev 8b43700570 leave chain in consistent state on errors 2009-06-02 16:07:13 +00:00
Igor Sysoev 65b091a131 test premature process termination 2009-06-02 14:26:59 +00:00
Igor Sysoev 6bc565fce2 log GetExitCodeProcess()'s errno 2009-06-02 14:26:18 +00:00
Igor Sysoev 897c0c022a limit_rate_after 2009-06-02 14:01:50 +00:00
Igor Sysoev 641c68fb6c add drive letter for Win32 root path 2009-06-02 14:00:01 +00:00
Igor Sysoev 4c5403bbf7 test that zone has the same addresses in different processes 2009-06-02 13:57:59 +00:00
Igor Sysoev 73f5d51455 *) fix memory leak in successful case
*) log shared memory name in failure case
2009-06-02 13:56:42 +00:00
Igor Sysoev bc3a7766b2 allow shared memory segments more than 4G 2009-05-30 17:06:38 +00:00
Igor Sysoev 00a2e7c2ae fix "out of memory" case handling 2009-05-29 11:42:55 +00:00
Igor Sysoev 4adfd21563 fix logging in ngx_win32_rename_file() 2009-05-29 09:32:52 +00:00
Igor Sysoev f6f6c95649 add trailing zero to a file name 2009-05-29 09:31:48 +00:00
Igor Sysoev 8b1c690e03 fix XSLT filter in SSI subrequests 2009-05-28 15:42:27 +00:00
Igor Sysoev 22f9e83575 Win32 returns ERROR_PATH_NOT_FOUND instead of ERROR_FILE_NOT_FOUND 2009-05-28 15:32:22 +00:00
Igor Sysoev bfee5cb477 *) use no-threads for Unix builds only
*) style fix
2009-05-28 15:30:45 +00:00
Igor Sysoev bcacef7f18 use tab in Makefile 2009-05-28 14:33:37 +00:00
Igor Sysoev e580f4a299 report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility 2009-05-28 13:41:44 +00:00
Igor Sysoev 7b26e45205 style fix 2009-05-28 13:31:43 +00:00
Igor Sysoev 791c447d29 stop ./configure at once on library failure 2009-05-26 14:28:49 +00:00
Igor Sysoev 626c10e245 use md5/sha1 in OpenSSL only if OpenSSL is used 2009-05-26 14:28:06 +00:00
Igor Sysoev 37a8051294 do not set charset for subrequests 2009-05-26 09:38:48 +00:00
Igor Sysoev e219044a07 fix the previous commit 2009-05-25 19:57:25 +00:00
Igor Sysoev 0bc0ebd260 refactor ngx_http_charset_header_filter() 2009-05-25 15:57:43 +00:00
Igor Sysoev 607daa4cee keepalive_requests 2009-05-25 15:38:36 +00:00
Igor Sysoev 62d6e759a0 bump version 2009-05-25 15:24:20 +00:00
Igor Sysoev 3af2847153 release-0.7.59 tag 2009-05-25 10:00:09 +00:00
Igor Sysoev 9b1125b416 nginx-0.7.59-RELEASE 2009-05-25 10:00:08 +00:00
Igor Sysoev fe31472ba6 fix socket leak introduced in r2378 2009-05-25 09:56:01 +00:00
Igor Sysoev cc4b08b686 reset content_type hash value, this fixes a bug when XSLT responses
could not be processed by SSI, charset, and gzip filters
2009-05-25 09:06:29 +00:00
Igor Sysoev c8156a245c light optimization of ngx_http_test_content_type() 2009-05-25 09:00:35 +00:00
Igor Sysoev b9f1f83e27 test libdl before OpenSSL configuration
the bug has been introduced in r2818 and broke
*) SSL modules linking on Solaris 9 and lower,
*) and linking with OpenSSL built from sources on Linux
2009-05-24 14:19:16 +00:00
Igor Sysoev c8a13e5c23 allow absolute path in --with-openssl= 2009-05-24 14:14:08 +00:00
Igor Sysoev 83b0b36110 fix segfault introduced in r2845 2009-05-22 11:32:17 +00:00
Igor Sysoev 7e559ef739 add charset for ngx_http_gzip_static_module responses 2009-05-22 11:05:26 +00:00
Igor Sysoev 434948cc98 use -ldl for any OS that needs it 2009-05-22 09:22:28 +00:00
Igor Sysoev a879b26305 proxy_cache_methods and fastcgi_cache_methods 2009-05-19 13:27:27 +00:00
Igor Sysoev aec2982c22 use already given variable 2009-05-19 12:55:26 +00:00
Igor Sysoev a1a327f287 fix building OpenSSL on Unix 2009-05-19 12:12:36 +00:00
Igor Sysoev e072e57d75 style fix 2009-05-18 16:50:32 +00:00
Igor Sysoev f977404401 fix "make zip", the bug has been introduced in r2841 2009-05-18 16:50:05 +00:00
Igor Sysoev 87139c8b0a bump version 2009-05-18 16:48:53 +00:00
Igor Sysoev c505798dbf release-0.7.58 tag 2009-05-18 13:14:18 +00:00
Igor Sysoev fef1b2a8ac nginx-0.7.58-RELEASE 2009-05-18 13:14:17 +00:00
Igor Sysoev 6c8087a9ed use ngx_connection_local_sockaddr() instead of ngx_http_server_addr() 2009-05-18 12:58:19 +00:00
Igor Sysoev 01bd8881cc delete unneeded field 2009-05-18 12:21:00 +00:00
Igor Sysoev 9751eea0ee mail proxy listen IPv6 support 2009-05-18 12:20:22 +00:00
Igor Sysoev 67dd2e0947 ngx_connection_local_sockaddr() 2009-05-18 12:12:06 +00:00
Igor Sysoev a193d526d6 delete unneeded cast 2009-05-18 07:47:58 +00:00
Igor Sysoev 77a9675ebd update comments missed in r2513 2009-05-17 20:13:29 +00:00
Igor Sysoev a120e1aa78 update variable name missed in r2513 2009-05-17 19:58:37 +00:00
Igor Sysoev 2da8d73789 fix "make upgrade" broken in r2759 2009-05-17 19:22:08 +00:00
Igor Sysoev fb7278de13 fix colon in file name for ngx_http_autoindex_module 2009-05-17 19:01:23 +00:00
Igor Sysoev a5a579ca5c image_filter_jpeg_quality 2009-05-16 16:57:11 +00:00
Igor Sysoev b341110460 style fix 2009-05-14 16:24:39 +00:00
Igor Sysoev f8411dbc86 fix building OpenSSL on Win32 2009-05-14 15:46:34 +00:00
Igor Sysoev 315634cee6 client_body_in_single_buffer 2009-05-14 11:41:33 +00:00
Igor Sysoev bb96d6c546 $request_body variable 2009-05-14 11:40:51 +00:00
Igor Sysoev 0818290c22 update two previous commits again 2009-05-14 11:39:06 +00:00
Igor Sysoev 5ae70b03d8 update the previous commit 2009-05-14 11:36:26 +00:00
Igor Sysoev 73b5f6f648 fix client_body_in_file_only type 2009-05-14 11:31:50 +00:00
Igor Sysoev 6471b58d09 switch Win32 building to modern PCRE versions (starting from 7.1)
instead of single old 4.4 version
2009-05-13 19:48:21 +00:00
Igor Sysoev 71cf32439f add miltilines in OpenWatcom makefiles 2009-05-12 13:29:00 +00:00
Igor Sysoev 51e65de30a backout r2833: CURDIR was set to Unix style path
instead, do chdir inside Makefile
2009-05-12 13:15:43 +00:00
Igor Sysoev f32fabf623 bump version 2009-05-12 13:11:39 +00:00
Igor Sysoev acd022fea6 release-0.7.57 tag 2009-05-12 12:11:51 +00:00
Igor Sysoev f882fd918a nginx-0.7.57-RELEASE 2009-05-12 12:11:50 +00:00
Igor Sysoev 897252d550 test finalized image filter context before testing image_filter off
this fixes SIGFPE if image filter errors are passed to named location
2009-05-12 12:05:29 +00:00
Igor Sysoev 2b4d8f60ad correctly apply patch 2009-05-12 09:35:14 +00:00
Igor Sysoev 5e2e84b975 use $(CURDIR) instead of "..\..\.." because the later does not allow to use
options as --with-zlib=../zlib-1.2.3.  It seems there is no common way
to learn the current directory in Win32 make's: although nmake has MAKEDIR
variable, nevertheless Borland make's MAKEDIR is the directory where make
is installed, and OpenWatcom wmake has no MAKEDIR at all.
2009-05-11 18:02:06 +00:00
Igor Sysoev e7797d0b20 bump version 2009-05-11 17:47:06 +00:00
Igor Sysoev 207e5f0bfc release-0.7.56 tag 2009-05-11 13:42:27 +00:00
Igor Sysoev a00ef919b7 nginx-0.7.56-RELEASE 2009-05-11 13:42:26 +00:00
Igor Sysoev c0df517dd7 backout -r2827 and add correct fix 2009-05-10 19:49:14 +00:00
Igor Sysoev 07c3f967cb message creating Makefile 2009-05-10 18:38:11 +00:00
Igor Sysoev d982117b9f add MSYS support 2009-05-10 18:35:39 +00:00
Igor Sysoev 123db90851 remove BMAKE (build make): a cc compiler should use own make 2009-05-10 18:35:08 +00:00
Igor Sysoev d327e78cfb fix building --without-http-cache
the bug had been appeared in r2806
2009-05-08 20:14:35 +00:00
Igor Sysoev 823d809df5 reconfigure master process 2009-05-08 18:12:03 +00:00
Igor Sysoev 9b6040ff4a fix the previous commit 2009-05-08 18:11:18 +00:00
Igor Sysoev acdaf84126 allow to pass image filter errors via the same location where the filter is set 2009-05-08 14:52:50 +00:00
Igor Sysoev 66e4adc3c8 test already destroyed request 2009-05-08 14:31:59 +00:00
Igor Sysoev b8c9d31801 handle big responses for "size" and "test" image_filters 2009-05-08 14:25:51 +00:00
Igor Sysoev a3e783a0de preserve Solaris binary hardware capabilities 2009-05-08 09:41:43 +00:00
Igor Sysoev 09dd00879f test whether libdl is required for dynamic linking:
Solaris 10 has dlopen()/etc. in libc
2009-05-08 09:39:53 +00:00
Igor Sysoev 8281017379 Solaris 10 has sched_yield() in libc 2009-05-08 09:36:16 +00:00
Igor Sysoev 377aa46831 move libmd test before libmd5,
this fixes wrong linking with /usr/local/lib/libmd5.so from libwww package
on FreeBSD. The library uses long's instead of int32_t's in MD5_CTX
and on 64-bit platforms its MD5_CTX is bigger than defined in <md5.h>
2009-05-07 19:18:10 +00:00
Igor Sysoev f71852b835 IPv6 for Win32 2009-05-07 13:05:04 +00:00
Igor Sysoev 098b8ee438 divide select module into two modules: Unix and Win32 ones 2009-05-06 14:53:54 +00:00
Igor Sysoev 7020804152 bump version 2009-05-06 14:11:03 +00:00
Igor Sysoev e0d816c0cd release-0.7.55 tag 2009-05-06 09:28:58 +00:00
Igor Sysoev c596e953ec nginx-0.7.55-RELEASE 2009-05-06 09:28:57 +00:00
Igor Sysoev fce7d70193 make code clearer 2009-05-06 08:54:54 +00:00
Igor Sysoev 698703c480 test event type to prevent errors 2009-05-06 08:53:13 +00:00
Igor Sysoev 5b12a0b138 delete level event of appropriate type, this should fix select()'s EBADF,
WSAENOTSOCK, and "select ready != events" alerts
2009-05-06 08:40:44 +00:00
Igor Sysoev 35b414bc3f ngx_create_listening() 2009-05-05 17:33:26 +00:00
Igor Sysoev d634510e54 reinit proxy/fastcgi header parser before ngx_http_upstream_cache_send() 2009-05-05 17:18:33 +00:00
Igor Sysoev 0f784a0095 proxy/fastcgi_cache_use_stale http_50x did not work 2009-05-05 15:17:00 +00:00
Igor Sysoev 8499723c60 move listen log copying from ngx_open_listening_sockets()
to ngx_configure_listening_sockets(), otherwise listen socket logs have no file
after first reload and this caused segfault if debug_connection was used;
the bug has been introduced in r2786
2009-05-05 13:16:29 +00:00
Igor Sysoev 96e846f670 use correct name 2009-05-05 13:12:59 +00:00
Igor Sysoev 61f837251b use local variable 2009-05-05 13:05:42 +00:00
Igor Sysoev 6c083044aa delete never used ngx_ssl_set_nosendshut() 2009-05-04 19:51:32 +00:00
Igor Sysoev 145c338011 delete ngx_listening_inet_stream_socket() 2009-05-04 19:51:09 +00:00
Igor Sysoev 2f3014e62f axe imap module artifacts 2009-05-04 19:34:59 +00:00
Igor Sysoev ac66e2eb0b do not free buffer with cache header before it would be written,
it seems this affected header only FastCGI responses only:
proxied header only responses were cached right
2009-05-04 19:04:00 +00:00
Igor Sysoev 24e8356bd3 add libgd include path 2009-05-04 15:57:12 +00:00
Igor Sysoev 4ae910a756 fix building ngx_http_image_filter_module on 64-bit platforms 2009-05-04 11:39:22 +00:00
Igor Sysoev 7e6d4179f0 use off_t in $r->sendfile(), this allows to use 64-bit off_t on platforms
where IV is long:
*) on 64-bit platforms,
*) and on 32-bit platforms if perl was built with -Duse64bitint
2009-05-01 19:31:52 +00:00
Igor Sysoev 7d2892af8e add --with-http_image_filter_module to ./configure --help 2009-05-01 19:14:10 +00:00
Igor Sysoev 0804db3ccd bump version 2009-05-01 19:13:37 +00:00
Igor Sysoev 5178959530 release-0.7.54 tag 2009-05-01 18:52:59 +00:00
Igor Sysoev 06a59023d6 nginx-0.7.54-RELEASE 2009-05-01 18:52:58 +00:00
Igor Sysoev 0d0ca2d1b5 add comment 2009-05-01 18:44:50 +00:00
Igor Sysoev 7e2efefd53 ngx_http_image_filter_module 2009-05-01 18:42:09 +00:00
Igor Sysoev bd2e8b173d ngx_http_filter_finalize_request() and ngx_http_clean_header() 2009-05-01 18:41:07 +00:00
Igor Sysoev 42a313744c proxy_ignore_headers and fastcgi_ignore_headers 2009-04-30 16:15:07 +00:00
Igor Sysoev 4709d5d80f *) refactor error_log processing: listen socket log might inherit built-in
error_log with zero level, and r2447, r2466, r2467 were not enough
*) remove bogus "stderr" level
*) some functions and fields renames
2009-04-30 13:53:42 +00:00
Igor Sysoev 5426d28e31 *) check a proxy_redirect single parameter
*) warn about "proxy_redirect false"
2009-04-30 12:43:38 +00:00
Igor Sysoev 416256863e set of.failed for cached error, the bug has been introduced in r2757 2009-04-30 08:01:50 +00:00
Igor Sysoev 5b0c886626 uniform ngx_file_info() interface with ngx_fd_info() 2009-04-29 19:28:52 +00:00
Igor Sysoev cc310346f5 try to repair the case "select ready != events" 2009-04-29 18:56:47 +00:00
Igor Sysoev 0c56344143 ngx_select_repair_fd_sets() 2009-04-29 15:29:12 +00:00
Igor Sysoev f40bee45d3 delete useless debug log 2009-04-29 15:15:17 +00:00
Igor Sysoev 3eadb2ae20 style fix 2009-04-29 15:12:57 +00:00
Igor Sysoev 25e3fc0183 handle Winsock select() WSAEINVAL 2009-04-29 13:42:14 +00:00
Igor Sysoev d7d54fb5ab style fix 2009-04-29 13:08:10 +00:00
Igor Sysoev 50480a02a2 fix the previous commit 2009-04-29 13:07:16 +00:00
Igor Sysoev 2c265a76eb Winsock uses ECONNABORTED instead of ECONNRESET 2009-04-29 11:34:58 +00:00
Igor Sysoev 38e0a9b4e5 fix building by BCC if NGX_PREFIX is defined 2009-04-29 11:32:58 +00:00
Igor Sysoev d699f98b8c *) do not show line number for -g option
*) reset configuration file after -g option has been parsed
2009-04-28 20:06:03 +00:00
Igor Sysoev b498a2350a add listen events for win32 only after accept mutex is hold 2009-04-28 20:03:59 +00:00
Igor Sysoev 5dab4e9775 fallback to neutral language in FormatMessage() 2009-04-28 15:06:29 +00:00
Igor Sysoev 89cf9f7787 introduce ngx_write_console() to support OEM code pages 2009-04-28 15:05:27 +00:00
Igor Sysoev 42312a2c65 "port_in_redirect off" did not work
the bug had been appeared in r2530 and r2534
2009-04-28 06:20:12 +00:00
Igor Sysoev 64e5598458 add prefix in Usage 2009-04-28 04:34:27 +00:00
Igor Sysoev fd9051fc8f it seems MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT) returns
ERROR_RESOURCE_LANG_NOT_FOUND for Russian locale
2009-04-27 18:58:35 +00:00
Igor Sysoev 9c1308dd82 ngx_log_errno() 2009-04-27 13:17:33 +00:00
Igor Sysoev 70eb9fa979 use ngx_vslprintf(), ngx_slprintf() 2009-04-27 13:06:20 +00:00
Igor Sysoev 447dba8ab7 ngx_vslprintf(), ngx_slprintf() 2009-04-27 12:51:33 +00:00
Igor Sysoev ecfc0688ff bump version 2009-04-27 12:48:38 +00:00
Igor Sysoev 65e4056aeb release-0.7.53 tag 2009-04-27 12:02:02 +00:00
Igor Sysoev fc4e0b6904 nginx-0.7.53-RELEASE 2009-04-27 12:02:01 +00:00
Igor Sysoev fb2dc513f9 fix building by MSVC8 2009-04-27 11:33:34 +00:00
Igor Sysoev 0ae870d26b -p and --prefix= 2009-04-27 11:32:33 +00:00
Igor Sysoev 8d8d431c86 get a full response if the response is cacheable or storable even
a client has closed connection prematurely
2009-04-27 11:20:55 +00:00
Igor Sysoev 605e8e0575 *) of.test_only to not open file if only stat() is enough
*) of.failed to return exact name of failed syscall
2009-04-27 09:55:53 +00:00
Igor Sysoev 2f025ec2b0 add quotes for configure options with spaces 2009-04-26 19:37:38 +00:00
Igor Sysoev c2e7f19084 style fix 2009-04-24 19:58:19 +00:00
Igor Sysoev d0e3e9ed58 merge SSL context inside "if" block 2009-04-24 19:56:09 +00:00
Igor Sysoev 52a498f2fd change ngx_log_abort() interface 2009-04-24 15:50:51 +00:00
Igor Sysoev 0aa44a8c2a update gcc warnings 2009-04-24 15:31:13 +00:00
Igor Sysoev d8651b96c4 style fix: (void) 2009-04-24 14:45:52 +00:00
Igor Sysoev 30eebbb00a change ngx_log_create_errlog() interface 2009-04-24 14:27:36 +00:00
Igor Sysoev f73b68f96b fix Auth-Method, the bug has been introduced in r2496 2009-04-24 09:54:40 +00:00
Igor Sysoev 2a7c97b47f fix GNU strerror_r() detection, the bug has been inroduced in r2600 2009-04-24 09:38:48 +00:00
Igor Sysoev b1a4c79fce delete unused definition 2009-04-23 18:50:29 +00:00
Igor Sysoev c208891826 pass command lines options to workers 2009-04-23 18:22:28 +00:00
Igor Sysoev a6ff87e75b ngx_path_separator() 2009-04-23 16:38:59 +00:00
Igor Sysoev ddba51983f issue start up errors and warning on both stderr and error_log 2009-04-23 11:13:12 +00:00
Igor Sysoev d4dc08bc11 style fix: remove trailing spaces introduced in the previous commit 2009-04-23 09:46:14 +00:00
Igor Sysoev 1768f3bbf2 use ngx_str_t for error levels 2009-04-23 08:05:54 +00:00
Igor Sysoev 8570e9695e axe incomplete support of Winsock error descriptions on NT 2009-04-22 11:25:12 +00:00
Igor Sysoev e87ff22f57 use English only error descriptions in Win32 ngx_strerror_r() 2009-04-22 11:20:31 +00:00
Igor Sysoev a0ad107cee implement "-s signal" option for Unix 2009-04-21 20:25:49 +00:00
Igor Sysoev dc2cdf7565 style fix: remove trailing spaces 2009-04-21 19:49:48 +00:00
Igor Sysoev 613828e9c2 style fix: remove tabs 2009-04-21 19:38:02 +00:00
Igor Sysoev c21d2ff81e add -? and -h options 2009-04-21 16:21:58 +00:00
Igor Sysoev 35e01d481f add 48x48 icon 2009-04-21 15:44:39 +00:00
Igor Sysoev d8f4d3aee6 allow condensed command lines options 2009-04-21 15:42:15 +00:00
Igor Sysoev 7f8b171cdc fix r2731 for Win32 2009-04-21 15:40:40 +00:00
Igor Sysoev 75fb6526fc *) move advapi32.lib to core libs since it's required for Registry and Event Log
*) delete shell32.lib since we do not use tray icon anymore
2009-04-21 14:31:40 +00:00
Igor Sysoev 566b2a0d1f test command line options before ngx_log_init() and issue errors to stderr 2009-04-21 13:39:47 +00:00
Igor Sysoev 16bc72552e fix fastcgi_cache_min_uses 2009-04-21 10:36:01 +00:00
Igor Sysoev e1262ebe1d bump version 2009-04-20 13:29:38 +00:00
Igor Sysoev c93ea1705b release-0.7.52 tag 2009-04-20 06:16:20 +00:00
Igor Sysoev 2b181c433a nginx-0.7.52-RELEASE 2009-04-20 06:16:19 +00:00
Igor Sysoev 783a4563b5 Win32 master/workers model 2009-04-20 06:08:47 +00:00
Igor Sysoev 0541fec9be fix Win32 ngx_gettimezone() 2009-04-19 19:08:49 +00:00
Igor Sysoev 65ff46961d add variadic macros support for msvc8 2009-04-19 16:25:02 +00:00
Igor Sysoev 2668e22fa1 show -t results on stderr 2009-04-19 16:06:09 +00:00
Igor Sysoev b44439acda remove TODO comments 2009-04-18 19:39:06 +00:00
Igor Sysoev 523bf6b61f support attaching to an existent Win32 shared memory 2009-04-18 19:27:28 +00:00
Igor Sysoev 4877b3ef8c update c->sent in ngx_unix_send() 2009-04-18 19:13:53 +00:00
Igor Sysoev 2e17014cba fix building on platforms which have no atomic operations support,
the bug was introduced in r2564
2009-04-17 19:11:31 +00:00
Igor Sysoev 1b247358f5 fix the previous commit 2009-04-17 19:09:08 +00:00
Igor Sysoev 692c1103da move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory 2009-04-16 19:25:09 +00:00
Igor Sysoev c0cabc2e21 perl termination fixes:
*) master exit hook is run before global pool cleanup, so call PERL_SYS_TERM()
   after perl_destruct()/perl_free().  This fixes the message
        panic: MUTEX_LOCK (22) [op.c:352]
   on some threaded perl builds

*) call perl_destruct()/perl_free() before PERL_SYS_TERM() for
   non-mulitiplicity perl
2009-04-16 14:42:31 +00:00
Igor Sysoev e440c3957c fix segfault on exit if no http section is defined in confguraiton,
the bug has been introduced in r1947
2009-04-15 20:28:36 +00:00
Igor Sysoev 377ead1899 fix segfault if no http section is defined in confguraiton,
the bug has been introduced in r1259
2009-04-15 20:26:33 +00:00
Igor Sysoev a9459cfc60 OpenSSL building by MSVC and BCC from sources 2009-04-15 19:46:24 +00:00
Igor Sysoev d1c68f1116 fix building by BCC without NGX_DEBUG_MALLOC 2009-04-15 19:44:41 +00:00
Igor Sysoev 9cc2c1a656 fix building by MSVC8 2009-04-15 19:28:10 +00:00
Igor Sysoev d17fa5e084 fix debug logging 2009-04-15 13:46:52 +00:00
Igor Sysoev 8abd5392d7 fix building --without-http-cache, introduced in r2664 and later 2009-04-15 12:25:51 +00:00
Igor Sysoev 93d9b413c1 hide grep errors 2009-04-15 11:47:51 +00:00
Igor Sysoev 62db95750d hide cacheable Set-Cookie and P3P response headers 2009-04-15 11:42:49 +00:00
Igor Sysoev cdad5c2c6e do not pass if-... headers for cacheable responses 2009-04-15 11:21:12 +00:00
Igor Sysoev 4a31abbcc0 shutdown client connection for cacheable header only responses 2009-04-15 11:19:27 +00:00
Igor Sysoev 19bd20c4ed support 304 for cacheable responses 2009-04-15 11:17:38 +00:00
Igor Sysoev fc0497f0f1 style fix 2009-04-15 10:57:40 +00:00
Igor Sysoev c4ce6847ed support HEAD in proxy cache 2009-04-15 09:53:22 +00:00
Igor Sysoev 22d10b6760 style fix: remove trailing spaces 2009-04-15 06:26:20 +00:00
Igor Sysoev a9b3c2740b bump version 2009-04-15 06:25:02 +00:00
Igor Sysoev bbf815c7e8 release-0.7.51 tag 2009-04-12 09:35:26 +00:00
Igor Sysoev cf08991f3a nginx-0.7.51-RELEASE 2009-04-12 09:35:25 +00:00
Igor Sysoev 42d63f9173 allow any status 2009-04-11 11:05:15 +00:00
Igor Sysoev f833e5ec52 try_files status code 2009-04-11 11:02:36 +00:00
Igor Sysoev 9d8ce97d94 set cache manager maximum sleep time to 10s 2009-04-10 17:46:25 +00:00
Igor Sysoev afe21da6de style fix 2009-04-10 17:45:07 +00:00
Igor Sysoev f2748d1c9f style fix 2009-04-10 14:49:51 +00:00
Igor Sysoev 14285eb3c2 do not call ngx_http_file_cache_free() if a response is not cacheable 2009-04-10 14:48:41 +00:00
Igor Sysoev 8f6edf23e4 add debug logging 2009-04-10 14:47:18 +00:00
Igor Sysoev d386750bec backout r2535: virtual names is a property of address:port pair,
but is not a property of server configuration
2009-04-09 13:56:16 +00:00
Igor Sysoev 6cc13ed833 style fix 2009-04-08 19:51:30 +00:00
Igor Sysoev 7e67ab9ba4 delete win32 ngx_file_append_mode() as we use reliable
FILE_APPEND_DATA|SYNCHRONIZE flags
2009-04-08 19:13:28 +00:00
Igor Sysoev 2af47be63f adopt NGX_FILE_TRUNCATE for win32 2009-04-08 19:03:41 +00:00
Igor Sysoev a63e4e441e fix r2590: error_page made an external redirect without query string 2009-04-07 15:50:08 +00:00
Igor Sysoev 34df303fde update $status in log_format example 2009-04-06 13:43:46 +00:00
Igor Sysoev 32b29d3b03 bump version 2009-04-06 13:42:56 +00:00
Igor Sysoev 63c9ee2d2f release-0.7.50 tag 2009-04-06 11:44:35 +00:00
Igor Sysoev e88cab7972 nginx-0.7.50-RELEASE 2009-04-06 11:44:34 +00:00
Igor Sysoev 898d8d8497 backout r2677 and fix ngx_strlcasestrn() again 2009-04-06 11:42:42 +00:00
Igor Sysoev a02d0e5501 bump version 2009-04-06 11:39:01 +00:00
Igor Sysoev 0905d967aa release-0.7.49 tag 2009-04-06 10:42:54 +00:00
Igor Sysoev 08f067862c nginx-0.7.49-RELEASE 2009-04-06 10:42:53 +00:00
Igor Sysoev a133d58eb1 fix ngx_strlcasestrn() 2009-04-06 10:38:40 +00:00
Igor Sysoev a4b3ae12a1 bump version 2009-04-06 10:37:53 +00:00
Igor Sysoev 54a020a611 release-0.7.48 tag 2009-04-06 10:15:23 +00:00
Igor Sysoev 10a81a7129 nginx-0.7.48-RELEASE 2009-04-06 10:15:22 +00:00
Igor Sysoev b90c980272 proxy_cache_key 2009-04-06 08:58:44 +00:00
Igor Sysoev cd111aa205 fix cache path slot 2009-04-06 08:35:34 +00:00
Igor Sysoev 32771dca80 refactor ngx_http_arg() using ngx_strcasestrn(),
back out zero termination introduced in r2138
2009-04-04 17:51:38 +00:00
Igor Sysoev 38c4594299 support Cache-Control no-cache and max-age in cache 2009-04-04 17:35:40 +00:00
Igor Sysoev ba9ed02e19 ngx_strlcasestrn() 2009-04-04 17:31:54 +00:00
Igor Sysoev ac8229e49e update r2664 2009-04-04 17:22:26 +00:00
Igor Sysoev 35df6891f0 support Expires in cache 2009-04-03 15:48:19 +00:00
Igor Sysoev b2120fed34 fix r2664: ..._cache_valid did not work for stale responses 2009-04-03 15:47:45 +00:00
Igor Sysoev 159b0c4f95 zero field 2009-04-03 15:44:41 +00:00
Igor Sysoev 1047e40672 support X-Accel-Expires in cache 2009-04-03 14:33:34 +00:00
Igor Sysoev f79e73448c cache GET requests only 2009-04-03 12:06:04 +00:00
Igor Sysoev 6fb7a68e98 merge fastcgi_cache_key 2009-04-02 13:48:54 +00:00
Igor Sysoev a4d4842b11 autoconfigure crypt_r(): uclibc has no crypt_r() 2009-04-02 13:46:39 +00:00
Igor Sysoev 63418309a8 fix OpenBSD building, broken in r2616 2009-04-02 13:44:32 +00:00
Igor Sysoev 16385b2b92 bump version 2009-04-02 13:44:02 +00:00
Igor Sysoev cdab32833e release-0.7.47 tag 2009-04-01 13:20:35 +00:00
Igor Sysoev 46906a1850 nginx-0.7.47-RELEASE 2009-04-01 13:20:34 +00:00
Igor Sysoev e9b810d8f7 fix MacOSX building, broken in r2616 2009-04-01 13:09:36 +00:00
Igor Sysoev a8cad641c7 zero cache file length,
this fixes full cache purging and hogging CPU by the cache manager after this
2009-04-01 13:05:38 +00:00
Igor Sysoev bec72decfd add debug logging 2009-04-01 13:01:50 +00:00
Igor Sysoev f00d37ff4f link staticaly with libcmt 2009-04-01 12:58:31 +00:00
Igor Sysoev 0b33dc60c5 Win32 appends synchronized if only FILE_APPEND_DATA and SYNCHRONIZE are set
without any other flags. On the other hand, Unix requires at least the write
flag to be set together with O_APPEND.
2009-03-31 13:52:01 +00:00
Igor Sysoev a701f1956d win32 ngx_open_file() supports utf8 names and NGX_FILE_APPEND 2009-03-30 14:51:51 +00:00
Igor Sysoev f7ac677820 ngx_process_tray() 2009-03-30 14:46:33 +00:00
Igor Sysoev a2772ff902 fix segfault introduced in r2602 if there is 502/504 error
and proxy/fastcgi_cache is defined without proxy/fastcgi_cache_valid
2009-03-30 14:23:07 +00:00
Igor Sysoev 50c9150175 fix r2579 2009-03-30 14:15:47 +00:00
Igor Sysoev c3993c79e8 fix FreeBSD before 7 building, broken in r2616 2009-03-30 12:33:33 +00:00
Igor Sysoev 3261ed4f47 bump version 2009-03-30 12:09:52 +00:00
Igor Sysoev 1a75aa794b release-0.7.46 tag 2009-03-30 11:02:57 +00:00
Igor Sysoev 51284aca48 nginx-0.7.46-RELEASE 2009-03-30 11:02:56 +00:00
Igor Sysoev bae6e97c7a bump version 2009-03-30 11:00:58 +00:00
Igor Sysoev d89429961c release-0.7.45 tag 2009-03-30 08:32:57 +00:00
Igor Sysoev 5396b4d42e nginx-0.7.45-RELEASE 2009-03-30 08:32:56 +00:00
Igor Sysoev 5fea4a7a97 nginx_version 2009-03-30 07:48:53 +00:00
Igor Sysoev ae49939ef2 introduce cache manager instead of cache cleaner 2009-03-30 07:45:55 +00:00
Igor Sysoev 9dc8b06851 ngx_fs_bsize() 2009-03-30 07:43:06 +00:00
Igor Sysoev 3b75efc419 fix ngx_wsasend_chain() 2009-03-29 16:58:23 +00:00
Igor Sysoev 3b973c3c1a update cpuid for Core 2 and Atom 2009-03-28 12:43:41 +00:00
Igor Sysoev c812176e84 delete duplicate error logging 2009-03-27 19:32:55 +00:00
Igor Sysoev 5405ac4039 improve ngx_slab_alloc() error logging 2009-03-27 17:00:42 +00:00
Igor Sysoev c17cebe9e0 delete old debugging and info 2009-03-27 16:37:39 +00:00
Igor Sysoev d2d2168044 rename ngx_http_scrip_flush_complex_value()
to ngx_http_script_flush_complex_value()
2009-03-27 14:59:47 +00:00
Igor Sysoev 87211384e3 fix plain text values using relative path in ngx_http_complex_value(),
this fixes the auth_basic_user_file bug introduced in r2589
2009-03-27 06:34:31 +00:00
Igor Sysoev 4771115bd6 fix alias with variables, but without captures,
the bug had been introduced in r2566 and r2573
2009-03-26 15:24:19 +00:00
Igor Sysoev 6a4e164d49 delete unneeded condition 2009-03-26 14:00:28 +00:00
Igor Sysoev 94440587a1 fix add_header Last-Modified "", broken in r2589 2009-03-26 13:34:37 +00:00
Igor Sysoev a48ac6f304 fix logged long locked cache entry name and add count 2009-03-26 09:50:04 +00:00
Igor Sysoev f837a7664b fix segfault if ngx_read_file() will fail 2009-03-24 15:03:38 +00:00
Igor Sysoev a008e08c52 fastcgi cache 2009-03-24 12:49:29 +00:00
Igor Sysoev aec4730776 unlink proxy_cache and proxy_cache_valid 2009-03-24 12:31:24 +00:00
Igor Sysoev aa1ccafe4f do not clean cache if memory cache keys zone is cold 2009-03-24 12:25:43 +00:00
Igor Sysoev 7638ba274f fix Linux sendfile32() test broken in 0.3.36 2009-03-23 20:30:25 +00:00
Igor Sysoev 961090566c style fix 2009-03-23 20:26:33 +00:00
Igor Sysoev ce7fc39161 fix the previous commit 2009-03-23 16:40:11 +00:00
Igor Sysoev 1a24605b6c axe old definition fields 2009-03-23 15:57:57 +00:00
Igor Sysoev dc5526a133 bump version 2009-03-23 15:56:46 +00:00
Igor Sysoev af30d0f9af release-0.7.44 tag 2009-03-23 13:27:40 +00:00
Igor Sysoev b8b8a85531 nginx-0.7.44-RELEASE 2009-03-23 13:27:39 +00:00
Igor Sysoev f321dbd59a a prelimiary proxy cache support 2009-03-23 13:14:51 +00:00
Igor Sysoev df02658f5d style fix: remove tabs 2009-03-22 15:52:52 +00:00
Igor Sysoev 82d682d923 style fix: remove tabs 2009-03-22 15:50:07 +00:00
Igor Sysoev 3906365e3a use complex value in error_page 2009-03-22 09:40:04 +00:00
Igor Sysoev 9643ced05f use complex values in add_header, auth_basic_user_file,
sub_filter, and xslt_stylesheet parameters
2009-03-22 09:39:19 +00:00
Igor Sysoev d7efd732ac ngx_http_script_flush_complex_value()
ngx_http_complex_value()
ngx_http_compile_complex_value()
2009-03-22 09:36:51 +00:00
Igor Sysoev 1774bd1653 add full path debug log in try_files 2009-03-20 16:50:53 +00:00
Igor Sysoev 3157c405a8 allow try_files in server context 2009-03-20 16:48:45 +00:00
Igor Sysoev 1c2923d10b fix directory test in try_files 2009-03-20 16:47:23 +00:00
Igor Sysoev fa7deb7ca1 always run regex in server_name to get captures 2009-03-19 16:07:40 +00:00
Igor Sysoev 984c82915e --with-pcre 2009-03-19 16:06:32 +00:00
Igor Sysoev 26211a6f9f grammar fix 2009-03-19 16:02:40 +00:00
Igor Sysoev 52c07d624d test wildcard tail hash existance 2009-03-19 15:46:27 +00:00
Igor Sysoev 27911efd41 split args in a try_files fallback 2009-03-19 13:42:27 +00:00
Igor Sysoev f2ce6027ae ngx_http_split_args() 2009-03-19 13:41:29 +00:00
Igor Sysoev 4095623091 split ngx_http_script_compile() 2009-03-18 14:42:06 +00:00
Igor Sysoev e0ae22fd9b bump version 2009-03-18 14:40:21 +00:00
Igor Sysoev aadbf405c9 release-0.7.43 tag 2009-03-18 12:46:24 +00:00
Igor Sysoev 967a25f15b nginx-0.7.43-RELEASE 2009-03-18 12:46:23 +00:00
Igor Sysoev be42b2f13c fix $server_addr for wildcard listen, the has been introduced in r2513 2009-03-18 12:23:57 +00:00
Igor Sysoev ecdd385af1 reserve space for r->uri, the bug has been introduced in r2566 2009-03-18 12:21:19 +00:00
Igor Sysoev c8bcb7b97c delete unneeded variable 2009-03-16 11:08:08 +00:00
Igor Sysoev 4b276055bc bump version 2009-03-16 11:07:29 +00:00
Igor Sysoev 9f79209ba4 release-0.7.42 tag 2009-03-16 07:23:10 +00:00
Igor Sysoev 5feb1e9886 nginx-0.7.42-RELEASE 2009-03-16 07:23:09 +00:00
Igor Sysoev b352b8f964 auth_basic_user_file supports variables 2009-03-16 07:13:22 +00:00
Igor Sysoev f9f182fc10 fix case when regex locaiton runs the second time via internal redirect 2009-03-14 19:24:17 +00:00
Igor Sysoev 0d8b4349b0 fix reserved mapped uri length if alias has captures 2009-03-14 19:20:34 +00:00
Igor Sysoev cdf49db2e9 remove unneeded increment 2009-03-14 17:10:25 +00:00
Igor Sysoev 589338b12f compatibility with Tru64 UNIX: fcntl(F_SETLK, F_WRLCK) returns EINVAL if busy 2009-03-13 14:53:30 +00:00
Igor Sysoev b44a03b45d ipv6only 2009-03-13 14:20:34 +00:00
Igor Sysoev bfa0525cb7 fix building without PCRE, introduced in r2553 2009-03-12 11:42:34 +00:00
Igor Sysoev 1f474de90e ignore EINVAL from setsockopt() on Solaris 2009-03-12 07:16:15 +00:00
Igor Sysoev 3c28e772d2 bump version 2009-03-12 07:12:25 +00:00
Igor Sysoev fbe2f6dd2b release-0.7.41 tag 2009-03-11 13:16:10 +00:00
Igor Sysoev 1c80a69e52 nginx-0.7.41-RELEASE 2009-03-11 13:16:09 +00:00
Igor Sysoev faf146c4fa fix segfaults introduced in r2549 and r2550 2009-03-11 13:04:02 +00:00
Igor Sysoev b48e9848ab bump version 2009-03-11 12:57:26 +00:00
Igor Sysoev acab870534 release-0.7.40 tag 2009-03-09 08:54:24 +00:00
Igor Sysoev c5de0aab0e nginx-0.7.40-RELEASE 2009-03-09 08:54:23 +00:00
Igor Sysoev 3468176b6d fix segfaults introduced in r2550 2009-03-09 08:50:34 +00:00
Igor Sysoev 77fcc06583 style fix: remove tabs 2009-03-06 16:48:36 +00:00
Igor Sysoev 9dbc379f23 XFS on Linux does not set dirent.d_type,
therefore fallback to stat() if dirent.d_type is not set,
this fixes slash after directory name in ngx_http_autoindex_module;
the issue has been introduced in r2235
2009-03-06 13:01:21 +00:00
Igor Sysoev e6c7aa224e captures support in server_name 2009-03-06 12:50:20 +00:00
Igor Sysoev 4b7fa1a4cf captures support in location and alias 2009-03-06 12:49:22 +00:00
Igor Sysoev f1f9f103d8 now regex captures are per-request entities 2009-03-06 12:15:07 +00:00
Igor Sysoev 751a371878 pclcf->regex_locations are used with PCRE only 2009-03-05 08:24:17 +00:00
Igor Sysoev 0750c93313 bump version 2009-03-05 08:22:45 +00:00
Igor Sysoev be3c19b3ac release-0.7.39 tag 2009-03-02 12:43:10 +00:00
Igor Sysoev 24377ee4bd nginx-0.7.39-RELEASE 2009-03-02 12:43:09 +00:00
Igor Sysoev b8c1f47660 fix postponed zlib memory allocation, introduced in r2411
*) introduce postpone_gzipping directive
*) disable postponed gzipping by default

The r2411 commit caused hangings up on large SSIed responses
as SSI cleared buf->recycled bit on copy of recycled buf parts
2009-03-01 19:24:11 +00:00
Igor Sysoev 069b455dd4 fix case when the first try is shorter then URI 2009-03-01 19:10:36 +00:00
Igor Sysoev 50b62b2e86 lower ECONNRESET level 2009-02-25 14:27:34 +00:00
Igor Sysoev cbff23b019 fix segfault introduced in r2486 in $sent_http_location processing 2009-02-24 22:02:08 +00:00
Igor Sysoev 2018e891ac fix the previous commit 2009-02-24 14:25:24 +00:00
Igor Sysoev a37e9f3546 prepare ngx_ptocidr() for IPv6 2009-02-24 14:01:40 +00:00
Igor Sysoev 12c14b31e3 small optimization: " == NGX_ERROR" > " != NGX_OK" 2009-02-24 10:42:23 +00:00
Igor Sysoev dbc4603c83 use variable for often used field 2009-02-24 08:32:02 +00:00
Igor Sysoev c701f5dd5c move r->virtual_names to ngx_http_core_srv_conf_t 2009-02-24 07:56:47 +00:00
Igor Sysoev a7b6c2f33a axe r->port_text 2009-02-24 07:29:55 +00:00
Igor Sysoev 268c329649 remove seldom used variable 2009-02-24 07:21:35 +00:00
Igor Sysoev 34a1c027ed fix r2530 2009-02-24 07:12:39 +00:00
Igor Sysoev 62d2c6ad12 axe unneeded port field 2009-02-23 21:30:31 +00:00
Igor Sysoev c0cbf1e93e axe r->port 2009-02-23 21:19:35 +00:00
Igor Sysoev d5b8bfff8b axe r->in_addr 2009-02-23 21:05:10 +00:00
Igor Sysoev 02ce02d2e5 bump version 2009-02-23 21:02:18 +00:00
Igor Sysoev 9747085e08 release-0.7.38 tag 2009-02-23 16:01:24 +00:00
Igor Sysoev be5fb87d03 nginx-0.7.38-RELEASE 2009-02-23 16:01:23 +00:00
Igor Sysoev 447157153a name/password were ignored after odd empty lines 2009-02-23 15:31:18 +00:00
Igor Sysoev 44688aea72 add auth basic failure logging 2009-02-23 15:15:42 +00:00
Igor Sysoev 96d6eb9e70 fix message 2009-02-23 09:42:35 +00:00
Igor Sysoev f3778a5f36 fix NGX_SOCKADDRLEN, introduced in r2513 2009-02-21 15:13:13 +00:00
Igor Sysoev 064e0bdf0b bump version 2009-02-21 14:55:58 +00:00
Igor Sysoev a921304222 release-0.7.37 tag 2009-02-21 14:42:39 +00:00
Igor Sysoev 508dda4f8e nginx-0.7.37-RELEASE 2009-02-21 14:42:38 +00:00
Igor Sysoev 71d332dd0d fix upstream port, introduced in r2513 2009-02-21 14:34:32 +00:00
Igor Sysoev fe98af1054 fix implicit listen, introduced in r2513 2009-02-21 10:23:30 +00:00
Igor Sysoev 5d7081728e bump version 2009-02-21 09:44:57 +00:00
Igor Sysoev fac562fce3 release-0.7.36 tag 2009-02-21 07:26:18 +00:00
Igor Sysoev bcf2de0c97 nginx-0.7.36-RELEASE 2009-02-21 07:26:17 +00:00
Igor Sysoev e2dc4550af a prelimiary IPv6 support, HTTP listen 2009-02-21 07:02:02 +00:00
Igor Sysoev 2032328a14 split ports, addresses, and server names preparation and optimization 2009-02-18 16:17:12 +00:00
Igor Sysoev e50d758490 add debug logging 2009-02-18 09:24:14 +00:00
Igor Sysoev 412ad87546 the $ancient_browser variables did not treat as an ancient browser
listed in modern_browser, but has lower version
2009-02-18 09:23:47 +00:00
Igor Sysoev f7638d2374 set MIME-type length,
otherwise ngx_http_test_content_type() did not find "image/gif"
2009-02-17 08:37:36 +00:00
Igor Sysoev cfb10de1b6 bump version 2009-02-16 14:55:10 +00:00
Igor Sysoev 7f319fc74f release-0.7.35 tag 2009-02-16 13:58:44 +00:00
Igor Sysoev fda9f60e4c nginx-0.7.35-RELEASE 2009-02-16 13:58:43 +00:00
Igor Sysoev 106c630bbc load SSL engine before certificates,
otherwise RSA keys will use built-in RSA methods
2009-02-16 13:37:58 +00:00
Igor Sysoev 5c8e0ed2e3 set content-type for try_files' choice 2009-02-14 17:26:26 +00:00
Igor Sysoev 904955be52 fix r2169 for .def.com and .abc.def.com case 2009-02-11 12:33:13 +00:00
Igor Sysoev 0be61c1ed3 bump version 2009-02-11 10:23:06 +00:00
Igor Sysoev 7ed2735435 release-0.7.34 tag 2009-02-10 16:50:29 +00:00
Igor Sysoev b5b68eb500 nginx-0.7.34-RELEASE 2009-02-10 16:50:28 +00:00
Igor Sysoev 1759a9e80c fix /?new=arg?old=arg redirect case 2009-02-10 16:03:42 +00:00
Igor Sysoev d92328b870 send HELO/EHLO after XCLIENT
patch by Maxim Dounin
2009-02-10 15:19:45 +00:00
Igor Sysoev e127031055 if_modified_since off 2009-02-10 15:05:05 +00:00
Igor Sysoev 8eefe85677 compatibility with Microsoft's
AUTH LOGIN [base64 encoded user name ]
patch by Maxim Dounin
2009-02-09 12:03:55 +00:00
Igor Sysoev 8ab016271d AIX has no WCOREDUMP() 2009-02-05 16:01:50 +00:00
Igor Sysoev d789492a49 bump version 2009-02-05 15:47:12 +00:00
Igor Sysoev bae49c0320 release-0.7.33 tag 2009-02-02 11:00:12 +00:00
Igor Sysoev d413c011a5 nginx-0.7.33-RELEASE 2009-02-02 11:00:11 +00:00
Igor Sysoev 41eae75761 fix building by msvc, introduced in r2487 2009-02-02 10:17:06 +00:00
Igor Sysoev 5037113a13 avoid a double redirect response if
*) a request is going in a keep alive state,
*) the request body should be discarded,
*) epoll/rtsig reports about the response header has been sent,
*) and write event handler calls core phase handler
2009-01-31 20:44:30 +00:00
Igor Sysoev d38b0613cb avoid deep nested calls, flatten call tree 2009-01-31 20:34:26 +00:00
Igor Sysoev 678c196805 fix return code, this fixes segfault when two or more
simultaneous connections are resolving the same address
2009-01-31 20:33:01 +00:00
Igor Sysoev 1f61cdeaec use length of uncompressed name 2009-01-30 11:56:45 +00:00
Igor Sysoev bfea80ce31 fix $sent_http_location for local redirects 2009-01-30 05:26:27 +00:00
Igor Sysoev ae0158378e store name pointer in variable allocated on stack
as resolver ctx may be already deallocated at this point
2009-01-29 14:35:23 +00:00
Igor Sysoev 2636a427ba free addrs only it has been allocated before: non single address 2009-01-29 14:32:58 +00:00
Igor Sysoev 8cb51328e6 fix reverse resolving cache: it stored zero length names
*) free name only if it has been already allocated
*) store name length
2009-01-29 14:29:49 +00:00
Igor Sysoev 48f0532691 fix types and add comment 2009-01-27 16:22:02 +00:00
Igor Sysoev 82be9b3db6 test allocated space as in try_files 2009-01-27 16:20:29 +00:00
Igor Sysoev a0c0190dbd bump version 2009-01-26 17:01:27 +00:00
Igor Sysoev bada01a125 release-0.7.32 tag 2009-01-26 14:41:27 +00:00
Igor Sysoev ceaf5768b9 nginx-0.7.32-RELEASE 2009-01-26 14:41:26 +00:00
Igor Sysoev 3459066ec8 style fix: remove tabs 2009-01-26 14:35:10 +00:00
Igor Sysoev 9884689d06 fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
fastcgi handler, the bug has been introduced in r2444
2009-01-26 14:33:59 +00:00
Igor Sysoev 451b7b2fbc revert the previous commit and r2447 change in src/core/ngx_cycle.c 2009-01-26 14:31:49 +00:00
Igor Sysoev bab6e29561 default error_log has zero level, the bug has been introduced in r2447 2009-01-26 14:11:09 +00:00
Igor Sysoev 464ac78d5a fix slab page or more sized allocations if nginx was build without debug 2009-01-25 10:39:59 +00:00
Igor Sysoev e450e80f87 fix fastcgi_store 2009-01-21 20:54:40 +00:00
Igor Sysoev 8116838349 use GetFileAttributesEx() instead of GetFileAttributes() 2009-01-21 15:56:29 +00:00
Igor Sysoev 7f44d1b571 fix win32 ngx_is_dir(), etc 2009-01-21 15:53:09 +00:00
Igor Sysoev 1bcb862a85 test ngx_file_info() result, the bug has been introduced in r2070 2009-01-21 15:50:52 +00:00
Igor Sysoev 2e27bdaad0 fix r1981 on win32 2009-01-21 14:17:57 +00:00
Igor Sysoev 0b142d5bca allow directories in try_files 2009-01-21 12:11:22 +00:00
Igor Sysoev 5fdf1cbda6 fix segfault when geo range replaces starting part of another range 2009-01-19 16:42:14 +00:00
Igor Sysoev fed232be37 bump version 2009-01-19 16:37:22 +00:00
Igor Sysoev 4003f3aa5b release-0.7.31 tag 2009-01-19 13:57:02 +00:00
Igor Sysoev e72570337a nginx-0.7.31-RELEASE 2009-01-19 13:57:01 +00:00
Igor Sysoev bd6cc5e1f8 try_files should work with files only 2009-01-19 11:24:25 +00:00
Igor Sysoev 80165f6e52 allow insertion range if its start or end is the same as existent one 2009-01-16 16:29:23 +00:00
Igor Sysoev c0e75cbf02 fix single address range 2009-01-16 16:09:58 +00:00
Igor Sysoev 9edc91be02 fix range deletion 2009-01-16 16:02:30 +00:00
Igor Sysoev 159ae653ce repeat r2448 for range deletion 2009-01-16 15:58:27 +00:00
Igor Sysoev 9c46f3cfa4 log both overrlaped ranges 2009-01-16 15:47:05 +00:00
Igor Sysoev 7f5f76440b fix range start for ranges those spread in two or more slots 2009-01-16 15:44:39 +00:00
Igor Sysoev a188821842 set the error level as default http error_log level 2009-01-16 14:00:05 +00:00
Igor Sysoev 9663e72c13 proxy/fastcgi_store did not delete incomplete files 2009-01-16 13:57:00 +00:00
Igor Sysoev 94c95eff08 set r->root_tested for non-error_page response only 2009-01-16 13:53:08 +00:00
Igor Sysoev 29b8c38220 fastcgi_split_path_info 2009-01-16 13:21:20 +00:00
Igor Sysoev 64cbbf0e71 *) fix duplicate geo ranges
*) split existent range and insert a new one
2009-01-16 13:17:12 +00:00
Igor Sysoev a615a1a325 in miss case memcached module returned END instead of default 404 page body
the bug has been introduced in r2269
2009-01-15 13:10:45 +00:00
Igor Sysoev f1156d66ac update r2439: make clear name 2009-01-13 06:47:29 +00:00
Igor Sysoev b1204b829d update 2009 year and delete blank line 2009-01-12 15:45:19 +00:00
Igor Sysoev f4f6326b8d fix r2312 2009-01-12 15:40:26 +00:00
Igor Sysoev c7426c7260 style fix 2009-01-12 15:36:30 +00:00
Igor Sysoev c29ea4c4d7 send "100 Continue" just before reading request body 2008-12-26 13:43:42 +00:00
Igor Sysoev 3602e5b031 do not send "100 Continue" for subrequests 2008-12-26 06:21:23 +00:00
Igor Sysoev e612c04768 set send() slot for POSIX systems 2008-12-25 20:07:12 +00:00
Igor Sysoev 9f4f739350 bump version 2008-12-25 20:06:26 +00:00
Igor Sysoev 0b37253141 release-0.7.30 tag 2008-12-24 16:21:41 +00:00
Igor Sysoev a688f8c966 nginx-0.7.30-RELEASE 2008-12-24 16:21:40 +00:00
Igor Sysoev a7748055c2 fix segfault, introduced in r2423 2008-12-24 16:18:35 +00:00
Igor Sysoev 1076a34213 bump version 2008-12-24 15:54:21 +00:00
Igor Sysoev 8144c06b4f release-0.7.29 tag 2008-12-24 12:50:22 +00:00
Igor Sysoev 08fc4f5528 nginx-0.7.29-RELEASE 2008-12-24 12:50:21 +00:00
Igor Sysoev 42a733743f fix r2378, file inclusion should be waited 2008-12-24 12:39:41 +00:00
Igor Sysoev 301a2a20f1 do not try to align to a page size, allocate just 8K,
this is fixes allocation on Cygwin, it reports 64K page size
2008-12-24 12:05:55 +00:00
Igor Sysoev bf647d7676 flush variable values in try_files 2008-12-24 07:14:01 +00:00
Igor Sysoev 364480ea05 update r2422 2008-12-24 06:11:04 +00:00
Igor Sysoev e92388098d variable support for unix sockets in fastcgi_pass and proxy_pass 2008-12-23 19:35:12 +00:00
Igor Sysoev 7a283133e2 fix r2378, do not activate subrequest if there are already
postponed subrequests or data
2008-12-23 17:25:46 +00:00
Igor Sysoev 51cd8f1ded fix the previous commit 2008-12-23 08:10:17 +00:00
Igor Sysoev 1271a65a70 send "100 Continue" for HTTP/1.1 only 2008-12-22 15:44:13 +00:00
Igor Sysoev b8f5ad624b bump version 2008-12-22 15:40:12 +00:00
Igor Sysoev a4ec628f97 release-0.7.28 tag 2008-12-22 13:06:24 +00:00
Igor Sysoev 98f4ffe25d nginx-0.7.28-RELEASE 2008-12-22 13:06:23 +00:00
Igor Sysoev 6c27e28e62 ngx_http_arg() 2008-12-22 12:02:05 +00:00
Igor Sysoev 285a8f4f83 remove never used zero copy stuff 2008-12-17 20:47:18 +00:00
Igor Sysoev 5be2e142f5 fix segfault 2008-12-17 16:07:58 +00:00
Igor Sysoev c4d029f7d6 set default gzip_buffers to 32 4k or 16 8k 2008-12-16 16:15:52 +00:00
Igor Sysoev 726732cb89 bump version 2008-12-16 16:12:31 +00:00
Igor Sysoev b0bbef9718 postpone zlib memory allocation 2008-12-16 16:09:39 +00:00
Igor Sysoev b352e46449 release-0.7.27 tag 2008-12-15 11:30:09 +00:00
Igor Sysoev a181bd3777 nginx-0.7.27-RELEASE 2008-12-15 11:30:08 +00:00
Igor Sysoev f7ccdc3fe8 try_files 2008-12-15 10:56:48 +00:00
Igor Sysoev 2818ed6b60 do not add header if add_header "" 2008-12-15 10:50:57 +00:00
Igor Sysoev 15c0371993 remove seldom used variable 2008-12-12 16:40:12 +00:00
Igor Sysoev 8b19767c71 fix segfault if no named location are defined, but are used 2008-12-11 17:32:52 +00:00
Igor Sysoev 818876f689 fix zero length static response, the bug was introduced in r2378 2008-12-11 15:57:14 +00:00
Igor Sysoev 0c83b2cade $upstream_response_length 2008-12-11 15:30:52 +00:00
Igor Sysoev 530bc73c15 style fix: remove tabs 2008-12-11 10:22:25 +00:00
Igor Sysoev 2c47c83eb8 allow "~", "~*", "^~", and "=" before location name without space 2008-12-11 10:21:08 +00:00
Igor Sysoev 96dc6754be $geo variable support 2008-12-11 09:46:45 +00:00
Igor Sysoev 0945904292 remove before nginx-0.1.25 compatibility code 2008-12-11 07:48:48 +00:00
Igor Sysoev 887fc26511 fix r2394 2008-12-11 06:38:14 +00:00
Igor Sysoev 0878824edc test port in fastcgi_pass variable 2008-12-10 16:25:14 +00:00
Igor Sysoev 20dd3ab867 clear fastcgi ctx for internal redirection via named location 2008-12-10 16:16:10 +00:00
Igor Sysoev b575b6efd5 use ngx_ext_rename_file() for single file MOVE 2008-12-10 14:53:45 +00:00
Igor Sysoev a7a62b5f74 fix debug logging 2008-12-10 14:48:04 +00:00
Igor Sysoev 4936b13fdf change variable name 2008-12-10 14:46:34 +00:00
Igor Sysoev bd262e4954 delete surplus upstream.schema field 2008-12-10 14:44:48 +00:00
Igor Sysoev be40e7b1e8 fastcgi_pass variables support 2008-12-10 14:22:07 +00:00
Igor Sysoev 89d5a602d7 compact win32 errno logging 2008-12-09 17:41:17 +00:00
Igor Sysoev 8e7faf90f4 use "!= NGX_OK" instead of "== NGX_ERROR" 2008-12-09 17:27:48 +00:00
Igor Sysoev c65a71a1f8 remove stale pragma 2008-12-09 17:26:42 +00:00
Igor Sysoev 8138575bdd use already available r and u instead of ev 2008-12-09 17:25:03 +00:00
Igor Sysoev 4670baab4f delete unneeded call 2008-12-09 16:49:52 +00:00
Igor Sysoev 8ee817edaf bump version 2008-12-09 11:13:12 +00:00
Igor Sysoev 24fccfcf25 release-0.7.26 tag 2008-12-08 18:32:43 +00:00
Igor Sysoev 819442c70d nginx-0.7.26-RELEASE 2008-12-08 18:32:42 +00:00
Igor Sysoev 77917e966f fix r2378, run posted requests after upstream event handling 2008-12-08 18:28:06 +00:00
Igor Sysoev a2d1a1e0dd bump version 2008-12-08 17:59:43 +00:00
Igor Sysoev 28bc9c9302 release-0.7.25 tag 2008-12-08 14:43:17 +00:00
Igor Sysoev cd31de9402 nginx-0.7.25-RELEASE 2008-12-08 14:43:16 +00:00
Igor Sysoev 0862068332 *) refactor subrequest handling, now they run as separate posted requests
*) now $upstream_addr, $upstream_status, $upstream_response_time can be used
   with log_subrequest
2008-12-08 14:23:20 +00:00
Igor Sysoev 90cf67bebd *) add zone name while logging 503 error reason
*) log allocation error as 503 error reason
2008-12-08 14:18:06 +00:00
Igor Sysoev c539195e18 update comment 2008-12-08 14:15:19 +00:00
Igor Sysoev ec6863151c rename "lz" to "lr" in variable names 2008-12-08 14:13:36 +00:00
Igor Sysoev 0c190514c6 log 503 error reason 2008-12-08 14:12:29 +00:00
Igor Sysoev 8d6a2ade43 test duplicate limit_conn 2008-12-08 14:08:44 +00:00
Igor Sysoev 63b40c7f68 skip protected symlinks in autoindex 2008-12-08 14:05:21 +00:00
Igor Sysoev c7c815200b allow POST without Content-Length 2008-12-08 14:04:31 +00:00
Igor Sysoev b60c788cd7 fix comment 2008-12-02 16:50:56 +00:00
Igor Sysoev d2a86ccd09 fix "delete CIDR" 2008-12-02 15:02:36 +00:00
Igor Sysoev c0fe90885e bump version 2008-12-02 14:59:14 +00:00
Igor Sysoev 45e9d7a5b6 release-0.7.24 tag 2008-12-01 14:54:43 +00:00
Igor Sysoev c52228f178 nginx-0.7.24-RELEASE 2008-12-01 14:54:42 +00:00
Igor Sysoev 383884aa85 if_modified_since 2008-12-01 14:22:51 +00:00
Igor Sysoev 12657ffe6f read and process upstream header in cycle,
this fixes the case when local FastCGI server sends many warnings in stderr
2008-12-01 14:08:00 +00:00
Igor Sysoev ce6e845715 $cookie_... variable did not for SSI and perl 2008-12-01 13:59:35 +00:00
Igor Sysoev 8013eba125 create empty radix tree for "geo $geo { }" case 2008-11-28 17:22:35 +00:00
Igor Sysoev 80563412b8 bump version 2008-11-28 17:22:06 +00:00
Igor Sysoev beddab0870 release-0.7.23 tag 2008-11-27 13:05:35 +00:00
Igor Sysoev 9e78708847 nginx-0.7.23-RELEASE 2008-11-27 13:05:34 +00:00
Igor Sysoev f2c7d8e0f8 *) descrease geo configuration memory usage
*) geo delete
*) geo ranges
2008-11-25 15:59:06 +00:00
Igor Sysoev ad88b84e35 allocate cf->conf_file and cf->conf_file->buffer on stack 2008-11-25 15:55:10 +00:00
Igor Sysoev 4a47126295 fix segfault on close error 2008-11-25 14:45:44 +00:00
Igor Sysoev 00b187ec16 ngx_reset_pool() 2008-11-25 14:25:20 +00:00
Igor Sysoev c5d64f7af9 *) increase ngx_conf_log_error() buffer
*) always log an error code
2008-11-25 13:00:53 +00:00
Igor Sysoev 6e282a8ddd ngx_strerror_r() style and size == 0 bug fix 2008-11-25 11:26:32 +00:00
Igor Sysoev c3c89d5d45 use value rbtree instead of array in geo configuration 2008-11-22 20:42:51 +00:00
Igor Sysoev 997b3dbc72 variable value rbtree support 2008-11-22 20:42:01 +00:00
Igor Sysoev 60a1004e28 bump version 2008-11-22 20:38:45 +00:00
Igor Sysoev 13b11436b9 release-0.7.22 tag 2008-11-20 16:47:37 +00:00
Igor Sysoev 3838f48cd7 nginx-0.7.22-RELEASE 2008-11-20 16:47:36 +00:00
Igor Sysoev 79001f998d allow directio on XFS 2008-11-20 16:21:39 +00:00
Igor Sysoev 760972dc88 low some SSL handshake errors level 2008-11-18 16:05:00 +00:00
Igor Sysoev 1a70105b21 fix compression pointer for big (>255) DNS responses 2008-11-17 08:04:41 +00:00
Igor Sysoev 08d310387d use integer instead of float 2008-11-14 13:25:44 +00:00
Igor Sysoev 896dcfa400 change rate to an excess 2008-11-14 11:32:03 +00:00
Igor Sysoev 64ef84df90 do not close session if SMTP backend returned an error on RCPT TO
patch by Maxim Dounin
2008-11-13 14:20:54 +00:00
Igor Sysoev 6035577742 remove unused field 2008-11-13 13:30:34 +00:00
Igor Sysoev 91e1deb99d smtp_auth none
patch by Maxim Dounin
2008-11-13 13:25:34 +00:00
Igor Sysoev 8fcf6bbce6 memcached response was stored in variable with END 2008-11-12 21:01:01 +00:00
Igor Sysoev dbea16d385 $cookie_... variable 2008-11-12 11:12:02 +00:00
Igor Sysoev daef2021e4 bump version 2008-11-12 10:48:27 +00:00
Igor Sysoev 254638ddea release-0.7.21 tag 2008-11-11 20:04:59 +00:00
Igor Sysoev 24c05d6abd nginx-0.7.21-RELEASE 2008-11-11 20:04:58 +00:00
Igor Sysoev 80eb85f4be the sysctl "kern.ostype" and "kern.osrelease" had appeared in MacOSX 10.5 only 2008-11-11 19:44:30 +00:00
Igor Sysoev 96dfdc49a6 compatibility with glibc 2.3, warn_unused_result attribute for write() 2008-11-11 16:17:45 +00:00
Igor Sysoev dfaf3823d7 style fix: remove trailing spaces 2008-11-11 16:04:05 +00:00
Igor Sysoev 5dd3ec54de *) correct leaky bucket implementation
*) now burst is not per second
*) remove delay= parameter
*) add nodelay parameter
2008-11-11 15:38:16 +00:00
Igor Sysoev fea52523b7 exslt support 2008-11-11 15:22:24 +00:00
Igor Sysoev 0bcb5c5e59 bump version 2008-11-10 18:34:24 +00:00
Igor Sysoev 5e49c81be0 release-0.7.20 tag 2008-11-10 16:30:46 +00:00
Igor Sysoev 893b276254 nginx-0.7.20-RELEASE 2008-11-10 16:30:45 +00:00
Igor Sysoev cd0e6e18e1 fix r2067 2008-11-10 15:25:11 +00:00
Igor Sysoev 539cd0dad6 ngx_http_limit_req_module 2008-11-10 15:22:33 +00:00
Igor Sysoev 6df4eaaf88 %f format 2008-11-10 15:20:59 +00:00
Igor Sysoev 644029fa74 fix the previous commit 2008-11-06 19:54:54 +00:00
Igor Sysoev 08743f897c *) split ngx_http_gzip_body_filter()
*) send gzheader together with the filter's first output
2008-11-06 19:13:47 +00:00
Igor Sysoev bfb4833f35 change int to size_t 2008-11-06 19:11:19 +00:00
Igor Sysoev 476eddc439 align first allocation from additional pool block, this fixes bus error on sun4v 2008-11-06 16:14:24 +00:00
Igor Sysoev 2959de23f8 do not pass gzheader separately as due to the previous commit
we do not use ctx->busy as flush condition
2008-11-05 16:27:45 +00:00
Igor Sysoev 1894b45be8 use nomem flag to flush busy bufs,
thus gzip filter does not depend on NGX_AGAIN return code
2008-11-05 15:46:41 +00:00
Igor Sysoev 738bd68ab3 add double quotes around $request 2008-11-05 13:26:04 +00:00
Igor Sysoev ebf25e6fa4 fix r1913 2008-10-30 15:59:10 +00:00
Igor Sysoev 39c8f46741 fix case proxy_pass URL is evaluted to http://host?args 2008-10-24 19:34:24 +00:00
Igor Sysoev f8ec8752a6 fix case when URL has no port, but has ":" in URI part,
the bug has been introduced in r2204
2008-10-24 15:12:11 +00:00
Igor Sysoev d7354d3695 show name for a FORMERR DNS response 2008-10-24 14:38:09 +00:00
Igor Sysoev ee1be262b3 FORMERR DNS response may be equal to mininal query size 2008-10-24 14:34:10 +00:00
Igor Sysoev f67453d7d1 always use buffer, if connection is buffered,
this fixes OpenSSL "bad write retry" error, when
*) nginx passed a single buf greater than our buffer (say 32K) to OpenSSL,
*) OpenSSL returns SSL_ERROR_WANT_WRITE,
*) after some time nginx has to send a new data,
*) so there are at least two bufs nginx does pass them directly to OpenSSL,
*) but copies the first buf part to buffer, and sends the buffer to OpenSSL.
*) because the data length is lesser than it was in previous SSL_write():
   16K < 32K, OpenSSL returns SSL_R_BAD_WRITE_RETRY.
2008-10-23 05:58:10 +00:00
Igor Sysoev 8106a74d7c allow short secure links 2008-10-21 12:33:23 +00:00
Igor Sysoev 2f353eb47c fix server_addr value known from configuration, bug introduced in r2199 2008-10-17 12:36:48 +00:00
Igor Sysoev c021c4315d NGX_OPEN_FILE_DIRECTIO_OFF 2008-10-16 13:31:00 +00:00
Igor Sysoev ed4d05926a bump version 2008-10-16 13:20:47 +00:00
Igor Sysoev b12e38c000 release-0.7.19 tag 2008-10-13 15:16:12 +00:00
Igor Sysoev 1510fef89e nginx-0.7.19-RELEASE 2008-10-13 15:16:11 +00:00
Igor Sysoev 8bcd5ce3d5 bump version 2008-10-13 13:23:18 +00:00
Igor Sysoev 452e448512 release-0.7.18 tag 2008-10-13 13:18:29 +00:00
Igor Sysoev 663041905b nginx-0.7.18-RELEASE 2008-10-13 13:18:28 +00:00
Igor Sysoev f07fa18f25 do not set "Transfer-Encoding: chunked" for HEAD requests 2008-10-02 15:40:01 +00:00
Igor Sysoev 517ae5d12e fix r2122:
*) update file buf pointers,
*) avoid "zero buf" alert
2008-10-02 15:38:26 +00:00
Igor Sysoev c2646477f2 *) ngx_http_upstream_test_next()
*) add proxy_next_upstream http_502 and http_504
*) fix http_503
2008-09-30 15:39:02 +00:00
Igor Sysoev 625381a2c1 ngx_http_upstream_intercept_errors() 2008-09-30 14:57:09 +00:00
Igor Sysoev 21f6b381fc back out $random_index variable 2008-09-30 13:17:14 +00:00
Igor Sysoev 2a7898e6a6 refactor log_subrequest 2008-09-29 13:18:41 +00:00
Igor Sysoev a06848d177 update log_subrequest 2008-09-29 07:12:04 +00:00
Igor Sysoev fe26464ceb disable $realpath_root variable in a "root" directive 2008-09-29 04:47:22 +00:00
Igor Sysoev f78f3f7b14 fix the previous commit 2008-09-29 04:46:21 +00:00
Igor Sysoev 91f4425234 *) log_subrequest
*) flush variables in access log
2008-09-27 15:08:02 +00:00
Igor Sysoev 0f602f0f3a ngx_http_secure_link_module 2008-09-27 13:22:10 +00:00
Igor Sysoev 7bd0e4f5ab $realpath_root 2008-09-27 11:53:41 +00:00
Igor Sysoev e6d048635d $random_index variable 2008-09-27 11:48:28 +00:00
Igor Sysoev 866354a7e1 real_ip_header supports any header 2008-09-25 19:51:56 +00:00
Igor Sysoev 64cfd2ead9 underscores_in_headers 2008-09-24 14:02:50 +00:00
Igor Sysoev 0bc18748a1 dynamic accept threshold 2008-09-19 12:47:13 +00:00
Igor Sysoev abf2c011ff fix grammar 2008-09-17 08:03:58 +00:00
Igor Sysoev fe6ecb318d bump version 2008-09-15 17:10:23 +00:00
Igor Sysoev e297836cdb release-0.7.17 tag 2008-09-15 16:59:31 +00:00
Igor Sysoev d815760b97 nginx-0.7.17-RELEASE 2008-09-15 16:59:30 +00:00
Igor Sysoev c0507a61d3 set request handlers, this fixes complex proxied 400 handler with SSI includes 2008-09-15 16:44:37 +00:00
Igor Sysoev d07d1a257f $pid 2008-09-15 16:41:08 +00:00
Igor Sysoev 6b71af298f disable directio for unaligned reads in Linux 2008-09-12 13:50:12 +00:00
Igor Sysoev 7d2930d1fa disable directio for access_log with variables 2008-09-12 13:44:10 +00:00
Igor Sysoev 7fe348df8f cache directio flag in open file cache 2008-09-12 13:39:51 +00:00
Igor Sysoev 6a38a40700 add filename to the log message 2008-09-11 15:52:11 +00:00
Igor Sysoev 066c84ada7 strip charset name quotes 2008-09-09 11:58:45 +00:00
Igor Sysoev b8e08f06e7 bump version 2008-09-08 09:49:22 +00:00
Igor Sysoev b67e38a37f release-0.7.16 tag 2008-09-08 09:42:42 +00:00
Igor Sysoev d1630ec501 nginx-0.7.16-RELEASE 2008-09-08 09:42:41 +00:00
Igor Sysoev a6f85e84d4 fix building on 64-bit platforms, introduced in r2232 2008-09-08 09:33:37 +00:00
Igor Sysoev e13db0c3ee bump version 2008-09-08 08:47:00 +00:00
Igor Sysoev 691d732a71 release-0.7.15 tag 2008-09-08 08:36:23 +00:00
Igor Sysoev d271b4e52e nginx-0.7.15-RELEASE 2008-09-08 08:36:22 +00:00
Igor Sysoev 259fc2cfed allow underscores in client request header lines 2008-09-08 08:26:42 +00:00
Igor Sysoev b99e5f6c2e ngx_http_random_index_module 2008-09-05 15:45:55 +00:00
Igor Sysoev 4c972fac9d *) autoconfigure struct dirent capabilities
*) move src/os/.../ngx_types.h's content into src/os/.../ngx_files.h and
   delete src/os/.../ngx_types.h
2008-09-05 15:43:34 +00:00
Igor Sysoev 6d9843a4f1 remove unused #include's 2008-09-05 15:25:47 +00:00
Igor Sysoev 3aa7950789 style fix 2008-09-05 14:53:17 +00:00
Igor Sysoev 7e50cdf90d *) handle unaligned file part for directio
*) disable sendfile in directio mode
2008-09-05 14:48:47 +00:00
Igor Sysoev ef78cf29da split ngx_output_chain() 2008-09-03 10:01:29 +00:00
Igor Sysoev 5507c4b070 bump version 2008-09-01 15:44:57 +00:00
Igor Sysoev 40040b129b release-0.7.14 tag 2008-09-01 15:31:57 +00:00
Igor Sysoev 902fff21ae nginx-0.7.14-RELEASE 2008-09-01 15:31:56 +00:00
Igor Sysoev 956a1735ca fix building by msvc introduced in r2223 2008-09-01 15:17:54 +00:00
Igor Sysoev 1a3f82e132 escape a query string characters taken from URI while rewrite 2008-09-01 14:43:38 +00:00
Igor Sysoev 85951d5d72 *) listen ssl
*) no default ssl_cetificate and ssl_cetificate_key
2008-09-01 14:19:01 +00:00
Igor Sysoev 4bb5fe37a8 style fix: remove tabs and trailing spaces 2008-09-01 14:05:20 +00:00
Igor Sysoev 0dde4c40f7 test conf file size, this fixes OpenBSD's "nginx -c /tmp/" bug 2008-09-01 13:59:11 +00:00
Igor Sysoev 6c282650f4 use ngx_pmemalign() to allocate radix pages 2008-09-01 13:52:55 +00:00
Igor Sysoev 865600609c ngx_timezone_update() 2008-08-30 19:52:07 +00:00
Igor Sysoev 01355945ea set listen configuration to default server,
this fixes the case, when default server is not the first one
2008-08-29 13:43:38 +00:00
Igor Sysoev 4a5a87868b remove unused debug log 2008-08-27 13:26:35 +00:00
Igor Sysoev 9533401ca5 quoted too long parameter error 2008-08-27 12:19:07 +00:00
Igor Sysoev c5ae410655 too long parameter error 2008-08-26 21:10:20 +00:00
Igor Sysoev 1e9fff8c6d remove never used macro 2008-08-26 21:05:59 +00:00
Igor Sysoev d976439aaf fix types 2008-08-26 21:04:06 +00:00
Igor Sysoev 0fb7f889e1 bump version 2008-08-26 17:23:27 +00:00
Igor Sysoev 9458a33542 release-0.7.13 tag 2008-08-26 17:19:08 +00:00
Igor Sysoev 343f8ce832 nginx-0.7.13-RELEASE 2008-08-26 17:19:07 +00:00
Igor Sysoev 0f05c9f143 fix build on Linux and Solaris introduced in r2200 2008-08-26 17:15:11 +00:00
Igor Sysoev c9e43df8f1 bump version 2008-08-26 16:23:14 +00:00
Igor Sysoev e765939790 release-0.7.12 tag 2008-08-26 16:13:44 +00:00
Igor Sysoev b486ce715c nginx-0.7.12-RELEASE 2008-08-26 16:13:43 +00:00
Igor Sysoev c6aff78786 fix bugs introduced in r2204 2008-08-26 16:11:30 +00:00
Igor Sysoev d7d96c3c6d gzip_disable msie6 2008-08-26 15:09:28 +00:00
Igor Sysoev a9b2c85779 fix divide by zero if max_fails=0 2008-08-26 14:34:16 +00:00
Igor Sysoev 92a5ac81cf *) refactor ngx_parse_inet_url()
*) refactor ngx_parse_unix_domain_url()
*) delete unused ngx_url_t fields
2008-08-26 14:24:14 +00:00
Igor Sysoev 5bc7d0ead2 *) refactor ngx_ptocidr()
*) allow address without bitmask
*) thus now ngx_http_geo_module accepts addresses without bitmask
2008-08-26 14:19:37 +00:00
Igor Sysoev 06bf61981c ngx_strlchr() 2008-08-26 14:16:36 +00:00
Igor Sysoev 6b91bca1d7 split ngx_parse_url() 2008-08-22 13:36:56 +00:00
Igor Sysoev 75fedd3812 fix building on FreeBSD prior to 4.8, it has no GLOB_NOMATCH 2008-08-22 12:54:32 +00:00
Igor Sysoev f60b7174b1 ngx_sock_ntop() takes family from sockaddr, remove duplicate field 2008-08-21 19:24:07 +00:00
Igor Sysoev 95cf37a78f *) remove zero termination in ngx_inet_ntop() and ngx_sock_ntop()
*) use ngx_snprintf() in ngx_inet_ntop() and ngx_sock_ntop()
   as they are called just once per connection
*) NGX_INET_ADDRSTRLEN
2008-08-21 18:47:23 +00:00
Igor Sysoev 77d136e981 call ngx_http_xslt_filter_exit() 2008-08-21 18:21:40 +00:00
Igor Sysoev 8a825218e5 server_name "" support 2008-08-21 12:56:10 +00:00
Igor Sysoev 7e1b5e1c23 add Google Earth MIME types 2008-08-19 19:50:53 +00:00
Igor Sysoev f2376c950d fix $r->header_in() for "User-Agent", "Connection", and "Host"
broken in r2005, r2006, and r2008.
2008-08-19 19:40:45 +00:00
Igor Sysoev 646af391c9 leave HEAD method while error_page redirection 2008-08-19 18:55:46 +00:00
Igor Sysoev c403214b13 do not discard body while error_page redirection 2008-08-19 12:23:18 +00:00
Igor Sysoev f996fa8332 bump version 2008-08-18 14:29:57 +00:00
Igor Sysoev 256429fd81 release-0.7.11 tag 2008-08-18 14:22:51 +00:00
Igor Sysoev 4cdcb8765a nginx-0.7.11-RELEASE 2008-08-18 14:22:50 +00:00
Igor Sysoev 88e23c207d remove text/css from default charset_types
as it does not usually require recoding
2008-08-18 13:38:17 +00:00
Igor Sysoev 254b8310be *) regex match must return NGX_OK to stop regex searching,
this fixes inclusive regex location
*) change NGX_HTTP_INTERNAL_SERVER_ERROR to NGX_ERROR
2008-08-17 18:02:55 +00:00
Igor Sysoev 00b8dd8287 fix noregex for inclusive locations 2008-08-17 17:58:16 +00:00
Igor Sysoev 3472513983 proxy_ssl_session_reuse 2008-08-17 17:47:52 +00:00
Igor Sysoev 2a671cd3a1 disable original URI usage in proxy_pass after X-Accel-Redirect 2008-08-17 17:44:08 +00:00
Igor Sysoev 23588587df allow file existence test for POST requests in static module 2008-08-17 17:42:42 +00:00
Igor Sysoev 84f3bd312a ignore NGX_EACCES error while directory test 2008-08-17 17:38:48 +00:00
Igor Sysoev f1e566ff19 fix log message 2008-08-15 20:14:49 +00:00
Igor Sysoev 4abe8c6d51 bump version 2008-08-13 16:59:16 +00:00
Igor Sysoev b163a66a21 release-0.7.10 tag 2008-08-13 16:53:32 +00:00
Igor Sysoev 7dc963130e nginx-0.7.10-RELEASE 2008-08-13 16:53:31 +00:00
Igor Sysoev 8c7975d2ad restore connection address on request closure,
this fixes the issue when a frontend before nginx sends various client
connections via keepalive connection to nginx
2008-08-13 16:31:01 +00:00
Igor Sysoev 2776f9114a *) fix segfaults in types hash
*) fix inheritance: default hash instead of inherited one
2008-08-13 16:25:48 +00:00
Igor Sysoev 7da3929235 disable error_page loop in 500 error when recursive errors are enabled 2008-08-13 09:00:13 +00:00
Igor Sysoev 2e0ba6a9bd exit on libxslt test failure 2008-08-13 08:32:35 +00:00
Igor Sysoev b87f997b6b fix ngx_cpp_test_module configure 2008-08-13 08:29:27 +00:00
Igor Sysoev 4b6d704dc5 bump version 2008-08-12 15:46:34 +00:00
Igor Sysoev 2ed2ac1904 release-0.7.9 tag 2008-08-12 15:34:09 +00:00
Igor Sysoev bbc8da01bb nginx-0.7.9-RELEASE 2008-08-12 15:34:08 +00:00
Igor Sysoev 91e04b5d2c fix the case when unset domain.tld was matched by *.domain.tld 2008-08-12 15:28:19 +00:00
Igor Sysoev c2eec199ec *) charset_types
*) change of default charset types
*) addition_types
2008-08-12 13:17:08 +00:00
Igor Sysoev 03a9d6b399 use hash in gzip_types, ssi_types, and sub_filter_types 2008-08-12 13:11:36 +00:00
Igor Sysoev b0dc32eec3 backout both r2162 and r2128 and implement a new fix 2008-08-12 12:04:49 +00:00
Igor Sysoev be76a05b53 check daily time range 2008-08-11 17:50:37 +00:00
Igor Sysoev 545e30b14e expires daily time 2008-08-11 15:28:35 +00:00
Igor Sysoev 41d59b59bd ngx_next_time() 2008-08-11 15:28:15 +00:00
Igor Sysoev 5eb3a4f909 SSL connection readiness is required for level-triggered events only,
broken in r2128
2008-08-11 15:25:40 +00:00
Igor Sysoev 2ec5d3dbe8 consider log_not_found while testing index files 2008-08-11 15:22:40 +00:00
Igor Sysoev 7ef4a7af61 clear Last-Modified; set content-type and length for main request only 2008-08-06 13:18:57 +00:00
Igor Sysoev 416dd28ddc disable ranges, because xslt filter runs after range body filter 2008-08-06 09:38:34 +00:00
Igor Sysoev b9b9499840 ngx_cpp_test_module 2008-08-05 19:32:50 +00:00
Igor Sysoev b467cb72b2 reuse compiled DTD hash in different locations, add DTD cleanup 2008-08-05 19:05:15 +00:00
Igor Sysoev a8c8cfd097 update debug logging 2008-08-05 15:19:21 +00:00
Igor Sysoev 94c55307bc reuse compiled XSLT tree in different locations 2008-08-05 14:27:49 +00:00
Igor Sysoev ce6a5a9447 xsl:output's media-type and encoding support 2008-08-05 14:24:16 +00:00
Igor Sysoev 618fc44383 we do not need dtd->name 2008-08-05 13:08:35 +00:00
Igor Sysoev 97264f520e xslt_stylesheet should be valid for location only 2008-08-05 13:07:42 +00:00
Igor Sysoev 1490aa1577 fix xslt module context levels 2008-08-05 06:21:15 +00:00
Igor Sysoev 963e96e078 update debug logging 2008-08-04 21:51:36 +00:00
Igor Sysoev 4ec2c572cb style fix 2008-08-04 20:25:51 +00:00
Igor Sysoev ca64d981f8 fix building by bcc broken in r2143 2008-08-04 20:23:21 +00:00
Igor Sysoev f239450073 bump version 2008-08-04 16:45:52 +00:00
Igor Sysoev 0170bf4edf release-0.7.8 tag 2008-08-04 15:46:35 +00:00
Igor Sysoev 892cb4eb18 nginx-0.7.8-RELEASE 2008-08-04 15:46:34 +00:00
Igor Sysoev 046c266abc Solaris directio() 2008-08-04 15:32:10 +00:00
Igor Sysoev 8f1faed1d4 fix building by msvc8 introduced in r2127 2008-08-04 14:56:25 +00:00
Igor Sysoev 542e079b0e update comment 2008-08-04 14:54:12 +00:00
Igor Sysoev 107ef081fc if upstream sent a location header without status use 302 2008-08-04 14:53:16 +00:00
Igor Sysoev 99dbc09d5b ngx_http_xslt_filter_module 2008-08-04 14:48:15 +00:00
Igor Sysoev 41a9c12b44 test Content-Type via hash:
*) ngx_http_test_content_type()
*) ngx_http_types_slot()
*) ngx_http_merge_types()
2008-08-04 11:29:09 +00:00
Igor Sysoev 97562db601 $arg_... variable 2008-08-04 11:10:52 +00:00
Igor Sysoev 488629350b ngx_hash_strlow() 2008-08-04 10:18:36 +00:00
Igor Sysoev 7648ef4763 ngx_strlow() 2008-08-04 10:07:00 +00:00
Igor Sysoev 9c32f5b9c3 fix building by bcc broken in r2130 2008-08-04 09:14:30 +00:00
Igor Sysoev e857ecd7df fix conflicting names "true" and "false" 2008-07-31 07:55:46 +00:00
Igor Sysoev 524a1575b1 bump version 2008-07-30 13:38:49 +00:00
Igor Sysoev 934b5d51ca release-0.7.7 tag 2008-07-30 12:55:04 +00:00
Igor Sysoev f0ba17d279 nginx-0.7.7-RELEASE 2008-07-30 12:55:03 +00:00
Igor Sysoev bf12c62e56 directio 2008-07-30 12:34:04 +00:00
Igor Sysoev 825b7e8039 *) move Darwin support to separate files
*) Darwin sendfile() support
2008-07-30 12:18:07 +00:00
Igor Sysoev 056c6b563b update connection readiness after SSL handshake,
this fixes mail proxy SSL connection hanging if level-triggered event is used
2008-07-30 06:12:30 +00:00
Igor Sysoev 16044c276a case insensitive file system location support provided by locale only 2008-07-29 16:55:11 +00:00
Igor Sysoev 261287b0be rename ngx_utf_...() to ngx_utf8_...() 2008-07-29 14:41:34 +00:00
Igor Sysoev 958a82efdd fix typo 2008-07-29 14:31:03 +00:00
Igor Sysoev 1754fe97a7 *) ssl_verify_client ask
*) test ssl_client_certificate for ssl_verify_client
*) $ssl_client_cert adds TAB before each line except first one
*) $ssl_client_raw_cert contains certificate as is
2008-07-29 14:29:02 +00:00
Igor Sysoev 123a680e3b allow range for partial flv response 2008-07-29 13:58:56 +00:00
Igor Sysoev 427cb8372c support several buf's for single-part range
patch by Maxim Dounin
2008-07-29 13:58:13 +00:00
Igor Sysoev d8db68a729 fix utf-8 names in autoindex 2008-07-25 14:29:05 +00:00
Igor Sysoev d946ce369e fix ranges without Content-Type 2008-07-23 16:30:42 +00:00
Igor Sysoev 93387937cf split ngx_http_range_filter_module 2008-07-23 16:18:37 +00:00
Igor Sysoev 64e2848395 handle connect()'s EAGAIN on Linux 2008-07-09 15:42:13 +00:00
Igor Sysoev 0762a81a11 bump version 2008-07-07 12:19:57 +00:00
Igor Sysoev edf88b01f0 release-0.7.6 tag 2008-07-07 09:43:22 +00:00
Igor Sysoev a58f8e97e1 nginx-0.7.6-RELEASE 2008-07-07 09:43:21 +00:00
Igor Sysoev c6231f4434 always test root existence for access_log with variables 2008-07-07 09:26:13 +00:00
Igor Sysoev 4c9b373d71 allow several values in query string 2008-07-04 12:59:53 +00:00
Igor Sysoev 41b91d49ec show an error message for invalid parameter 2008-07-03 19:19:45 +00:00
Igor Sysoev bece4041ad bump version 2008-07-01 07:38:28 +00:00
Igor Sysoev 0a85b9c962 release-0.7.5 tag 2008-07-01 07:22:01 +00:00
Igor Sysoev 235780a168 nginx-0.7.5-RELEASE 2008-07-01 07:22:00 +00:00
Igor Sysoev e102e4d09a nginx could not be build without gzip, introduced in r2052 2008-07-01 06:31:16 +00:00
Igor Sysoev d979cfcfc8 NULL script in default access_log 2008-07-01 06:26:48 +00:00
Igor Sysoev 435ed70b96 fix error when response parsed by sub filter, then by SSI filter
and some response parts are output as file buffers
2008-06-30 19:10:06 +00:00
Igor Sysoev a93739b2ce fix variable access_log merging 2008-06-30 15:51:28 +00:00
Igor Sysoev e5f979d858 fix error message 2008-06-30 15:32:57 +00:00
Igor Sysoev 789e3f2ad8 bump version 2008-06-30 12:46:40 +00:00
Igor Sysoev 4a7b8fed0c release-0.7.4 tag 2008-06-30 12:38:50 +00:00
Igor Sysoev 60412e4e26 nginx-0.7.4-RELEASE 2008-06-30 12:38:49 +00:00
Igor Sysoev bfe44ae438 -g switch 2008-06-30 12:35:16 +00:00
Igor Sysoev a1ef4c7622 variables in access_log 2008-06-30 12:27:24 +00:00
Igor Sysoev 24a95941e4 fix comment 2008-06-30 12:12:16 +00:00
Igor Sysoev 6986daa34c fix the previous commit 2008-06-30 12:11:47 +00:00
Igor Sysoev ae73eb9661 use ngx_file_info() and test uniq if file is already open 2008-06-26 16:10:13 +00:00
Igor Sysoev c66dcda68a ngx_memzero() ngx_open_file_info_t 2008-06-26 14:07:59 +00:00
Igor Sysoev 52429def53 the "Expect" header support 2008-06-26 13:00:39 +00:00
Igor Sysoev 4da9fcd90d fix bug when inactive subrequest is truncated,
if output_buffers are less than subrequest size
2008-06-26 12:45:37 +00:00
Igor Sysoev 1bd3458bfd fix switch 2008-06-26 07:59:30 +00:00
Igor Sysoev 29dd032e46 refactor obscure code 2008-06-25 14:56:14 +00:00
Igor Sysoev 5868a5320d initialize of.uniq in ngx_open_cached_file() 2008-06-23 13:35:34 +00:00
Igor Sysoev 3b22f65e3f prepare to allow various number of connections in child processes 2008-06-23 13:23:29 +00:00
Igor Sysoev 3556721e2e change useless ngx_pcalloc() to ngx_pnalloc() 2008-06-23 12:27:03 +00:00
Igor Sysoev 9187c5481f bump version 2008-06-23 10:50:18 +00:00
Igor Sysoev 4f172e70ba release-0.7.3 tag 2008-06-23 10:34:58 +00:00
Igor Sysoev 425e96bd00 nginx-0.7.3-RELEASE 2008-06-23 10:34:57 +00:00
Igor Sysoev eb9d6d0b66 fix max size allocated from pool 2008-06-21 06:40:32 +00:00
Igor Sysoev c905f0ef73 fix the previous commit 2008-06-20 21:06:53 +00:00
Igor Sysoev e5f335d391 small optimization 2008-06-20 20:57:40 +00:00
Igor Sysoev d47c831491 auto detect https redirect in rewrite 2008-06-20 14:48:28 +00:00
Igor Sysoev f1008bed9b change RSS MIME type 2008-06-20 14:43:17 +00:00
Igor Sysoev 98054926fb fix "proxy_pass https://..." broken in r1427 2008-06-20 14:42:54 +00:00
Igor Sysoev 4f717f2ce9 "gzip_vary on" always sends "Vary: Accept-Encoding" header 2008-06-20 14:41:03 +00:00
Igor Sysoev f87fb20c0b disable charset if there is "Content-Encoding" header 2008-06-20 14:33:36 +00:00
Igor Sysoev 0ebc285aa0 *) back out r2040
*) refactor ngx_palloc()
*) introduce ngx_pnalloc()
*) additional pool blocks have smaller header
2008-06-17 15:00:30 +00:00
Igor Sysoev 90b7e712ce bump version 2008-06-16 09:11:12 +00:00
Igor Sysoev 9dc26f1462 release-0.7.2 tag 2008-06-16 09:04:23 +00:00
Igor Sysoev f93c1d0e1b nginx-0.7.2-RELEASE 2008-06-16 09:04:22 +00:00
Igor Sysoev 6bf65f677d $ssl_client_cert 2008-06-16 05:54:18 +00:00
Igor Sysoev d512987c1e DH parameters, ssl_dhparam 2008-06-16 05:51:32 +00:00
Igor Sysoev 1c3b27b4bd after URI was rewritten location configuration should be to a server's null one 2008-06-15 19:07:35 +00:00
Igor Sysoev fe8aa0c4d4 fix building without PCRE introduced in r2023 2008-06-07 12:08:38 +00:00
Igor Sysoev e2bb451169 style fix 2008-05-28 12:27:08 +00:00
Igor Sysoev 29aacafb55 fix building by bcc/etc introduced in r2038 2008-05-28 12:26:20 +00:00
Igor Sysoev 413dfbbd79 *) add ngx_palloc_aligned() to allocate explicitlty aligned memory
*) allows non-aligned memory blocks for small allocations and for odd
   length strings on all platforms
*) use ngx_palloc_aligned()
2008-05-27 09:37:40 +00:00
Igor Sysoev b3699723c6 add args in redirect to a directory 2008-05-26 18:57:43 +00:00
Igor Sysoev 25a4442187 fix debug logging 2008-05-26 18:49:36 +00:00
Igor Sysoev 1430110631 fix error log message 2008-05-26 10:54:59 +00:00
Igor Sysoev ad12f1268f bump version 2008-05-26 09:54:17 +00:00
Igor Sysoev 8ce1ea18ef release-0.7.1 tag 2008-05-26 09:32:31 +00:00
Igor Sysoev 7ad6b28081 nginx-0.7.1-RELEASE 2008-05-26 09:32:30 +00:00
Igor Sysoev f4e540c64d ssl_session_cache none 2008-05-26 07:14:13 +00:00
Igor Sysoev 889d7a8301 read channel until EAGAIN 2008-05-25 18:27:38 +00:00
Igor Sysoev 875f90f6d2 remove directives deprecated in 0.3.x 2008-05-24 15:48:50 +00:00
Igor Sysoev 88335cbce8 *) remove optimize_host_names
*) deprecate optimize_server_names: it is not needed since
   server_name_in_redirect introduction
2008-05-24 15:43:48 +00:00
Igor Sysoev 0ffe02a0e4 move configuration phase only field to the end of structure 2008-05-24 14:46:46 +00:00
Igor Sysoev a2eddf1bfe locations tree 2008-05-24 14:14:13 +00:00
Igor Sysoev 7aff7dd9c0 new ngx_queue functions 2008-05-24 14:10:01 +00:00
Igor Sysoev 585631d84d delete useless lines 2008-05-22 14:28:25 +00:00
Igor Sysoev 54fbbd0412 style fix 2008-05-22 12:09:41 +00:00
Igor Sysoev bcd1dd7156 axe never used variables 2008-05-22 11:11:16 +00:00
Igor Sysoev ce2ad1b855 split ngx_http_block() further 2008-05-22 11:07:08 +00:00
Igor Sysoev 705817b3f3 split ngx_http_block() 2008-05-22 09:57:47 +00:00
Igor Sysoev 0e1ec16ca3 delete outdated debug logging that only causes segfault if enabled 2008-05-22 07:10:36 +00:00
Igor Sysoev 6ac85cc51e style fix 2008-05-21 17:39:51 +00:00
Igor Sysoev cb47d6e8d8 fix building on modern Fedora 9 caused by IOV_MAX 2008-05-20 13:45:07 +00:00
Igor Sysoev 731adf0c13 bump version 2008-05-19 10:45:57 +00:00
Igor Sysoev 8209b36a29 release-0.7.0 tag 2008-05-19 10:34:42 +00:00
Igor Sysoev c74a54311f nginx-0.7.0-RELEASE 2008-05-19 10:34:41 +00:00
Igor Sysoev ad22d2b60a avoid recursive loop 2008-05-19 10:24:22 +00:00
Igor Sysoev 772a5e4739 expires modified 2008-05-16 15:18:50 +00:00
Igor Sysoev 9c47cb4a4c $uid_got and $uid_set may used at any time 2008-05-16 15:03:37 +00:00
Igor Sysoev 4b020d55bd $hostname variable 2008-05-16 14:39:06 +00:00
Igor Sysoev 098db9e3be simplify library autoconfigure 2008-05-16 14:32:58 +00:00
Igor Sysoev 3bacab2a81 DESTDIR support 2008-05-16 13:29:19 +00:00
Igor Sysoev 64d5c02d1f escape 0x00-0x1f, ", and \ in access log variables 2008-05-15 15:09:39 +00:00
Igor Sysoev ced97d1791 *) host in request line has priority
*) allow several Host headers
*) validate host
2008-05-15 14:44:47 +00:00
Igor Sysoev bae2ece30b style fix: remove tabs and trailing spaces 2008-05-14 07:54:52 +00:00
Igor Sysoev 2ef98d17f7 small fixes 2008-05-13 09:47:52 +00:00
Igor Sysoev 2d2fe700b9 test user agent in header callback 2008-05-13 09:18:58 +00:00
Igor Sysoev e8c98494f4 bump version 2008-05-12 10:08:28 +00:00
Igor Sysoev 6f23ab195b release-0.6.31 tag 2008-05-12 09:48:44 +00:00
Igor Sysoev a6a39d573c nginx-0.6.31-RELEASE 2008-05-12 09:48:43 +00:00
Igor Sysoev 222792eaf1 fix error introduced in r1273 and r1275:
nginx did not process FastCGI response if header was at end of FastCGI record
2008-05-08 09:53:22 +00:00
Igor Sysoev f993862bf2 fix segfault when file is deleted and open_file_cache_errors is off 2008-04-29 18:15:23 +00:00
Igor Sysoev 595653cfeb back out the previous commit 2008-04-29 18:14:45 +00:00
Igor Sysoev 21b408ec96 fix segfault when file is deleted and open_file_cache_errors is off 2008-04-29 14:39:15 +00:00
Igor Sysoev 9cfe2aecd4 bump version 2008-04-29 12:44:47 +00:00
Igor Sysoev 6a1f445b30 release-0.6.30 tag 2008-04-29 12:36:40 +00:00
Igor Sysoev 6228599d61 nginx-0.6.30-RELEASE 2008-04-29 12:36:39 +00:00
Igor Sysoev 1c6f157993 args support in static error_page 2008-04-29 10:06:43 +00:00
Igor Sysoev 7356cf9295 reset message 2008-04-29 09:35:06 +00:00
Igor Sysoev b630cae48d ignore glob no match error 2008-04-29 09:28:42 +00:00
Igor Sysoev 5536e55168 disable confusing messages about threads 2008-04-29 09:27:55 +00:00
Igor Sysoev 74af3ea26c reset looked at match 2008-04-29 06:15:56 +00:00
Igor Sysoev 297030bd24 get certificate info only for debug build 2008-04-28 08:52:32 +00:00
Igor Sysoev 4fbcbbbdef fix memory leak when ssl_verify_client is on 2008-04-28 08:50:39 +00:00
Igor Sysoev a4499b0924 Cygwin O_BINARY mode 2008-04-24 19:19:26 +00:00
Igor Sysoev c2fdce089d fix memory leak when ssl_verify_client is on 2008-04-23 18:57:25 +00:00
Igor Sysoev 991e0b912c small fix 2008-04-17 14:32:11 +00:00
Igor Sysoev 294cf16679 allow time without spaces in ngx_parse_time() 2008-04-17 14:23:20 +00:00
Igor Sysoev 11d2c0fedc change variable name 2008-04-16 19:33:23 +00:00
Igor Sysoev ba0cc5e2cb use more straightforward ngx_gmtime() implementation 2008-04-13 13:33:12 +00:00
Igor Sysoev f68e094d7a limit CNAME recursion 2008-04-12 07:29:20 +00:00
Igor Sysoev aba43cdba9 fix segfault 2008-04-11 09:15:07 +00:00
Igor Sysoev 83d444c5d0 use correct ngx_sprintf() formats 2008-04-10 17:27:07 +00:00
Igor Sysoev 7005534ff5 log unexpected qtype 2008-04-10 17:26:14 +00:00
Igor Sysoev 21377c009d take into account DNAME 2008-04-10 17:12:21 +00:00
Igor Sysoev 8ff3b99868 comment Gauss' formula 2008-04-10 09:37:12 +00:00
Igor Sysoev 1018aae845 grammar fix 2008-04-09 19:09:13 +00:00
Igor Sysoev 7d55d9dc2f small optimization 2008-04-09 18:56:36 +00:00
Igor Sysoev 82795fd08c return NXDOMAIN for ".." in host name 2008-04-09 14:45:39 +00:00
Igor Sysoev ee7770ec51 fix memory leak on resolver query send failure 2008-04-09 14:26:08 +00:00
Igor Sysoev 0640828e87 quick resolving handles u->resolved->ctx by itself 2008-04-09 14:20:17 +00:00
Igor Sysoev 582c0d74d3 fix peer sendfile capability 2008-04-04 12:07:13 +00:00
Igor Sysoev a38d9e3439 update previous commit 2008-03-24 17:17:17 +00:00
Igor Sysoev 24da7352fd use ngx_int_t in ngx_sort() callback 2008-03-24 13:04:02 +00:00
Igor Sysoev e3fb99f87a use dynamically allocated buffer in ngx_sort() 2008-03-23 19:58:54 +00:00
Igor Sysoev cc596f7559 it seems that malloc.h is required for Cygwin only
and breaks building on other platforms
2008-03-23 15:42:40 +00:00
Igor Sysoev b97e607c33 axe never used macro 2008-03-20 07:31:51 +00:00
Igor Sysoev 1392f827fe bump version 2008-03-18 14:51:09 +00:00
Igor Sysoev 2904fc7a81 release-0.6.29 tag 2008-03-18 14:11:56 +00:00
Igor Sysoev 9fd10cd346 nginx-0.6.29-RELEASE 2008-03-18 14:11:55 +00:00
Igor Sysoev e308649c82 ngx_google_perftools_module 2008-03-18 10:36:27 +00:00
Igor Sysoev 56d658736f low some SSL handshake errors level 2008-03-18 10:35:00 +00:00
Igor Sysoev 625e47eff4 use ngx_ext_rename_file() in proxy/fastcgi_store 2008-03-17 13:07:35 +00:00
Igor Sysoev 3cfddc90e1 some perl builds require my_perl for PERL_SYS_TERM() 2008-03-17 08:58:07 +00:00
Igor Sysoev 2b1f24f6b0 fastcgi params debug logging 2008-03-16 18:03:10 +00:00
Igor Sysoev e0283b6ece speed up ngx_http_charset_recode() for 25%: google-perftools reported
that CPU usage of charset body filter has decreased from 7.5% to 5.5%
if gzipping is disabled
2008-03-16 16:52:15 +00:00
Igor Sysoev 48de2e9629 test the more likely case first 2008-03-16 16:47:16 +00:00
Igor Sysoev 83bbdf3309 use the more correct mask 2008-03-16 13:29:49 +00:00
Igor Sysoev 977d4a7972 style fix 2008-03-14 12:31:20 +00:00
Igor Sysoev 618948dc4a fix building on 64-bit platforms broken in r1900 2008-03-13 15:48:36 +00:00
Igor Sysoev bfb027f1a5 restore building --test-build-rtsig and --test-build-eventport on FreeBSD 6 2008-03-13 15:47:14 +00:00
Igor Sysoev b051b72e61 fix the previous commit 2008-03-13 13:00:40 +00:00
Igor Sysoev 540cb9b3aa fix case when errors are not cached,
and a file was not used often enough to keep open
and it has been removed before it was kept open
2008-03-13 12:59:25 +00:00
Igor Sysoev 229294d395 axe useless code 2008-03-13 12:34:59 +00:00
Igor Sysoev 1606b65d8e bump version 2008-03-13 06:39:00 +00:00
Igor Sysoev 2952451dc3 release-0.6.28 tag 2008-03-13 06:10:33 +00:00
Igor Sysoev 6ac97dd2d0 nginx-0.6.28-RELEASE 2008-03-13 06:10:32 +00:00
Igor Sysoev b0b12f8d91 fix typo 2008-03-12 21:10:48 +00:00
Igor Sysoev 1a00c2a554 fix r1921 2008-03-12 19:34:36 +00:00
Igor Sysoev 51aff08456 bump version 2008-03-12 13:37:29 +00:00
Igor Sysoev f8a06e5a60 release-0.6.27 tag 2008-03-12 13:27:11 +00:00
Igor Sysoev 8e1402bf7e nginx-0.6.27-RELEASE 2008-03-12 13:27:10 +00:00
Igor Sysoev 6754aabd79 use uname instead of often outdated header file 2008-03-11 16:29:18 +00:00
Igor Sysoev 5faa0de556 use correct version: real hex numbers 2008-03-11 16:27:44 +00:00
Igor Sysoev 830a7fd652 non cacheable $proxy_host and $proxy_port 2008-03-11 14:10:11 +00:00
Igor Sysoev 6bdb1e9451 invalidate SSL session if there is no valid client certificate 2008-03-10 14:47:07 +00:00
Igor Sysoev 4d74d56fbf fix large memory allocation in "error_page 495-497 /uri" 2008-03-10 14:45:41 +00:00
Igor Sysoev 9ea445750d do not change method while error redirection to named location 2008-03-10 14:36:42 +00:00
Igor Sysoev d0fb6c4044 disable rtsig automatic building in post 2.6.18 Linux kernels 2008-03-10 14:35:21 +00:00
Igor Sysoev 6e489c997f rtsig uses own poll code 2008-03-08 15:15:18 +00:00
Igor Sysoev bda142ac94 create dummy resolver in http context to inherit it in all servers 2008-03-06 08:48:55 +00:00
Igor Sysoev 923ff42e46 check duplicate resolver 2008-03-06 08:48:25 +00:00
Igor Sysoev 7c11652b25 decrease log level of connection errors while closing socket 2008-03-05 21:21:26 +00:00
Igor Sysoev 4863093640 ngx_resolve_name() frees ctx on immediate failure 2008-03-05 07:30:44 +00:00
Igor Sysoev fad16b3a9f reset r->content_handler in a named location 2008-03-04 14:57:07 +00:00
Igor Sysoev 63131f46a8 fix previous commit 2008-03-04 10:47:34 +00:00
Igor Sysoev f0590d13b0 use cf->cycle->new_log because at merge stage cf->pool->log is old log 2008-03-04 10:42:05 +00:00
Igor Sysoev 9db321bc4e fix r1903 2008-03-03 20:04:06 +00:00
Igor Sysoev acc951b0d9 included file name must be allocated in pool,
because it may be used in error message later
2008-03-03 17:12:05 +00:00
Igor Sysoev b2bf997644 fix r1490 2008-03-03 16:44:56 +00:00
Igor Sysoev 5fc9a66ef5 C++ compatibility 2008-03-03 16:32:16 +00:00
Igor Sysoev 64c52d8378 fix memory leak in long-lived non buffered connections 2008-03-03 10:42:00 +00:00
Igor Sysoev a24a8c96cc add "root" to the fastcgi example to set correct included DOCUMENT_ROOT 2008-02-28 20:44:16 +00:00
Igor Sysoev 8e773cdc3b cleanup resolver 2008-02-28 20:38:34 +00:00
Igor Sysoev 5372b96aba left open sockets were not really tested 2008-02-28 20:31:33 +00:00
Igor Sysoev 20a7e32435 fix memory leaks, use unlocked ngx_resolver_free() for seldom failed cases 2008-02-28 20:09:39 +00:00
Igor Sysoev ee7d212bdf static ngx_resolver_calloc() 2008-02-28 15:34:53 +00:00
Igor Sysoev bdfa98344c check port in upstream list 2008-02-21 13:58:45 +00:00
Igor Sysoev 5a53d35f7e use CMSG_LEN(), this fixes an alert "sendmsg() failed (9: Bad file descriptor)"
on some 64-bit platforms
2008-02-19 16:34:55 +00:00
Igor Sysoev 112f4b1165 avoid endless loop if epoll is used 2008-02-19 16:30:54 +00:00
Igor Sysoev bce20ada9f pass additional arguments in ngx_http_perl_call_handler() as SV 2008-02-16 14:29:44 +00:00
Igor Sysoev 174d85a985 fix previous commit 2008-02-16 14:24:43 +00:00
Igor Sysoev f064fb9a23 optimize $r->sleep 2008-02-16 14:23:14 +00:00
Igor Sysoev 0301dca171 do not resolve SMTP clients by default 2008-02-16 13:46:33 +00:00
Igor Sysoev 97d4e8106c delete unneeded dXSTARG 2008-02-15 13:57:55 +00:00
Igor Sysoev 92bff7d88a named locations in post_action 2008-02-15 12:46:40 +00:00
Igor Sysoev 2d46d11798 fix segfault if empty stub block is used second time 2008-02-14 16:03:48 +00:00
Igor Sysoev 2209d9e17e resolver in smtp proxy module 2008-02-13 13:50:04 +00:00
Igor Sysoev af519c8c3b length calculation did not take into account escaped symbols in arguments 2008-02-12 18:05:32 +00:00
Igor Sysoev bbdef43461 bump version 2008-02-11 15:27:44 +00:00
Igor Sysoev c4ae0b50aa release-0.6.26 tag 2008-02-11 15:22:26 +00:00
Igor Sysoev a74494ce4c nginx-0.6.26-RELEASE 2008-02-11 15:22:25 +00:00
Igor Sysoev 58a15e5a7d set absolute weight, this fixes bogus "no live upstream" case when
last upstream is down while live one has negative weight
2008-02-11 14:31:38 +00:00
Igor Sysoev ffca03813a add X-Accel-Charset to ingored header, fix X-Accel-Buffering 2008-02-11 14:02:28 +00:00
Igor Sysoev e881c923af test response length in proxy/fastcgi_store 2008-02-11 13:14:56 +00:00
Igor Sysoev 3ae8899767 fix order 2008-02-07 10:45:04 +00:00
Igor Sysoev 7033238125 fix order 2008-02-07 10:43:45 +00:00
Igor Sysoev 3e0e2592c3 fix order 2008-02-07 10:38:13 +00:00
Igor Sysoev ed17a5a76b fix return code 2008-02-07 08:57:07 +00:00
Igor Sysoev 02a5ce8dca fix r1879 2008-02-06 17:23:17 +00:00
Igor Sysoev d360e73c70 do not delete failed DNS request if there are waiting clients 2008-02-06 16:08:52 +00:00
Igor Sysoev ae671bed79 fix segfault if UDP connect() has failed 2008-02-06 16:01:35 +00:00
Igor Sysoev 5d76c1f897 low SSL handshake close notify alert error level 2008-02-04 20:46:58 +00:00
Igor Sysoev 18a1a9a9a6 low SSL handshake errors level 2008-02-01 14:05:18 +00:00
Igor Sysoev cc76e9c91f reset ready flag if no data is available,
this fixes endless loop at least in lingering close
2008-01-31 15:36:33 +00:00
Igor Sysoev 09f6e25c89 treat time_t as unsigned time 2008-01-31 15:14:31 +00:00
Igor Sysoev 4e7e486b56 backout r1757, we really need SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 2008-01-31 15:10:45 +00:00
Igor Sysoev 5cffe1052c detect L2 cache line size for Intel Core 2008-01-29 07:06:18 +00:00
Igor Sysoev d10ae97e18 fix cache line size for Pentium 4 2008-01-29 06:58:47 +00:00
Igor Sysoev f092482ae7 fix building --test-build-rtsig and --test-build-eventport on FreeBSD 7 2008-01-28 16:24:01 +00:00
Igor Sysoev db38365ab7 add NGX_ENETDOWN, NGX_ENETUNREACH, and NGX_EHOSTDOWN 2008-01-25 14:57:35 +00:00
Igor Sysoev 929d881e1d pull all errors 2008-01-25 14:56:37 +00:00
Igor Sysoev 749922f792 limit string length 2008-01-24 15:18:58 +00:00
Igor Sysoev 7b1670f1c5 use correct type cast 2008-01-24 15:18:17 +00:00
Igor Sysoev 2257b8aea1 fix bogus crit log message "SSL_shutdown() failed" introduced in r1755 2008-01-22 16:04:35 +00:00
Igor Sysoev ec32b25b84 fix building by msvc introduced in r1817 2008-01-22 15:16:38 +00:00
Igor Sysoev 9b813cffc8 allow zero length in %*s 2008-01-22 15:13:01 +00:00
Igor Sysoev c2d454a9c4 fix building by bcc introduced by r1831 2008-01-22 15:09:55 +00:00
Igor Sysoev 2ebe2174bc pull all errors 2008-01-10 08:45:00 +00:00
Igor Sysoev c366bd9136 grammar fix 2008-01-10 08:36:14 +00:00
Igor Sysoev 6ddfa43a74 fix building by gcc42, etc. introduced in r1858 2008-01-09 15:27:27 +00:00
Igor Sysoev e15b10b8e9 add code missed in r1856 2008-01-09 08:21:57 +00:00
Igor Sysoev aea406bbad update GET method text in an subrequest 2008-01-08 21:06:38 +00:00
Igor Sysoev 79fba80985 axe old flag remained after ancient "post_accept_timeout" directive 2008-01-08 20:55:27 +00:00
Igor Sysoev cfd21584ef add code missed in r1830 2008-01-08 20:51:06 +00:00
Igor Sysoev 4dda2bd7a6 bump version 2008-01-08 13:05:18 +00:00
Igor Sysoev c25dfc95ab fix CHANGES 2008-01-08 12:45:10 +00:00
Igor Sysoev 87900a50eb release-0.6.25 tag 2008-01-08 12:31:36 +00:00
Igor Sysoev 34a4ac6b39 nginx-0.6.25-RELEASE 2008-01-08 12:31:35 +00:00
Igor Sysoev e559b52f2f style fix: remove trailing space 2008-01-08 11:33:14 +00:00
Igor Sysoev ff3410aa48 workaround for Linux 2.6 OpenVZ 2008-01-08 11:31:50 +00:00
Igor Sysoev 8a712e4a15 ngx_http_gzip_static_module should DECLINE request 2008-01-08 10:35:50 +00:00
Igor Sysoev 39de6a4033 fix comment 2008-01-05 19:07:10 +00:00
Igor Sysoev 26e737a2c8 change order 2008-01-04 11:54:55 +00:00
Igor Sysoev 912893e685 fix socket leak if deferred accept was used 2008-01-04 09:32:12 +00:00
Igor Sysoev edd04ac52f use ngx_ext_rename_file() in PUT 2008-01-03 22:18:21 +00:00
Igor Sysoev e58627919e add declaration missed in previous commit 2008-01-03 22:17:27 +00:00
Igor Sysoev 7d96521689 transform ngx_create_path_and_rename_file() to ngx_ext_rename_file() 2008-01-03 22:16:37 +00:00
Igor Sysoev 7f553e9bb6 do not delete target until all tests will be done,
fix single file COPY/MOVE
2008-01-03 21:44:38 +00:00
Igor Sysoev 18ccec6eb6 add log 2008-01-03 21:29:01 +00:00
Igor Sysoev dcfcf08842 add comment 2008-01-03 20:43:12 +00:00
Igor Sysoev 8d1eeee6c6 test URI/Destination collection/non-collection and Depth 2008-01-03 20:09:51 +00:00
Igor Sysoev d7037b6ea5 axe useless code 2008-01-03 20:06:09 +00:00
Igor Sysoev c691a0ed26 change order 2008-01-03 19:18:25 +00:00
Igor Sysoev cd4b71abc4 change status code, add log message, and test collection URI 2008-01-03 19:13:04 +00:00
Igor Sysoev cde0bc81f1 style fix 2008-01-03 17:21:13 +00:00
Igor Sysoev 316cbe4712 2008 year 2008-01-03 12:33:54 +00:00
Igor Sysoev 5ffbd97658 min_delete_depth 2007-12-30 11:46:03 +00:00
Igor Sysoev 071619f2ba log DELETE errors 2007-12-30 10:24:43 +00:00
Igor Sysoev 7b74191d0e axe useless code 2007-12-30 10:19:32 +00:00
Igor Sysoev 2aec60b9a3 change status code and add log message 2007-12-30 09:44:02 +00:00
Igor Sysoev f41d322859 log right request method 2007-12-30 09:11:19 +00:00
Igor Sysoev 72a91c756c axe useless r->server_name 2007-12-30 08:15:27 +00:00
Igor Sysoev b9c49e59ab log server address 2007-12-30 08:01:50 +00:00
Igor Sysoev 8991aa8f56 fix building by msvc introduced by r1807 2007-12-29 21:43:49 +00:00
Igor Sysoev e71222b0ba handle old "server_name *" 2007-12-29 19:05:21 +00:00
Igor Sysoev 2ed526073b fix comment 2007-12-29 16:55:31 +00:00
Igor Sysoev 74f3ad4579 satisfy all|any 2007-12-29 16:38:23 +00:00
Igor Sysoev baedf19d3a use ngx_http_server_addr() 2007-12-29 16:00:34 +00:00
Igor Sysoev 9901529164 several changes in server_name:
*) server_name_in_redirect directive and removal of the '*' stub
*) use server address in redirect if host can not be detected
*) ngx_http_server_addr()
*) allow wildcard and regex names to be a main server_name
*) DAV Destination header is tested against Host header
2007-12-29 15:30:39 +00:00
Igor Sysoev 915063fd16 condition declarations inside blocks update missed in r1705 2007-12-29 13:55:10 +00:00
Igor Sysoev ff873cf4dd set ngx_http_gzip_static module just before ngx_http_static_module 2007-12-29 08:38:42 +00:00
Igor Sysoev a11e6187da style fix: remove trailing spaces 2007-12-28 13:15:36 +00:00
Igor Sysoev dbadfc12d0 fix building --without-pcre 2007-12-28 13:15:11 +00:00
Igor Sysoev bc50034481 optimization 2007-12-27 20:32:43 +00:00
Igor Sysoev 4d079eba8e bump version 2007-12-27 18:47:33 +00:00
Igor Sysoev 5a965e8e98 release-0.6.24 tag 2007-12-27 18:43:54 +00:00
Igor Sysoev 1790ce2b3e nginx-0.6.24-RELEASE 2007-12-27 18:43:53 +00:00
Igor Sysoev fdcadd6b50 fix segfault introduced in r1780 2007-12-27 18:35:52 +00:00
Igor Sysoev 26089cd999 bump version 2007-12-27 15:39:06 +00:00
Igor Sysoev c875382d2a release-0.6.23 tag 2007-12-27 14:59:58 +00:00
Igor Sysoev bf41c7bec8 nginx-0.6.23-RELEASE 2007-12-27 14:59:57 +00:00
Igor Sysoev 61523817d5 backout r1790 2007-12-27 14:39:05 +00:00
Igor Sysoev f6630df22b ngx_http_gzip_static_module and gzip_disable 2007-12-27 14:21:59 +00:00
Igor Sysoev 3d9460a202 non-active request is not done 2007-12-27 14:20:50 +00:00
Igor Sysoev 8d81be062f allow memached_pass inside "if" block 2007-12-27 14:19:30 +00:00
Igor Sysoev da15b77684 inherit $memached_key index and memcached_pass upstream inside "if" block 2007-12-27 14:18:34 +00:00
Igor Sysoev 4ab51d5cb3 return NGX_DECLINED if access directives are not active,
this fixes case when satisfy any does not test active directives at all
2007-12-27 14:15:34 +00:00
Igor Sysoev 3936145497 use ngx_regex_exec_array() 2007-12-27 13:15:43 +00:00
Igor Sysoev 25427feac6 ngx_regex_exec_array() 2007-12-27 13:15:08 +00:00
Igor Sysoev b74ef369d0 call post_action for 499 2007-12-27 13:13:34 +00:00
Igor Sysoev 9702fd533b regex valid_referers were not inherited 2007-12-27 12:13:11 +00:00
Igor Sysoev 74bfa8ca4a optimization 2007-12-27 09:17:20 +00:00
Igor Sysoev e4a67eeba6 style fix 2007-12-27 08:40:14 +00:00
Igor Sysoev 93d1079897 create ssl buffer on demand and free it before keep-alive 2007-12-26 21:07:30 +00:00
Igor Sysoev efcf5c7468 ssl_session_cache off 2007-12-26 20:27:22 +00:00
Igor Sysoev 9a1e7464e1 optimization 2007-12-26 13:24:57 +00:00
Igor Sysoev 2590d6c241 style fix 2007-12-25 15:31:18 +00:00
Igor Sysoev 4b32db62b0 several fixes:
*) do not add event if file was used less than min_uses
*) do not rely upon event to avoid race conditions
*) ngx_open_file_lookup()
2007-12-25 10:46:40 +00:00
Igor Sysoev 2c27e0be14 use %*s format 2007-12-24 17:05:31 +00:00
Igor Sysoev 2729f9ede6 %*s format 2007-12-24 17:05:16 +00:00
Igor Sysoev c9d8ac563a open_file_cache_min_uses 2007-12-22 13:19:39 +00:00
Igor Sysoev 9b84b607d9 take MALLOC_OPTIONS=J into account in slab allocator 2007-12-22 11:06:53 +00:00
Igor Sysoev 6b6ca4b48c add missed dependences 2007-12-22 10:32:00 +00:00
Igor Sysoev 53998a95a4 tree.init_handler is never called 2007-12-21 17:50:49 +00:00
Igor Sysoev e75e2677c9 fix the previous commit 2007-12-21 17:23:41 +00:00
Igor Sysoev 5202af7573 open_file_cache_retest > open_file_cache_valid 2007-12-21 16:19:48 +00:00
Igor Sysoev e35d6ba22c fix the previous commit 2007-12-21 16:19:14 +00:00
Igor Sysoev d514f49f08 use ngx_queue.h 2007-12-21 15:33:15 +00:00
Igor Sysoev 273ac50acd clean rbtree node for all removals 2007-12-21 15:32:51 +00:00
Igor Sysoev 0c89e11d88 style fix 2007-12-21 15:24:59 +00:00
Igor Sysoev d7712faae2 fix STARTTLS prompt in SMTP 2007-12-21 10:24:59 +00:00
Igor Sysoev e02ad43419 embed sentinel 2007-12-20 21:29:52 +00:00
Igor Sysoev dac5d9ad46 use ngx_queue.h 2007-12-20 21:01:00 +00:00
Igor Sysoev 9176fbab73 embed session_rbtree and sentinel inside ngx_ssl_session_cache_t 2007-12-20 20:35:23 +00:00
Igor Sysoev 19132f7adb omit useless test 2007-12-20 20:30:45 +00:00
Igor Sysoev 135f78830c use ngx_time() instead of ngx_timeofday() 2007-12-20 20:11:45 +00:00
Igor Sysoev ad772dab83 remove SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER, we never need it,
the "bad write retry" error was caused by SSL_shutdown() error
2007-12-20 13:49:07 +00:00
Igor Sysoev 8425d35bc2 cleaning stale global SSL error 2007-12-20 13:04:20 +00:00
Igor Sysoev 2c227d3c34 SSL_shutdown() never returns -1, on error it returns 0.
This fixes incidental "bad write retry" errors.
2007-12-20 12:59:05 +00:00
Igor Sysoev 34da96a7cd bump version 2007-12-19 16:56:01 +00:00
Igor Sysoev b28fe8d795 release-0.6.22 tag 2007-12-19 16:44:39 +00:00
Igor Sysoev 52d5c32954 nginx-0.6.22-RELEASE 2007-12-19 16:44:38 +00:00
Igor Sysoev 17470252fd comment ngx_walk_tree() 2007-12-18 18:04:37 +00:00
Igor Sysoev d78a4d06fd fix comment 2007-12-18 15:12:33 +00:00
Igor Sysoev eeeb5c9fd4 ngx_create_hashed_filename() does not need ngx_file_t 2007-12-17 21:29:34 +00:00
Igor Sysoev 90d0e036c1 create the only cleanup 2007-12-17 21:23:05 +00:00
Igor Sysoev 663fbda196 style fix: remove trailing spaces 2007-12-17 21:20:12 +00:00
Igor Sysoev c70e255fa0 replace ngx_md5_text() with ngx_hex_dump() 2007-12-17 21:06:17 +00:00
Igor Sysoev c8bb8fbaaf log run cleanups clearly 2007-12-17 17:29:36 +00:00
Igor Sysoev c61f8cd4a8 optimize rbtree initialization and insert 2007-12-17 08:52:00 +00:00
Igor Sysoev 420323780a no answers in DNS response should be NXDOMAIN 2007-12-16 20:47:55 +00:00
Igor Sysoev 6f49134630 fix segfault if response will have CNAME only 2007-12-16 20:00:15 +00:00
Igor Sysoev 71b8deb9d0 restore environ for perl_destruct() 2007-12-16 11:58:16 +00:00
Igor Sysoev e338919d12 copy return values to perl's allocated memory 2007-12-16 11:57:27 +00:00
Igor Sysoev e6de03148d fix merge_slashes 2007-12-14 14:33:00 +00:00
Igor Sysoev 8aa97dc74d large_client_header_buffers did not free()ed before keep-alive 2007-12-12 15:42:39 +00:00
Igor Sysoev a0767cf8b5 $upstream_addr did not contain last address, the bug was introduced in r1659 2007-12-11 16:26:56 +00:00
Igor Sysoev a333df9cd9 style fix: remove trailing spaces 2007-12-10 12:30:09 +00:00
Igor Sysoev 54ba36eeb3 optimize r->upstream usage 2007-12-10 12:29:43 +00:00
Igor Sysoev 1e973c6d87 move condition declarations inside blocks where they are used 2007-12-10 12:09:51 +00:00
Igor Sysoev 7a17551f8a *) copy regex captures $1, $2, etc.
*) SV flags debug logging
2007-12-09 20:52:14 +00:00
Igor Sysoev 5b57cfa682 fix segfault when $r->has_request_body() is called with ready body 2007-12-09 19:30:30 +00:00
Igor Sysoev 30676327b2 *) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
this fixes fastcgi_catch_stderr segfault introduced in r1453
*) ngx_http_upstream_hide_headers_hash()
*) proxy/fastcgi pass_header/hide_header use
   ngx_http_upstream_hide_headers_hash()
2007-12-09 18:03:20 +00:00
Igor Sysoev 756c0243b0 return NGX_HTTP_UPSTREAM_INVALID_HEADER instead of NGX_HTTP_BAD_GATEWAY
to go to a next upstream on invalid_header condition
2007-12-09 14:50:19 +00:00
Igor Sysoev 285127fbbe return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header() 2007-12-09 08:22:35 +00:00
Igor Sysoev a04245d293 return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status 2007-12-09 08:08:56 +00:00
Igor Sysoev 2b7c295215 fix r1695 2007-12-08 22:12:37 +00:00
Igor Sysoev 9f65245a83 delete useless variable 2007-12-07 20:57:38 +00:00
Igor Sysoev 5f21421401 ngx_create_path_and_rename_file() 2007-12-07 20:22:03 +00:00
Igor Sysoev 79ce6f8f61 rename ngx_crc32_init() to ngx_crc32_table_init()
ngx_crc32_init(), ngx_crc32_update(), ngx_crc32_final()
2007-12-07 20:19:41 +00:00
Igor Sysoev 28bfe377e7 use malloc() in ngx_win32_rename_file, set crit level instead of error 2007-12-07 19:57:13 +00:00
Igor Sysoev 6694df5d91 bump version 2007-12-03 17:26:28 +00:00
Igor Sysoev eee67a7ed5 release-0.6.21 tag 2007-12-03 17:18:49 +00:00
Igor Sysoev c33ec0414c nginx-0.6.21-RELEASE 2007-12-03 17:18:48 +00:00
Igor Sysoev 23338af6e1 ngx_udp_recv() 2007-12-03 16:46:46 +00:00
Igor Sysoev ffeb47564a fix segfault 2007-12-03 15:47:35 +00:00
Igor Sysoev 4b011ec1f3 use ngx_rbtree_init() 2007-12-03 12:17:26 +00:00
Igor Sysoev 413cc634bf ngx_rbtree_init() 2007-12-03 12:17:15 +00:00
Igor Sysoev 927cf70a5f use ngx_queue_init() 2007-12-03 11:21:19 +00:00
Igor Sysoev fcb170fbca ngx_queue_init() 2007-12-03 11:21:07 +00:00
Igor Sysoev ce86f12a95 allow to use IP addresses without defined resolver 2007-12-03 10:05:19 +00:00
Igor Sysoev 6887ccefd2 style fix 2007-12-01 21:05:19 +00:00
Igor Sysoev e87de6618d axe old unused alert message 2007-12-01 20:31:59 +00:00
Igor Sysoev c02be5c16f style fix 2007-12-01 20:25:32 +00:00
Igor Sysoev 1d25090146 style fix: remove trailing spaces 2007-12-01 19:57:37 +00:00
Igor Sysoev 5cdf6f5f4b log how big fastcgi record 2007-12-01 14:23:53 +00:00
Igor Sysoev 3807c3c04e copy protocol value when large request line is copied,
this fixes error "fastcgi: the request record is too big"
2007-12-01 12:22:48 +00:00
Igor Sysoev 8d6f7dbed7 do not allow plain 0.9 request to HTTPS 2007-12-01 11:46:04 +00:00
Igor Sysoev 9c6d68aa3d zero ngx_url_t 2007-11-30 22:08:59 +00:00
Igor Sysoev 6105e092cf style fix 2007-11-30 22:08:29 +00:00
Igor Sysoev fe325a719e fix typo 2007-11-30 22:07:05 +00:00
Igor Sysoev be7424e3ae fix comment 2007-11-30 22:06:48 +00:00
Igor Sysoev 8009a9c41d ngx_parse_url() saves port text, this allows to use it in proxy host header 2007-11-28 19:55:31 +00:00
Igor Sysoev 7328fd5950 bump version 2007-11-28 19:17:24 +00:00
Igor Sysoev e245fee05f release-0.6.20 tag 2007-11-28 19:13:24 +00:00
Igor Sysoev bb766abfcd nginx-0.6.20-RELEASE 2007-11-28 19:13:23 +00:00
Igor Sysoev 90465507d8 fix segfault 2007-11-28 15:06:05 +00:00
Igor Sysoev 948878c194 delete unneeded declaration 2007-11-28 10:14:04 +00:00
Igor Sysoev 03730a612f bump version 2007-11-27 16:58:41 +00:00
Igor Sysoev 9419cbff24 release-0.6.19 tag 2007-11-27 16:53:15 +00:00
Igor Sysoev 90db0f409f nginx-0.6.19-RELEASE 2007-11-27 16:53:14 +00:00
Igor Sysoev 87d7092d20 do not delete resolver sources from release tarball 2007-11-27 16:47:16 +00:00
Igor Sysoev c6041e61db bump version 2007-11-27 16:25:32 +00:00
Igor Sysoev 0489025edf release-0.6.18 tag 2007-11-27 16:20:12 +00:00
Igor Sysoev a6897fea08 nginx-0.6.18-RELEASE 2007-11-27 16:20:11 +00:00
Igor Sysoev cddb620691 proxy_pass variables support 2007-11-27 13:34:13 +00:00
Igor Sysoev 73678216ea improve throughput with large limit_rate 2007-11-27 12:24:44 +00:00
Igor Sysoev 75d58f0295 log entire request line instead of URI only 2007-11-27 12:22:01 +00:00
Igor Sysoev 11992c39f2 add_header last-modified "" 2007-11-27 12:02:58 +00:00
Igor Sysoev 2a61e9f620 r->headers_out.refresh 2007-11-27 11:56:18 +00:00
Igor Sysoev 5ba863c9b0 set r->headers_out.location for non-local redirects 2007-11-27 11:52:37 +00:00
Igor Sysoev f30ab3ccb5 http resolver and resolver_timeout 2007-11-27 11:33:52 +00:00
Igor Sysoev 0c3195b9d6 use usec and pid as start value 2007-11-24 10:43:15 +00:00
Igor Sysoev 79d54be696 fix previous commit 2007-11-23 17:27:01 +00:00
Igor Sysoev b8b26eaf4b resolver 2007-11-23 17:13:26 +00:00
Igor Sysoev 859f375a06 update ngx_memcmp() 2007-11-23 17:00:11 +00:00
Igor Sysoev b0035d246d ngx_inet_addr() 2007-11-23 16:59:24 +00:00
Igor Sysoev 1884fd1343 ngx_queue.h 2007-11-23 16:32:50 +00:00
Igor Sysoev f8d3ec16b5 the simple expression has the same precision without overflow 2007-11-16 18:15:04 +00:00
Igor Sysoev 315fa5b74d bump version 2007-11-15 15:42:39 +00:00
Igor Sysoev c4290dc206 release-0.6.17 tag 2007-11-15 15:04:23 +00:00
Igor Sysoev 8c04610bf1 nginx-0.6.17-RELEASE 2007-11-15 15:04:22 +00:00
Igor Sysoev 64b3e3f88e enable getenv() and gmtime() in msvc8 2007-11-15 14:34:10 +00:00
Igor Sysoev f1dfba6181 64-bit time_t compatibility 2007-11-15 14:26:36 +00:00
Igor Sysoev 77ca451c35 msvc8 compatibility: it can not build with debug under Wine 2007-11-15 14:22:12 +00:00
Igor Sysoev 733bd4cb4e add msvc8 2007-11-15 11:00:06 +00:00
Igor Sysoev 4bce4da522 option -Yd has been deprecated in msvc8,
option -debugtype:coff is unsupported in msvc8
2007-11-15 10:59:07 +00:00
Igor Sysoev 4cfb5c76e2 enable precompiled headers for msvc7,
probably they were disabled because of some Wine bug
2007-11-15 10:25:30 +00:00
Igor Sysoev 23bf191614 fix typo 2007-11-14 14:58:27 +00:00
Igor Sysoev e2035917ad fix win32 ngx_read_fd() and ngx_write_fd() 2007-11-11 19:56:46 +00:00
Igor Sysoev b41a838b12 TransmitPackets(), ConnectEx(), and DisconnectEx() 2007-11-11 18:56:50 +00:00
Igor Sysoev 84c7b781d1 fix win32 glob 2007-11-11 17:50:47 +00:00
Igor Sysoev ae4a2523a4 omit unnecessary test, because NGX_ERROR == -1,
but r->headers_out.last_modified_time != -1 at this point
2007-11-09 15:43:43 +00:00
Igor Sysoev 68ca446285 If-Range support 2007-11-09 15:41:35 +00:00
Igor Sysoev f544967693 do not encode already encoded characters in msie_refresh 2007-11-09 13:17:58 +00:00
Igor Sysoev 8edffbc468 style and grammar fix 2007-11-09 13:12:25 +00:00
Igor Sysoev 268e77cdc2 fix autoindex for "alias /" 2007-11-08 15:21:54 +00:00
Igor Sysoev 90901080d0 fix gzip and SSL 2007-11-08 15:21:22 +00:00
Igor Sysoev eae2ca31df fix segfaults 2007-11-08 15:20:56 +00:00
Igor Sysoev abe0bd3d4a set status in correct place 2007-11-06 15:01:13 +00:00
Igor Sysoev d22059220c bump version 2007-10-29 14:09:12 +00:00
Igor Sysoev f316d58198 release-0.6.16 tag 2007-10-29 13:41:42 +00:00
Igor Sysoev aefee81bb5 nginx-0.6.16-RELEASE 2007-10-29 13:41:41 +00:00
Igor Sysoev 13b4ba87e3 use uname(2) instead of /proc/, this allows to run nginx in chroot 2007-10-26 16:38:53 +00:00
Igor Sysoev 7b5c8d0eb8 divide special response handling into several functions
fix "?" escaping introduced in r1467
2007-10-26 16:17:17 +00:00
Igor Sysoev 9c79d46bd9 compatibility with mget: space after HTTP/1.1 2007-10-26 11:34:10 +00:00
Igor Sysoev adb876b8c5 refactor index module: remove context 2007-10-23 14:16:00 +00:00
Igor Sysoev 222d6a3b90 change emerg to a warn for absolute index 2007-10-23 14:15:06 +00:00
Igor Sysoev 16dade19b6 fix mime type for absolute index 2007-10-23 14:10:38 +00:00
Igor Sysoev 3237929d65 64-bit update lost in r1355 2007-10-23 14:09:12 +00:00
Igor Sysoev 47df56d5d5 style fix 2007-10-22 15:22:08 +00:00
Igor Sysoev 39bd97db14 bump version 2007-10-22 11:24:05 +00:00
Igor Sysoev 2fc7fdc44b release-0.6.15 tag 2007-10-22 11:16:56 +00:00
Igor Sysoev 393d24e5a7 nginx-0.6.15-RELEASE 2007-10-22 11:16:55 +00:00
Igor Sysoev 5da76f13a5 fix building broken in r1593 2007-10-22 10:28:03 +00:00
Igor Sysoev 5c422fd820 unescape SSI include 2007-10-22 10:19:17 +00:00
Igor Sysoev bffca907d1 server_tokens 2007-10-22 10:17:34 +00:00
Igor Sysoev 42f2628016 fix typo 2007-10-22 10:15:48 +00:00
Igor Sysoev 56572af092 fix segfault 2007-10-22 10:15:27 +00:00
Igor Sysoev e3357b4b13 style fix 2007-10-18 16:20:21 +00:00
Igor Sysoev d9757fabbe style fix 2007-10-18 16:12:55 +00:00
Igor Sysoev d3dc3cb0a4 style fix 2007-10-18 16:05:48 +00:00
Igor Sysoev c2aa32b013 fix typo 2007-10-18 15:53:38 +00:00
Igor Sysoev 9fcc52f466 merge_slashes 2007-10-18 11:36:58 +00:00
Igor Sysoev 728c994e8d allow full URL without URI part: "GET http://host HTTP/1.0" 2007-10-18 11:33:31 +00:00
Igor Sysoev 2c6ba1646d gzip_vary 2007-10-18 11:29:34 +00:00
Igor Sysoev d8712ad9bb do not discard body if it has been already read 2007-10-18 11:29:15 +00:00
Igor Sysoev b3e07a9e02 Cygwin can not pass SCM_RIGHTS via unix socket, use signals 2007-10-18 11:28:21 +00:00
Igor Sysoev d5e8d2311f fix segfault if no server_name was defined 2007-10-17 13:22:26 +00:00
Igor Sysoev dc9206049d style fix 2007-10-17 13:21:20 +00:00
Igor Sysoev 144e68ff7c fix building broken in r1578 2007-10-16 19:22:27 +00:00
Igor Sysoev b0751fde34 delete code that should be deleted in r1576 2007-10-16 17:51:47 +00:00
Igor Sysoev 81c25d266f Cygwin support 2007-10-16 14:14:30 +00:00
Igor Sysoev d8e91f47be avoid segfault if poll is used and endless loop if select is used 2007-10-16 14:12:52 +00:00
Igor Sysoev cf09fc0add use ngx_sha1.h 2007-10-16 12:17:11 +00:00
Igor Sysoev 111b034ee8 ngx_sha1.h 2007-10-16 12:16:58 +00:00
Igor Sysoev 3e34d90164 ngx_md5.h 2007-10-16 11:59:47 +00:00
Igor Sysoev 72dd95b480 bump version 2007-10-15 11:32:09 +00:00
Igor Sysoev 53bf02b5b8 release-0.6.14 tag 2007-10-15 11:24:12 +00:00
Igor Sysoev 75dc423c05 nginx-0.6.14-RELEASE 2007-10-15 11:24:11 +00:00
Igor Sysoev ad8723ae80 use real weight, do not downground to one 2007-10-15 10:15:54 +00:00
Igor Sysoev 531115412f memcached did not set $upstream_response_time 2007-10-15 09:46:36 +00:00
Igor Sysoev 859fded207 fix segfault when $date_local or $date_gmt are used outside ssi module 2007-10-14 19:04:23 +00:00
Igor Sysoev 2e4e39296a fix English grammar 2007-10-14 18:56:15 +00:00
Igor Sysoev 1a344ced38 optimization 2007-10-10 13:58:47 +00:00
Igor Sysoev b8baad1936 style fix: remove double semicolons 2007-10-09 20:11:03 +00:00
Igor Sysoev 1faaf3ac9a allow access_log inside limit_except 2007-10-09 18:45:49 +00:00
Igor Sysoev 34f87ac373 %v fix lost in r1407 2007-10-09 18:44:59 +00:00
Igor Sysoev df7cac2b02 style fix: remove trailing spaces 2007-10-09 18:42:00 +00:00
Igor Sysoev 1b528b45da use pool instead of ngx_conf_t 2007-10-08 08:55:12 +00:00
Igor Sysoev 4f7f6b33a3 optimization 2007-10-08 04:59:26 +00:00
Igor Sysoev 21043e8ffe *) add sub_filter parser fix similar to r1261 in SSI parser
*) fix case when pattern is split between two buffers:
   it had been fixed in SSI parser long ago
2007-10-02 18:53:31 +00:00
Igor Sysoev a472d89407 fix r1552 and r1464: test max fails in correct peer 2007-10-02 12:34:16 +00:00
Igor Sysoev 6bf1224438 fix empty string replacement in sub_filter 2007-10-01 16:24:15 +00:00
Igor Sysoev 183b4db9f3 two commits those go together by mistake
*) fix gzip broken in r1544
*) fix memcached END test
2007-10-01 16:00:13 +00:00
Igor Sysoev 5e1a14b2b1 use ngx_strnstr() 2007-10-01 14:48:45 +00:00
Igor Sysoev 2c924bac25 ngx_strnstr() 2007-10-01 14:48:33 +00:00
Igor Sysoev 97ffb89fd5 fix r1464: test max fails in correct peer 2007-10-01 14:45:31 +00:00
Igor Sysoev 15ae439ba8 add comment 2007-10-01 13:00:30 +00:00
Igor Sysoev 24bcae3edb pass length clearly 2007-10-01 12:57:47 +00:00
Igor Sysoev 1f187b3892 style fix 2007-09-29 11:45:46 +00:00
Igor Sysoev cb16d14fca add time and length to a HEAD request 2007-09-28 09:48:25 +00:00
Igor Sysoev 6e95d33eb0 omit trailing zero in directory name 2007-09-27 09:39:29 +00:00
Igor Sysoev e90ee470d4 SSI echo encoding 2007-09-27 09:37:09 +00:00
Igor Sysoev ed203139f6 ngx_escape_html() 2007-09-27 09:36:50 +00:00
Igor Sysoev 21b063f499 use ngx_strstrn() and ngx_strcasestrn() 2007-09-26 19:26:14 +00:00
Igor Sysoev b15f13ccf0 ngx_strstrn() and ngx_strcasestrn() 2007-09-26 19:25:52 +00:00
Igor Sysoev 773786c1c4 fix comment 2007-09-26 12:23:34 +00:00
Igor Sysoev 0d2160c48d bump version 2007-09-24 04:18:22 +00:00
Igor Sysoev 9551a988f1 release-0.6.13 tag 2007-09-24 04:10:02 +00:00
Igor Sysoev 47f1629cec nginx-0.6.13-RELEASE 2007-09-24 04:10:01 +00:00
Igor Sysoev 93378db666 fix file leak for HEAD requests 2007-09-22 17:56:05 +00:00
Igor Sysoev f7e357e735 document mail modules options 2007-09-21 16:14:17 +00:00
Igor Sysoev be3081d599 bump version 2007-09-21 14:41:05 +00:00
Igor Sysoev e3cc3f3fc6 release-0.6.12 tag 2007-09-21 14:36:11 +00:00
Igor Sysoev 5ecb8d86c9 nginx-0.6.12-RELEASE 2007-09-21 14:36:10 +00:00
Igor Sysoev b65a6a826c fix "AUTH PLAIN [initial-response]" bug introduced in r1477 2007-09-21 14:08:50 +00:00
Igor Sysoev 9679e39c59 use "_" instead of " " as new line substitute, do not delete trailing new line 2007-09-21 13:47:33 +00:00
Igor Sysoev fbe4862a64 fix r1416 2007-09-21 13:43:53 +00:00
Igor Sysoev 327a39aaf6 log starttls 2007-09-20 11:08:14 +00:00
Igor Sysoev c7016edacd add rpath for Solaris 2007-09-19 12:14:05 +00:00
Igor Sysoev 6a5cc2396e u_char* is enough to keep file name 2007-09-15 17:11:06 +00:00
Igor Sysoev a1e85aa6b6 the "proxy_hide_header" and "fastcgi_hide_header" directives did not
hide response header lines whose name was longer than 32 characters
2007-09-15 16:54:58 +00:00
Igor Sysoev fb598fe906 ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module 2007-09-15 16:51:16 +00:00
Igor Sysoev 4cb8d374bf style fix: remove trailing spaces 2007-09-14 15:04:45 +00:00
Igor Sysoev a3b995f5b2 create salt just before it will be used 2007-09-14 15:00:19 +00:00
Igor Sysoev d3fdc28bc3 fix r1482 2007-09-14 14:56:46 +00:00
Igor Sysoev d36a9ff7e1 ngx_mail_smtp_create_buffer() 2007-09-14 14:13:25 +00:00
Igor Sysoev c9f1aada71 optimizations 2007-09-14 14:04:24 +00:00
Igor Sysoev 7ccf7b35da smtp_client_buffer and smtp_greeting_delay 2007-09-14 13:58:49 +00:00
Igor Sysoev 4b4a64b80b move event handling to protocol specific code,
it is required to support SMTP greeting delay
2007-09-14 10:42:19 +00:00
Igor Sysoev 94b0b06dc1 optimizations 2007-09-13 21:24:27 +00:00
Igor Sysoev 467d739f89 small optimizations 2007-09-13 20:32:52 +00:00
Igor Sysoev 7aa63131c7 style fix and optimizations 2007-09-13 20:27:28 +00:00
Igor Sysoev 06c3f18113 split pop3, imap, and smtp handlers 2007-09-13 20:13:18 +00:00
Igor Sysoev f0e951e23e bump version 2007-09-11 13:21:30 +00:00
Igor Sysoev ab1fefc837 release-0.6.11 tag 2007-09-11 13:15:49 +00:00
Igor Sysoev 3eccdd7784 nginx-0.6.11-RELEASE 2007-09-11 13:15:48 +00:00
Igor Sysoev 45ab454787 decrement active connection counter in mail proxy 2007-09-11 10:22:12 +00:00
Igor Sysoev ebe6ec98b3 response to the HEAD request should be a header only 2007-09-11 06:34:18 +00:00
Igor Sysoev 26331129dc 64-bit update lost in r1355 2007-09-10 09:08:12 +00:00
Igor Sysoev 384ae47203 connection error should be logged with "connecting to upstream" action,
the bug was introduced in r1154
2007-09-09 18:43:16 +00:00
Igor Sysoev 8df6cc83b5 read EOF of header only responses in non-buffered proxying 2007-09-09 18:32:53 +00:00
Igor Sysoev 67ff3bcccd there may be several "Connection" header lines and each may have several tokens 2007-09-09 18:28:49 +00:00
Igor Sysoev d911dbb292 escape internal request URI in proxy_pass 2007-09-09 18:25:03 +00:00
Igor Sysoev 373a10cff1 balance more fair when there are several servers with equal weights,
side effect: now smallest weights go first
2007-09-09 18:23:21 +00:00
Igor Sysoev c072d218d1 style fix 2007-09-07 09:29:08 +00:00
Igor Sysoev 11cb8111fa fix case when server was marked as down after one failure 2007-09-05 15:30:19 +00:00
Igor Sysoev 9db497a7fd backout r1426: return dynamic weights 2007-09-05 15:28:19 +00:00
Igor Sysoev 0510116c34 bump version 2007-09-03 10:35:02 +00:00
Igor Sysoev e00699462c release-0.6.10 tag 2007-09-03 10:30:00 +00:00
Igor Sysoev 633ab489e6 nginx-0.6.10-RELEASE 2007-09-03 10:29:59 +00:00
Igor Sysoev 3eeb5f6845 test the most relevant condition first 2007-09-03 09:06:26 +00:00
Igor Sysoev cd77964df6 open_file_cache_events 2007-09-03 08:41:42 +00:00
Igor Sysoev ea414bb402 fix unlikely socket leak 2007-09-01 16:41:52 +00:00
Igor Sysoev 029cfdac86 fix socket leak introduced in r1374 when request header and body was
in one packet and connection went to keep-alive state
2007-09-01 16:40:19 +00:00
Igor Sysoev fa7f65761c open_file_cache in HTTP 2007-09-01 12:12:48 +00:00
Igor Sysoev 5d30aa5e86 open file cache 2007-09-01 12:11:21 +00:00
Igor Sysoev 9f94c4abb8 change ngx_conf_merge_ptr_value() and update fastcgi_catch_stderr 2007-09-01 12:05:55 +00:00
Igor Sysoev 07cb5d3c46 NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT 2007-09-01 11:59:36 +00:00
Igor Sysoev 5704a5f1ed add comment 2007-09-01 11:21:00 +00:00
Igor Sysoev 1641196a88 update comments 2007-09-01 09:33:25 +00:00
Igor Sysoev bad2d75e62 allow to append charset to the "Content-Type" header 2007-08-31 18:47:25 +00:00
Igor Sysoev 0ffbc71642 style fix 2007-08-31 12:13:12 +00:00
Igor Sysoev a5babdacd6 update comment 2007-08-31 09:50:23 +00:00
Igor Sysoev 73d021789e style fix 2007-08-31 09:41:45 +00:00
Igor Sysoev d1bdda37e0 use ev->log, because ev->data may be connection stub only 2007-08-31 09:40:38 +00:00
Igor Sysoev 305194e79b style fix 2007-08-31 09:22:53 +00:00
Igor Sysoev b5f0c83025 fix typo 2007-08-31 06:15:50 +00:00
Igor Sysoev 8c1b31e32e destroy ngx_cycle->pool on exit 2007-08-30 18:59:44 +00:00
Igor Sysoev 8518844fba win32 ngx_is_exec() stub 2007-08-30 18:57:38 +00:00
Igor Sysoev 1c98a2c5e9 log socket number 2007-08-29 15:33:59 +00:00
Igor Sysoev 6f10471450 If-Modified-Since should be unique header line 2007-08-29 15:32:49 +00:00
Igor Sysoev 02867d3b46 add guard code 2007-08-29 11:26:42 +00:00
Igor Sysoev f8aa43a771 fix comment 2007-08-29 07:19:22 +00:00
Igor Sysoev fc0be99221 disable pair event on POLLREMOVE 2007-08-29 07:18:54 +00:00
Igor Sysoev fe4494bfb4 bump version 2007-08-28 16:44:29 +00:00
Igor Sysoev 68f94670b4 release-0.6.9 tag 2007-08-28 16:22:49 +00:00
Igor Sysoev d6767c2abc nginx-0.6.9-RELEASE 2007-08-28 16:22:48 +00:00
Igor Sysoev 2d7e880663 return 400 response 2007-08-27 20:52:40 +00:00
Igor Sysoev 73c21fbc67 do not set read->eof, ready, and error prematurely 2007-08-27 19:44:35 +00:00
Igor Sysoev 16d586c0c4 cancel dynamic weights,
it seems that may permanently set lower weight or even mark server as down
2007-08-27 16:02:43 +00:00
Igor Sysoev 3244743f4b optimize r->connection in ngx_http_finalize_request() 2007-08-27 15:53:00 +00:00
Igor Sysoev a5af428550 cancel keep-alive and lingering close on EOF 2007-08-27 15:40:19 +00:00
Igor Sysoev 7545944a3f cancel discarding body on EOF 2007-08-27 15:38:46 +00:00
Igor Sysoev 5461cb4ad6 mark connection as not ready, this fixes endless loop introduced in r1368 2007-08-27 15:01:08 +00:00
Igor Sysoev 83a74ef59d add guard code to prevent endless loop 2007-08-24 15:58:13 +00:00
Igor Sysoev 9258af522c update ip_hash to "backup" option 2007-08-24 15:30:35 +00:00
Igor Sysoev 44c50a5b5b set current peer to use it in ngx_http_upstream_free_round_robin_peer() 2007-08-24 15:29:50 +00:00
Igor Sysoev 71f527a847 fix ip_hash on 64-bit platform 2007-08-24 15:28:06 +00:00
Igor Sysoev d3345e465f fix trailing wildcard when two or more listen used in one server 2007-08-24 11:05:47 +00:00
Igor Sysoev 1d05fec921 add svg mime type 2007-08-21 11:05:30 +00:00
Igor Sysoev 04f030eb44 fix build on amd64 2007-08-21 11:05:11 +00:00
Igor Sysoev 3ca15678cc bump version 2007-08-20 13:10:25 +00:00
Igor Sysoev 1c110cc7c2 release-0.6.8 tag 2007-08-20 13:05:33 +00:00
Igor Sysoev 951caf5213 nginx-0.6.8-RELEASE 2007-08-20 13:05:32 +00:00
Igor Sysoev 8ad43bb779 set delay only when almost whole sendfile_max_chunk was transferred 2007-08-20 10:35:41 +00:00
Igor Sysoev 3d442cfe0f test relative nginx.conf, this is compatible with old versions
because cycle->root on this stage is not set
2007-08-20 10:05:10 +00:00
Igor Sysoev 519bb30b6c use %v for ngx_variable_value_t in ngx_sprintf(),
this fixes nginx on FreeBSD/sparc64
2007-08-20 09:57:19 +00:00
Igor Sysoev fc62e7a845 escape " ", "%", and %00-%1F in login and password 2007-08-20 09:50:53 +00:00
Igor Sysoev c2c3841c82 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
worker_rlimit_sigpending without super-user privileges testing
2007-08-15 20:53:30 +00:00
Igor Sysoev 2fb58ed49e auto redirect lost arguments 2007-08-15 15:57:26 +00:00
Igor Sysoev 22b8d513ea bump version 2007-08-15 12:58:35 +00:00
Igor Sysoev ed9b262514 release-0.6.7 tag 2007-08-15 12:44:27 +00:00
Igor Sysoev 79e3381caf nginx-0.6.7-RELEASE 2007-08-15 12:44:26 +00:00
Igor Sysoev f733811589 upstream sendfile bit was overridden by r->connection->sendfile 2007-08-14 20:44:09 +00:00
Igor Sysoev 710486568f axe --sysconfdir=PATH
configuration prefix is dirname of --conf-path=PATH
fix paths in default nginx.conf
2007-08-14 19:26:20 +00:00
Igor Sysoev 5f6b1e9838 rename upgrade to upgrade1
use -QUIT instead of -WINCH
2007-08-14 18:22:07 +00:00
Igor Sysoev 338bf13e7c test http_auth absence 2007-08-14 15:21:20 +00:00
Igor Sysoev 9b0a311e18 allow "http://" in auth_http URL 2007-08-14 15:00:38 +00:00
Igor Sysoev 04c357cc81 stop configuration on error 2007-08-14 14:57:51 +00:00
Igor Sysoev e743193c2d fix long loop 2007-08-14 13:35:52 +00:00
Igor Sysoev 98f422bd09 regex in valid_referers 2007-08-12 20:06:43 +00:00
Igor Sysoev 8a7b4af8b5 regex in server_name 2007-08-12 19:48:12 +00:00
Igor Sysoev 8b6afa26fa fix building by bcc without PCRE 2007-08-12 15:25:09 +00:00
Igor Sysoev 92971a4746 style fix 2007-08-12 09:00:56 +00:00
Igor Sysoev 1f36f2b49e ignore meaningless bits in CIDR and warn about them 2007-08-10 13:13:28 +00:00
Igor Sysoev f9827bbc56 sort upstream weights 2007-08-09 15:28:17 +00:00
Igor Sysoev 73d67a9729 backup upstream servers 2007-08-09 13:54:33 +00:00
Igor Sysoev c5245bab92 set default listen() backlog to 511 on all platforms except FreeBSD 2007-08-09 13:32:21 +00:00
Igor Sysoev 14301cb098 "down" server caused endless loop 2007-08-07 12:34:20 +00:00
Igor Sysoev 12e21a5a09 add debug info for Sun Studio 2007-08-07 10:56:45 +00:00
Igor Sysoev 35cac46a0b omit unnecessary conditions 2007-08-07 10:56:09 +00:00
Igor Sysoev 642079e468 discard request body before going to keep-alive state and use lingering timeouts 2007-08-07 10:53:27 +00:00
Igor Sysoev fc0ee2428d omit unnecessary XSRETURN_EMPTY 2007-08-06 15:40:26 +00:00
Igor Sysoev cff9ac37b3 $r->discard_request_body 2007-08-06 15:38:08 +00:00
Igor Sysoev 695ba73268 rename ngx_http_discard_body() to ngx_http_discard_request_body() 2007-08-06 15:37:22 +00:00
Igor Sysoev b0e8daec9e block reading for level events 2007-08-06 15:31:00 +00:00
Igor Sysoev 49b05f246f rename ngx_http_block_read() and ngx_http_test_read() to ..._reading() 2007-08-06 15:22:40 +00:00
Igor Sysoev 2cdf0a727c discard request body in cycle 2007-08-06 15:18:24 +00:00
Igor Sysoev 2e136a5d5b move "Expires" header code to a separate function 2007-08-01 19:32:58 +00:00
Igor Sysoev 83b5a672b6 move "Cache-Control" header code to specific handler 2007-08-01 15:24:06 +00:00
Igor Sysoev e2e211d381 style fix 2007-08-01 14:22:12 +00:00
Igor Sysoev 77ef1f5452 use header specific handler in add_handler,
"Last-Modified" header handler
2007-08-01 14:01:30 +00:00
Igor Sysoev dfcab9c61a fix r1353 2007-07-30 10:51:55 +00:00
Igor Sysoev feedad72be bump version 2007-07-30 09:23:26 +00:00
Igor Sysoev 4d4a19568c release-0.6.6 tag 2007-07-30 09:13:18 +00:00
Igor Sysoev a59328c7eb nginx-0.6.6-RELEASE 2007-07-30 09:13:17 +00:00
Igor Sysoev 5385801f35 make 64-bit ngx_int_t on 64-bit platforms 2007-07-29 18:24:53 +00:00
Igor Sysoev c4d0f5b0ae named location 2007-07-29 18:11:39 +00:00
Igor Sysoev 37f3097fbe --sysconfdir=DIR 2007-07-29 18:05:45 +00:00
Igor Sysoev a23e82a839 $is_args 2007-07-29 17:56:56 +00:00
Igor Sysoev b8af806a0b allow to set $args 2007-07-29 17:55:37 +00:00
Igor Sysoev a6d25b840f fair upstream weight balancer 2007-07-28 16:04:01 +00:00
Igor Sysoev 4d12a376e8 fix building on amd64 by Sun Studio 11 and more early versions 2007-07-28 08:48:12 +00:00
Igor Sysoev df16faee5a fix case when client has closed connection but upstream buffer is not empty 2007-07-24 18:08:04 +00:00
Igor Sysoev c89fce22ce fix case when two directives
proxy_pass   http://backend;
    proxy_pass   https://backend;
both use one port - 80 or 443, that was defined first.
2007-07-23 12:35:21 +00:00
Igor Sysoev 87f9fc6094 style fix 2007-07-23 12:32:34 +00:00
Igor Sysoev c534c63601 bump version 2007-07-23 08:12:24 +00:00
Igor Sysoev 761cb308e9 release-0.6.5 tag 2007-07-23 07:57:09 +00:00
Igor Sysoev 17a82916c3 nginx-0.6.5-RELEASE 2007-07-23 07:57:08 +00:00
Igor Sysoev f048c9a001 escape space, etc in $memcached_key 2007-07-22 19:18:59 +00:00
Igor Sysoev 7f54b9eb77 omit unnecessary code 2007-07-22 19:11:52 +00:00
Igor Sysoev 1e3b96aadd add $nginx_version 2007-07-22 13:15:21 +00:00
Igor Sysoev 00aa2a9631 $nginx_version 2007-07-22 13:12:16 +00:00
Igor Sysoev e5476b20b9 fix building on amd64 and add -xipo to the link stage 2007-07-21 06:23:58 +00:00
Igor Sysoev 5d06f9b142 IMAP AUTHENTICATE
patch by Maxim Dounin
2007-07-20 19:38:08 +00:00
Igor Sysoev 8241fb2998 SMTP STARTTLS
patch by Maxim Dounin
2007-07-20 18:36:04 +00:00
Igor Sysoev 12ee774d04 fix bug introduced by r1306 2007-07-20 18:33:44 +00:00
Igor Sysoev 8aa60b3191 exit cycle early,
found by Coverity's Scan
2007-07-19 19:12:36 +00:00
Igor Sysoev 26022f76a6 fix potential double free(),
found by Coverity's Scan
2007-07-19 19:11:57 +00:00
Igor Sysoev 100d0f42ad fix potential segfault,
found by Coverity's Scan
2007-07-19 19:08:22 +00:00
Igor Sysoev 260cba9111 fix memory leak,
found by Coverity's Scan
2007-07-19 19:07:13 +00:00
Igor Sysoev b56f4e953c bump version 2007-07-17 10:15:07 +00:00
Igor Sysoev 54b8a904d9 release-0.6.4 tag 2007-07-17 09:57:38 +00:00
Igor Sysoev 81404ffdd0 nginx-0.6.4-RELEASE 2007-07-17 09:57:37 +00:00
Igor Sysoev ac2375f0f9 Sun Studio on sparc uses different bit order 2007-07-17 09:23:23 +00:00
Igor Sysoev 00beec63d5 Sun Studio 12 compatibility 2007-07-16 08:54:04 +00:00
Igor Sysoev a2f7a8ba87 --with-cpu-opt=sparc32 and --with-cpu-opt=sparc64 2007-07-15 20:09:14 +00:00
Igor Sysoev 5aff3fd765 fix building PCRE by SunStudio 2007-07-15 19:17:46 +00:00
Igor Sysoev 42e902b6aa Solaris compatibility 2007-07-15 14:45:51 +00:00
Igor Sysoev 81d5025013 icc/sunc and PCRE-7.1+ compatibility 2007-07-15 14:44:53 +00:00
Igor Sysoev fb427d3bad msie_refresh should escape at least '"' to prevent XSS 2007-07-13 09:37:01 +00:00
Igor Sysoev 78300bff51 "?" should not be escaped 2007-07-13 09:35:51 +00:00
Igor Sysoev 9d22064182 dav_access uses ngx_conf_set_access_slot() 2007-07-13 08:32:12 +00:00
Igor Sysoev 93a49ec586 proxy_store and fastcgi_store were changed,
proxy_store_access and fastcgi_store_access were added
2007-07-13 08:30:34 +00:00
Igor Sysoev bf08751a0f bump version 2007-07-12 11:35:57 +00:00
Igor Sysoev 05dd962bcf release-0.6.3 tag 2007-07-12 11:21:57 +00:00
Igor Sysoev 9f9962c4d2 nginx-0.6.3-RELEASE 2007-07-12 11:21:56 +00:00
Igor Sysoev 3ff8cde26d proxy_store and fastcgi_store 2007-07-12 11:19:05 +00:00
Igor Sysoev aceadba26b style fix 2007-07-11 20:12:26 +00:00
Igor Sysoev 02279c26bf style fix 2007-07-11 13:06:54 +00:00
Igor Sysoev bfab8ca187 reset errno 2007-07-11 10:46:21 +00:00
Igor Sysoev 3c46293a23 fix segfault when event port returns POLLERR without POLLIN or POLLOUT 2007-07-11 10:45:55 +00:00
Igor Sysoev d2165b3f83 fix segfault when CRAM-MD5 is not enabled but client tries it 2007-07-11 07:47:57 +00:00
Igor Sysoev 04216efe18 fix memory allocation for auth_http_header 2007-07-10 21:26:51 +00:00
Igor Sysoev cd23e55fe1 fix segfault when session was freed twice 2007-07-10 21:04:37 +00:00
Igor Sysoev 8833495f15 proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
broken by r1111
2007-07-10 20:53:45 +00:00
Igor Sysoev bbb3401960 bump version 2007-07-09 07:09:38 +00:00
Igor Sysoev dc90e24668 release-0.6.2 tag 2007-07-09 06:54:48 +00:00
Igor Sysoev 4868184b60 nginx-0.6.2-RELEASE 2007-07-09 06:54:47 +00:00
Igor Sysoev b54acaa1de fix headers split in FastCGI records 2007-07-09 06:30:53 +00:00
Igor Sysoev 07be9c08f3 omit unnecessary conditions 2007-07-08 09:38:37 +00:00
Igor Sysoev 2497b14b22 when the FastCGI header was split in records,
nginx passed garbage in the header to a client
2007-07-08 09:16:36 +00:00
Igor Sysoev 5db84b1a9f add comment 2007-07-06 11:28:20 +00:00
Igor Sysoev 3fb0cd4a5e bump version 2007-06-17 19:27:34 +00:00
Igor Sysoev be4daa1cc9 release-0.6.1 tag 2007-06-17 19:13:34 +00:00
Igor Sysoev 8a5e2d27a7 nginx-0.6.1-RELEASE 2007-06-17 19:13:33 +00:00
Igor Sysoev 5bccc49372 if a subrequest was finished and SSI was in middle of SSI command parsing
and the command was a fast subrequest then the second subrequest output
was just after first subrequest output and response part of main request
between the subrequests went after the second subrequest.
2007-06-17 18:10:43 +00:00
Igor Sysoev 61e4e2c457 if "<!--" was on edge of buf, then ssi_sharp_state was saved in ctx->saved
and if it was not reset, then any '#' was treated as SSI command start
2007-06-17 17:54:48 +00:00
Igor Sysoev 20a1bd00af if subrequest response was buffered in file, then subrequest was finalized
with 0 code, ngx_http_writer() was not set, and response part in file was lost
2007-06-17 09:29:15 +00:00
Igor Sysoev 36477e0c0e fix building on threaded or multiplicity interpreter perl,
the bug was introduced by previous commit
2007-06-16 09:22:37 +00:00
Igor Sysoev 65327a2637 set worker's perl $$ 2007-06-15 12:20:23 +00:00
Igor Sysoev ceaab041e0 bump version 2007-06-14 05:48:47 +00:00
Igor Sysoev 8b72b1346b release-0.6.0 tag 2007-06-14 05:41:43 +00:00
Igor Sysoev 419d10908a nginx-0.6.0-RELEASE 2007-06-14 05:41:42 +00:00
Igor Sysoev 5fb6ed90af the "www.example.*" wildcard hash support 2007-06-11 19:49:22 +00:00
Igor Sysoev 86364a7ca5 bump version 2007-06-11 19:32:29 +00:00
Igor Sysoev 175a728a3b release-0.5.25 tag 2007-06-11 18:42:56 +00:00
547 changed files with 201214 additions and 33117 deletions

389
README Normal file
View File

@ -0,0 +1,389 @@
Experimental QUIC support for nginx
-----------------------------------
1. Introduction
2. Building from sources
3. Configuration
4. Directives
5. Clients
6. Troubleshooting
7. Contributing
8. Links
1. Introduction
This is an experimental QUIC [1] / HTTP/3 [2] support for nginx.
The code is developed in a separate "quic" branch available
at https://hg.nginx.org/nginx-quic. Currently it is based
on nginx mainline 1.23.x. We merge new nginx releases into
this branch regularly.
The project code base is under the same BSD license as nginx.
The code is currently at a beta level of quality, however
there are several production deployments with it.
NGINX Development Team is working on improving HTTP/3 support to
integrate it into the main NGINX codebase. Thus, expect further
updates of this code, including features, changes in behaviour,
bug fixes, and refactoring. NGINX Development team will be
grateful for any feedback and code submissions.
Please contact NGINX Development Team via nginx-devel mailing list [3].
What works now:
IETF QUIC version 1 is supported. Internet drafts are no longer supported.
nginx should be able to respond to HTTP/3 requests over QUIC and
it should be possible to upload and download big files without errors.
+ The handshake completes successfully
+ One endpoint can update keys and its peer responds correctly
+ 0-RTT data is being received and acted on
+ Connection is established using TLS Resume Ticket
+ A handshake that includes a Retry packet completes successfully
+ Stream data is being exchanged and ACK'ed
+ An H3 transaction succeeded
+ One or both endpoints insert entries into dynamic table and
subsequently reference them from header blocks
+ Version Negotiation packet is sent to client with unknown version
+ Lost packets are detected and retransmitted properly
+ Clients may migrate to new address
2. Building from sources
The build is configured using the configure command.
Refer to http://nginx.org/en/docs/configure.html for details.
When configuring nginx, it's possible to enable QUIC and HTTP/3
using the following new configuration options:
--with-http_v3_module - enable QUIC and HTTP/3
--with-stream_quic_module - enable QUIC in Stream
A library that provides QUIC support is recommended to build nginx, there
are several of those available on the market:
+ BoringSSL [4]
+ LibreSSL [5]
+ QuicTLS [6]
Alternatively, nginx can be configured with OpenSSL compatibility
layer, which emulates BoringSSL QUIC API for OpenSSL. This mode is
enabled by default if native QUIC support is not detected.
0-RTT is not supported in OpenSSL compatibility mode.
Clone the NGINX QUIC repository
$ hg clone -b quic https://hg.nginx.org/nginx-quic
$ cd nginx-quic
Use the following command to configure nginx with BoringSSL [4]
$ ./auto/configure --with-debug --with-http_v3_module \
--with-cc-opt="-I../boringssl/include" \
--with-ld-opt="-L../boringssl/build/ssl \
-L../boringssl/build/crypto"
$ make
Alternatively, nginx can be configured with QuicTLS [6]
$ ./auto/configure --with-debug --with-http_v3_module \
--with-cc-opt="-I../quictls/build/include" \
--with-ld-opt="-L../quictls/build/lib"
Alternatively, nginx can be configured with a modern version
of LibreSSL [7]
$ ./auto/configure --with-debug --with-http_v3_module \
--with-cc-opt="-I../libressl/build/include" \
--with-ld-opt="-L../libressl/build/lib"
3. Configuration
The HTTP "listen" directive got a new option "quic" which enables
QUIC as client transport protocol instead of TCP.
The Stream "listen" directive got a new option "quic" which enables
QUIC as client transport protocol instead of TCP or plain UDP.
Along with "quic", it's also possible to specify "reuseport"
option [8] to make it work properly with multiple workers.
To enable address validation:
quic_retry on;
To enable 0-RTT:
ssl_early_data on;
Make sure that TLS 1.3 is configured which is required for QUIC:
ssl_protocols TLSv1.3;
To enable GSO (Generic Segmentation Offloading):
quic_gso on;
To limit maximum UDP payload size on receive path:
quic_mtu <size>;
To set host key for various tokens:
quic_host_key <filename>;
By default, GSO Linux-specific optimization [10] is disabled.
Enable it in case a corresponding network interface is configured to
support GSO.
A number of directives were added that configure HTTP/3:
http3
http3_hq
http3_stream_buffer_size
http3_max_concurrent_pushes
http3_max_concurrent_streams
http3_push
http3_push_preload
In http, an additional variable is available: $http3.
The value of $http3 is "h3" for HTTP/3 connections,
"hq" for hq connections, or an empty string otherwise.
In stream, an additional variable is available: $quic.
The value of $quic is "quic" if QUIC connection is used,
or an empty string otherwise.
Example configuration:
http {
log_format quic '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$http3"';
access_log logs/access.log quic;
server {
# for better compatibility it's recommended
# to use the same port for quic and https
listen 8443 quic reuseport;
listen 8443 ssl;
ssl_certificate certs/example.com.crt;
ssl_certificate_key certs/example.com.key;
ssl_protocols TLSv1.3;
location / {
# required for browsers to direct them into quic port
add_header Alt-Svc 'h3=":8443"; ma=86400';
}
}
}
4. Directives
Syntax: quic_bpf on | off;
Default: quic_bpf off;
Context: main
Enables routing of QUIC packets using eBPF.
When enabled, this allows to support QUIC connection migration.
The directive is only supported on Linux 5.7+.
Syntax: quic_retry on | off;
Default: quic_retry off;
Context: http | stream, server
Enables the QUIC Address Validation feature. This includes:
- sending a new token in a Retry packet or a NEW_TOKEN frame
- validating a token received in the Initial packet
Syntax: quic_gso on | off;
Default: quic_gso off;
Context: http | stream, server
Enables sending in optimized batch mode using segmentation offloading.
Optimized sending is only supported on Linux featuring UDP_SEGMENT.
Syntax: quic_mtu size;
Default: quic_mtu 65527;
Context: http | stream, server
Sets the QUIC max_udp_payload_size transport parameter value.
This is the maximum UDP payload that we are willing to receive.
Syntax: quic_host_key file;
Default: -
Context: http | stream, server
Specifies a file with the secret key used to encrypt stateless reset and
address validation tokens. By default, a randomly generated key is used.
Syntax: quic_active_connection_id_limit number;
Default: quic_active_connection_id_limit 2;
Context: http | stream, server
Sets the QUIC active_connection_id_limit transport parameter value.
This is the maximum number of connection IDs we are willing to store.
Syntax: quic_timeout time;
Default: quic_timeout 60s;
Context: stream, server
Defines a timeout used to negotiate the QUIC idle timeout.
In the http module, it is taken from the keepalive_timeout directive.
Syntax: quic_stream_buffer_size size;
Default: quic_stream_buffer_size 64k;
Context: stream, server
Syntax: http3_stream_buffer_size size;
Default: http3_stream_buffer_size 64k;
Context: http, server
Sets buffer size for reading and writing of the QUIC STREAM payload.
The buffer size is used to calculate initial flow control limits
in the following QUIC transport parameters:
- initial_max_data
- initial_max_stream_data_bidi_local
- initial_max_stream_data_bidi_remote
- initial_max_stream_data_uni
Syntax: http3_max_concurrent_pushes number;
Default: http3_max_concurrent_pushes 10;
Context: http, server
Limits the maximum number of concurrent push requests in a connection.
Syntax: http3_max_concurrent_streams number;
Default: http3_max_concurrent_streams 128;
Context: http, server
Sets the maximum number of concurrent HTTP/3 streams in a connection.
Syntax: http3_push uri | off;
Default: http3_push off;
Context: http, server, location
Pre-emptively sends (pushes) a request to the specified uri along with
the response to the original request. Only relative URIs with absolute
path will be processed, for example:
http3_push /static/css/main.css;
The uri value can contain variables.
Several http3_push directives can be specified on the same configuration
level. The off parameter cancels the effect of the http3_push directives
inherited from the previous configuration level.
Syntax: http3_push_preload on | off;
Default: http3_push_preload off;
Context: http, server, location
Enables automatic conversion of preload links specified in the “Link”
response header fields into push requests.
Syntax: http3 on | off;
Default: http3 on;
Context: http, server
Enables HTTP/3 protocol negotiation.
Syntax: http3_hq on | off;
Default: http3_hq off;
Context: http, server
Enables HTTP/0.9 protocol negotiation used in QUIC interoperability tests.
5. Clients
* Browsers
Known to work: Firefox 90+ and Chrome 92+ (QUIC version 1)
Beware of strange issues: sometimes browser may decide to ignore QUIC
Cache clearing/restart might help. Always check access.log and
error.log to make sure the browser is using HTTP/3 and not TCP https.
* Console clients
Known to work: ngtcp2, firefox's neqo and chromium's console clients:
$ examples/client 127.0.0.1 8443 https://example.com:8443/index.html
$ ./neqo-client https://127.0.0.1:8443/
$ chromium-build/out/my_build/quic_client http://example.com:8443
In case everyhing is right, the access log should show something like:
127.0.0.1 - - [24/Apr/2020:11:27:29 +0300] "GET / HTTP/3" 200 805 "-"
"nghttp3/ngtcp2 client" "quic"
6. Troubleshooting
Here are some tips that may help to identify problems:
+ Ensure nginx is built with proper SSL library that supports QUIC
+ Ensure nginx is using the proper SSL library in runtime
(`nginx -V` shows what it's using)
+ Ensure a client is actually sending requests over QUIC
(see "Clients" section about browsers and cache)
We recommend to start with simple console client like ngtcp2
to ensure the server is configured properly before trying
with real browsers that may be very picky with certificates,
for example.
+ Build nginx with debug support [9] and check the debug log.
It should contain all details about connection and why it
failed. All related messages contain "quic " prefix and can
be easily filtered out.
+ For a deeper investigation, please enable additional debugging
in src/event/quic/ngx_event_quic_connection.h:
#define NGX_QUIC_DEBUG_PACKETS
#define NGX_QUIC_DEBUG_FRAMES
#define NGX_QUIC_DEBUG_ALLOC
#define NGX_QUIC_DEBUG_CRYPTO
7. Contributing
Please refer to
http://nginx.org/en/docs/contributing_changes.html
8. Links
[1] https://datatracker.ietf.org/doc/html/rfc9000
[2] https://datatracker.ietf.org/doc/html/rfc9114
[3] https://mailman.nginx.org/mailman/listinfo/nginx-devel
[4] https://boringssl.googlesource.com/boringssl/
[5] https://www.libressl.org/
[6] https://github.com/quictls/openssl
[7] https://github.com/libressl-portable/portable/releases/tag/v3.6.0
[8] https://nginx.org/en/docs/http/ngx_http_core_module.html#listen
[9] https://nginx.org/en/docs/debugging_log.html
[10] http://vger.kernel.org/lpc_net2018_talks/willemdebruijn-lpc2018-udpgso-paper-DRAFT-1.pdf

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
# aCC: HP ANSI C++ B3910B A.03.55.02
@ -11,4 +12,3 @@ CC_TEST_FLAGS="-Ae"
PCRE_OPT="$PCRE_OPT -Ae"
ZLIB_OPT="$ZLIB_OPT -Ae"
MD5_OPT="$MD5_OPT -Ae"

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
# Borland C++ 5.5
@ -24,7 +25,7 @@ esac
# __stdcall
#CPU_OPT="$CPU_OPT -ps"
# __fastcall
CPU_OPT="$CPU_OPT -pr"
#CPU_OPT="$CPU_OPT -pr"
CFLAGS="$CFLAGS $CPU_OPT"
@ -46,7 +47,7 @@ NGX_USE_PCH="-Hu -H=$NGX_OBJS/ngx_config.csm"
# Win32 GUI mode application
LINK="\$(CC) -laa"
#LINK="\$(CC) -laa"
# the resource file
@ -61,7 +62,6 @@ ngx_include_opt="-I"
ngx_objout="-o"
ngx_binout="-e"
ngx_objext="obj"
ngx_binext=".exe"
ngx_long_start='@&&|
'

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
# Compaq C V6.5-207

99
auto/cc/clang Normal file
View File

@ -0,0 +1,99 @@
# Copyright (C) Nginx, Inc.
# clang
NGX_CLANG_VER=`$CC -v 2>&1 | grep 'version' 2>&1 \
| sed -n -e 's/^.*clang version \(.*\)/\1/p' \
-e 's/^.*LLVM version \(.*\)/\1/p'`
echo " + clang version: $NGX_CLANG_VER"
have=NGX_COMPILER value="\"clang $NGX_CLANG_VER\"" . auto/define
CC_TEST_FLAGS="-pipe"
# optimizations
#NGX_CLANG_OPT="-O2"
#NGX_CLANG_OPT="-Oz"
NGX_CLANG_OPT="-O"
case $CPU in
pentium)
# optimize for Pentium
CPU_OPT="-march=pentium"
NGX_CPU_CACHE_LINE=32
;;
pentiumpro | pentium3)
# optimize for Pentium Pro, Pentium II and Pentium III
CPU_OPT="-march=pentiumpro"
NGX_CPU_CACHE_LINE=32
;;
pentium4)
# optimize for Pentium 4
CPU_OPT="-march=pentium4"
NGX_CPU_CACHE_LINE=128
;;
athlon)
# optimize for Athlon
CPU_OPT="-march=athlon"
NGX_CPU_CACHE_LINE=64
;;
opteron)
# optimize for Opteron
CPU_OPT="-march=opteron"
NGX_CPU_CACHE_LINE=64
;;
esac
CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT"
CFLAGS="$CFLAGS -pipe $CPU_OPT"
if [ ".$PCRE_OPT" = "." ]; then
PCRE_OPT="-O2 -pipe $CPU_OPT"
else
PCRE_OPT="$PCRE_OPT -pipe"
fi
if [ ".$ZLIB_OPT" = "." ]; then
ZLIB_OPT="-O2 -pipe $CPU_OPT"
else
ZLIB_OPT="$ZLIB_OPT -pipe"
fi
# warnings
CFLAGS="$CFLAGS $NGX_CLANG_OPT -Wall -Wextra -Wpointer-arith"
CFLAGS="$CFLAGS -Wconditional-uninitialized"
#CFLAGS="$CFLAGS -Wmissing-prototypes"
# we have a lot of unused function arguments
CFLAGS="$CFLAGS -Wno-unused-parameter"
# deprecated system OpenSSL library on OS X
if [ "$NGX_SYSTEM" = "Darwin" ]; then
CFLAGS="$CFLAGS -Wno-deprecated-declarations"
fi
# stop on warning
CFLAGS="$CFLAGS -Werror"
# debug
CFLAGS="$CFLAGS -g"
if [ ".$CPP" = "." ]; then
CPP="$CC -E"
fi

View File

@ -1,15 +1,21 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
LINK="\$(CC)"
MAIN_LINK=
MODULE_LINK="-shared"
ngx_include_opt="-I "
ngx_compile_opt="-c"
ngx_pic_opt="-fPIC"
ngx_objout="-o "
ngx_binout="-o "
ngx_objext="o"
ngx_binext=
ngx_modext=".so"
ngx_long_start=
ngx_long_end=
@ -42,6 +48,32 @@ if test -n "$CFLAGS"; then
ngx_include_opt="-I"
;;
sunc)
MAIN_LINK=
MODULE_LINK="-G"
case "$NGX_MACHINE" in
i86pc)
NGX_AUX=" src/os/unix/ngx_sunpro_x86.il"
;;
sun4u | sun4v)
NGX_AUX=" src/os/unix/ngx_sunpro_sparc64.il"
;;
esac
case $CPU in
amd64)
NGX_AUX=" src/os/unix/ngx_sunpro_amd64.il"
;;
esac
;;
esac
else
@ -55,6 +87,12 @@ else
. auto/cc/gcc
;;
clang)
# Clang C compiler
. auto/cc/clang
;;
icc)
# Intel C++ compiler 7.1, 8.0, 8.1
@ -79,7 +117,7 @@ else
. auto/cc/acc
;;
msvc*)
msvc)
# MSVC++ 6.0 SP2, MSVC++ Toolkit 2003
. auto/cc/msvc
@ -104,7 +142,7 @@ else
fi
CFLAGS="$CFLAGS $NGX_CC_OPT"
NGX_TEST_LD_OPT="$NGX_LD_OPT"
if [ "$NGX_PLATFORM" != win32 ]; then
@ -125,18 +163,41 @@ if [ "$NGX_PLATFORM" != win32 ]; then
fi
fi
ngx_feature="gcc variadic macros"
ngx_feature_name="NGX_HAVE_GCC_VARIADIC_MACROS"
ngx_feature_run=yes
ngx_feature_incs="#include <stdio.h>
#define var(dummy, args...) sprintf(args)"
ngx_feature="-Wl,-E switch"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[30]; buf[0] = '0';
var(0, buf, \"%d\", 1);
if (buf[0] != '1') return 1"
ngx_feature_libs=-Wl,-E
ngx_feature_test=
. auto/feature
if [ $ngx_found = yes ]; then
MAIN_LINK="-Wl,-E"
fi
if [ "$NGX_CC_NAME" = "sunc" ]; then
echo "checking for gcc builtin atomic operations ... disabled"
else
ngx_feature="gcc builtin atomic operations"
ngx_feature_name=NGX_HAVE_GCC_ATOMIC
ngx_feature_run=yes
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="long n = 0;
if (!__sync_bool_compare_and_swap(&n, 0, 1))
return 1;
if (__sync_fetch_and_add(&n, 1) != 1)
return 1;
if (n != 2)
return 1;
__sync_synchronize();"
. auto/feature
fi
if [ "$NGX_CC_NAME" = "ccc" ]; then
echo "checking for C99 variadic macros ... disabled"
@ -152,7 +213,30 @@ if [ "$NGX_PLATFORM" != win32 ]; then
var(0, buf, \"%d\", 1);
if (buf[0] != '1') return 1"
. auto/feature
fi
fi
ngx_feature="gcc variadic macros"
ngx_feature_name="NGX_HAVE_GCC_VARIADIC_MACROS"
ngx_feature_run=yes
ngx_feature_incs="#include <stdio.h>
#define var(dummy, args...) sprintf(args)"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[30]; buf[0] = '0';
var(0, buf, \"%d\", 1);
if (buf[0] != '1') return 1"
. auto/feature
ngx_feature="gcc builtin 64 bit byteswap"
ngx_feature_name="NGX_HAVE_GCC_BSWAP64"
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="if (__builtin_bswap64(0)) return 1"
. auto/feature
# ngx_feature="inline"

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
# gcc 2.7.2.3, 2.8.1, 2.95.4, egcs-1.1.2
@ -51,8 +52,6 @@ esac
#NGX_GCC_OPT="-Os"
NGX_GCC_OPT="-O"
CFLAGS="$CFLAGS $NGX_GCC_OPT"
#CFLAGS="$CFLAGS -fomit-frame-pointer"
case $CPU in
@ -90,7 +89,6 @@ case $CPU in
# build 32-bit UltraSparc binary
CPU_OPT="-m32"
CORE_LINK="$CORE_LINK -m32"
CC_AUX_FLAGS="$CC_AUX_FLAGS -m32"
NGX_CPU_CACHE_LINE=64
;;
@ -98,7 +96,6 @@ case $CPU in
# build 64-bit UltraSparc binary
CPU_OPT="-m64"
CORE_LINK="$CORE_LINK -m64"
CC_AUX_FLAGS="$CC_AUX_FLAGS -m64"
NGX_CPU_CACHE_LINE=64
;;
@ -108,12 +105,12 @@ case $CPU in
CPU_OPT="$CPU_OPT -falign-functions=32 -falign-labels=32"
CPU_OPT="$CPU_OPT -falign-loops=32 -falign-jumps=32"
CORE_LINK="$CORE_LINK -m64"
CC_AUX_FLAGS="$CC_AUX_FLAGS -m64"
NGX_CPU_CACHE_LINE=128
;;
esac
CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT"
case "$NGX_GCC_VER" in
2.7*)
@ -131,12 +128,6 @@ else
PCRE_OPT="$PCRE_OPT $PIPE"
fi
if [ ".$MD5_OPT" = "." ]; then
MD5_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
else
MD5_OPT="$MD5_OPT $PIPE"
fi
if [ ".$ZLIB_OPT" = "." ]; then
ZLIB_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
else
@ -152,21 +143,24 @@ CFLAGS="$CFLAGS ${NGX_GCC_OPT:--O} -W"
CFLAGS="$CFLAGS -Wall -Wpointer-arith"
#CFLAGS="$CFLAGS -Wconversion"
#CFLAGS="$CFLAGS -Winline"
#CFLAGS="$CFLAGS -Wmissing-prototypes"
case "$NGX_GCC_VER" in
3.* | 4.* )
2.*)
# we have a lot of the unused function arguments
CFLAGS="$CFLAGS -Wno-unused-parameter"
CFLAGS="$CFLAGS -Wno-unused-function"
CFLAGS="$CFLAGS -Wunused-variable"
CFLAGS="$CFLAGS -Wunused-value"
#CFLAGS="$CFLAGS -Wunreachable-code"
CFLAGS="$CFLAGS -Wno-unused"
;;
*)
# we have a lot of the unused function arguments
CFLAGS="$CFLAGS -Wno-unused"
CFLAGS="$CFLAGS -Wno-unused-parameter"
# 4.2.1 shows the warning in wrong places
#CFLAGS="$CFLAGS -Wunreachable-code"
# deprecated system OpenSSL library on OS X
if [ "$NGX_SYSTEM" = "Darwin" ]; then
CFLAGS="$CFLAGS -Wno-deprecated-declarations"
fi
;;
esac

View File

@ -1,8 +1,9 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
# Intel C++ compiler 7.1, 8.0, 8.1, 9.0
# Intel C++ compiler 7.1, 8.0, 8.1, 9.0, 11.1
NGX_ICC_VER=`$CC -V 2>&1 | grep 'Version' 2>&1 \
| sed -e 's/^.* Version \([^ ]*\) *Build.*$/\1/'`
@ -15,32 +16,7 @@ have=NGX_COMPILER value="\"Intel C Compiler $NGX_ICC_VER\"" . auto/define
# optimizations
CFLAGS="$CFLAGS -O"
# inline the functions declared with __inline
#CFLAGS="$CFLAGS -Ob1"
# inline any function, at the compiler's discretion
CFLAGS="$CFLAGS -Ob2"
# multi-file IP optimizations
case "$NGX_ICC_VER" in
9.*)
IPO="-ipo"
;;
# 8.1.38 under FreeBSD can not link -ipo
8.1)
IPO="-ip"
;;
*)
IPO="-ipo -ipo_obj"
;;
esac
# single-file IP optimizations
#IPO="-ip"
CFLAGS="$CFLAGS $IPO"
CORE_LINK="$CORE_LINK $IPO"
CORE_LINK="$CORE_LINK -opt_report_file=$NGX_OBJS/opt_report_file"
@ -64,15 +40,11 @@ esac
CFLAGS="$CFLAGS $CPU_OPT"
if [ ".$PCRE_OPT" = "." ]; then
PCRE_OPT="-O $IPO $CPU_OPT"
fi
if [ ".$MD5_OPT" = "." ]; then
MD5_OPT="-O $IPO $CPU_OPT"
PCRE_OPT="-O $CPU_OPT"
fi
if [ ".$ZLIB_OPT" = "." ]; then
ZLIB_OPT="-O $IPO $CPU_OPT"
ZLIB_OPT="-O $CPU_OPT"
fi
@ -113,7 +85,7 @@ CFLAGS="$CFLAGS -wd1419"
case "$NGX_ICC_VER" in
9.*)
# "cc" clobber ignored, warnings for Liunx's htonl()/htons()
# "cc" clobber ignored, warnings for Linux's htonl()/htons()
CFLAGS="$CFLAGS -wd1469"
# explicit conversion of a 64-bit integral type to a smaller
# integral type
@ -127,7 +99,7 @@ case "$NGX_ICC_VER" in
;;
8.*)
# "cc" clobber ignored, warnings for Liunx's htonl()/htons()
# "cc" clobber ignored, warnings for Linux's htonl()/htons()
CFLAGS="$CFLAGS -wd1469"
# floating-point equality and inequality comparisons are unreliable,
# warning on SvTRUE()

View File

@ -1,8 +1,41 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
# MSVC 6.0 SP2, MSVC Toolkit 2003 (7.1)
# MSVC 6.0 SP2 cl 12.00
# MSVC Toolkit 2003 (7.1) cl 13.10
# MSVC 2005 Express Edition SP1 (8.0) cl 14.00
# MSVC 2008 Express Edition (9.0) cl 15.00
# MSVC 2010 (10.0) cl 16.00
# MSVC 2015 (14.0) cl 19.00
NGX_MSVC_VER=`$NGX_WINE $CC 2>&1 | grep 'C/C++.* [0-9][0-9]*\.[0-9]' 2>&1 \
| sed -e 's/^.* \([0-9][0-9]*\.[0-9].*\)/\1/'`
echo " + cl version: $NGX_MSVC_VER"
have=NGX_COMPILER value="\"cl $NGX_MSVC_VER\"" . auto/define
ngx_msvc_ver=`echo $NGX_MSVC_VER | sed -e 's/^\([0-9]*\).*/\1/'`
# detect x64 builds
case "$NGX_MSVC_VER" in
*x64)
NGX_MACHINE=amd64
;;
*)
NGX_MACHINE=i386
;;
esac
# optimizations
@ -49,12 +82,12 @@ case $CPU in
;;
esac
# __cdecl, use with OpenSSL, md5 asm, and sha1 asm
# __cdecl, default, must be used with OpenSSL, md5 asm, and sha1 asm
#CPU_OPT="$CPU_OPT -Gd"
# __stdcall
#CPU_OPT="$CPU_OPT -Gz"
# __fastcall
CPU_OPT="$CPU_OPT -Gr"
#CPU_OPT="$CPU_OPT -Gr"
CFLAGS="$CFLAGS $CPU_OPT"
@ -70,38 +103,43 @@ CFLAGS="$CFLAGS -WX"
# disable logo
CFLAGS="$CFLAGS -nologo"
LINK="\$(CC)"
# the link flags
CORE_LINK="$CORE_LINK -link -verbose:lib"
if [ $NGX_CC_NAME = msvc7 ]; then
# link with libcmt.lib, multithreaded
LIBC="-MT"
else
# link with msvcrt.dll
LIBC="-MD"
fi
# link with libcmt.lib, multithreaded
LIBC="-MT"
# link with msvcrt.dll
# however, MSVC Toolkit 2003 has no MSVCRT.LIB
#LIBC="-MD"
CFLAGS="$CFLAGS $LIBC"
# Win32 GUI mode application
CORE_LIBS="$CORE_LIBS kernel32.lib user32.lib"
CORE_LINK="$CORE_LINK -subsystem:windows -entry:mainCRTStartup"
# Win32 GUI mode application
#CORE_LINK="$CORE_LINK -subsystem:windows -entry:mainCRTStartup"
# debug
CFLAGS="$CFLAGS -Yd"
CORE_LINK="$CORE_LINK -debug -debugtype:coff"
# msvc under Wine issues
# C1902: Program database manager mismatch; please check your installation
if [ -z "$NGX_WINE" ]; then
CFLAGS="$CFLAGS -Zi -Fd$NGX_OBJS/nginx.pdb"
CORE_LINK="$CORE_LINK -debug"
fi
# MSVC 2005 supports C99 variadic macros
if [ "$ngx_msvc_ver" -ge 14 ]; then
have=NGX_HAVE_C99_VARIADIC_MACROS . auto/have
fi
# precompiled headers
if [ $NGX_CC_NAME != msvc7 ]; then
CORE_DEPS="$CORE_DEPS $NGX_OBJS/ngx_config.pch"
NGX_PCH="$NGX_OBJS/ngx_config.pch"
NGX_BUILD_PCH="-Ycngx_config.h -Fp$NGX_OBJS/ngx_config.pch"
NGX_USE_PCH="-Yungx_config.h -Fp$NGX_OBJS/ngx_config.pch"
fi
CORE_DEPS="$CORE_DEPS $NGX_OBJS/ngx_config.pch"
CORE_LINK="$CORE_LINK $NGX_OBJS/ngx_pch.obj"
NGX_PCH="$NGX_OBJS/ngx_config.pch"
NGX_BUILD_PCH="-Ycngx_config.h -Fp$NGX_OBJS/ngx_config.pch"
NGX_USE_PCH="-Yungx_config.h -Fp$NGX_OBJS/ngx_config.pch"
# the resource file
@ -110,29 +148,23 @@ NGX_RCC="rc -fo$NGX_RES \$(CORE_INCS) $NGX_WIN32_RC"
CORE_LINK="$NGX_RES $CORE_LINK"
# dynamic modules
#MAIN_LINK="-link -def:$NGX_OBJS/nginx.def"
#MODULE_LINK="-LD $NGX_OBJS/nginx.lib"
ngx_pic_opt=
ngx_objout="-Fo"
ngx_binout="-Fe"
ngx_objext="obj"
ngx_binext=".exe"
if [ "$BMAKE" = nmake ]; then
# MS nmake
ngx_long_start='@<<
'
ngx_long_end='<<'
ngx_long_regex_cont=' \
ngx_long_start='@<<
'
ngx_long_cont='
ngx_long_end='<<'
ngx_long_regex_cont=' \
'
ngx_long_cont='
'
else
# Borland make
ngx_long_start='@&&|
'
ngx_long_end='|'
fi
# MSVC understand / in path
#ngx_regex_dirsep='\\'

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
if [ "$NGX_PLATFORM" != win32 ]; then
@ -24,61 +25,46 @@ fi
if [ "$CC" = cl ]; then
if `$NGX_WINE $CC -v 2>&1 \
| grep '^Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13' \
>/dev/null 2>&1`; then
NGX_CC_NAME=msvc
echo " + using Microsoft Visual C++ compiler"
NGX_CC_NAME=msvc7
echo " + using Microsoft Visual C++ 7 compiler"
else
NGX_CC_NAME=msvc
echo " + using Microsoft Visual C++ compiler"
fi
else
if [ "$CC" = wcl386 ]; then
elif [ "$CC" = wcl386 ]; then
NGX_CC_NAME=owc
echo " + using Open Watcom C compiler"
else
if [ "$CC" = bcc32 ]; then
elif [ "$CC" = bcc32 ]; then
NGX_CC_NAME=bcc
echo " + using Borland C++ compiler"
else
if `$CC -v 2>&1 | grep 'gcc version' >/dev/null 2>&1`; then
NGX_CC_NAME=gcc
echo " + using GNU C compiler"
else
if `$CC -V 2>&1 | grep '^Intel(R) C' >/dev/null 2>&1`; then
elif `$CC -V 2>&1 | grep '^Intel(R) C' >/dev/null 2>&1`; then
NGX_CC_NAME=icc
echo " + using Intel C++ compiler"
else
if `$CC -V 2>&1 | grep 'Sun C' >/dev/null 2>&1`; then
elif `$CC -v 2>&1 | grep 'gcc version' >/dev/null 2>&1`; then
NGX_CC_NAME=gcc
echo " + using GNU C compiler"
elif `$CC -v 2>&1 | grep 'clang version' >/dev/null 2>&1`; then
NGX_CC_NAME=clang
echo " + using Clang C compiler"
elif `$CC -v 2>&1 | grep 'LLVM version' >/dev/null 2>&1`; then
NGX_CC_NAME=clang
echo " + using Clang C compiler"
elif `$CC -V 2>&1 | grep 'Sun C' >/dev/null 2>&1`; then
NGX_CC_NAME=sunc
echo " + using Sun C compiler"
else
if `$CC -V 2>&1 | grep '^Compaq C' >/dev/null 2>&1`; then
elif `$CC -V 2>&1 | grep '^Compaq C' >/dev/null 2>&1`; then
NGX_CC_NAME=ccc
echo " + using Compaq C compiler"
else
if `$CC -V 2>&1 | grep '^aCC: ' >/dev/null 2>&1`; then
elif `$CC -V 2>&1 | grep '^aCC: ' >/dev/null 2>&1`; then
NGX_CC_NAME=acc
echo " + using HP aC++ compiler"
else
NGX_CC_NAME=unknown
fi # acc
fi # ccc
fi # sunc
fi # icc
fi # gcc
fi # bcc
fi # owc
fi # msvc
fi

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
# Open Watcom C 1.0, 1.2, 1.3
@ -64,14 +65,14 @@ have=NGX_HAVE_C99_VARIADIC_MACROS . auto/have
# the precompiled headers
CORE_DEPS="$CORE_DEPS $NGX_OBJS/ngx_config.pch"
NGX_PCH="$NGX_OBJS/ngx_config.pch"
NGX_BUILD_PCH="-fhq=$NGX_OBJS/ngx_config.pch"
NGX_USE_PCH="-fh=$NGX_OBJS/ngx_config.pch"
#CORE_DEPS="$CORE_DEPS $NGX_OBJS/ngx_config.pch"
#NGX_PCH="$NGX_OBJS/ngx_config.pch"
#NGX_BUILD_PCH="-fhq=$NGX_OBJS/ngx_config.pch"
#NGX_USE_PCH="-fh=$NGX_OBJS/ngx_config.pch"
# the link flags, built target is NT GUI mode application
CORE_LINK="$CORE_LINK -l=nt_win"
#CORE_LINK="$CORE_LINK -l=nt_win"
# the resource file
@ -83,7 +84,20 @@ ngx_include_opt="-i="
ngx_objout="-fo"
ngx_binout="-fe="
ngx_objext="obj"
ngx_binext=".exe"
ngx_regex_dirsep='\\'
ngx_dirsep="\\"
ngx_long_start=' '
ngx_long_end=' '
ngx_long_regex_cont=' \&\
'
ngx_long_cont=' &
'
ngx_regex_cont=' \&\
'
ngx_cont=' &
'
ngx_tab=' &
'

View File

@ -1,9 +1,17 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
# Sun C 5.7 Patch 117837-04 2005/05/11
# Sun C 5.8 2005/10/13
# Sun C 5.7 Patch 117837-04 2005/05/11 Sun Studio 10
# Sun C 5.8 2005/10/13 Sun Studio 11
# Sun C 5.9 SunOS_i386 2007/05/03 Sun Studio 12
# Sun C 5.9 SunOS_sparc 2007/05/03
# Sun C 5.10 SunOS_i386 2009/06/03 Sun Studio 12.1
# Sun C 5.11 SunOS_i386 2010/08/13 Oracle Solaris Studio 12.2
# Sun C 5.12 SunOS_i386 2011/11/16 Oracle Solaris Studio 12.3
# Sun C 5.13 SunOS_i386 2014/10/20 Oracle Solaris Studio 12.4
# Sun C 5.14 SunOS_i386 2016/05/31 Oracle Developer Studio 12.5
NGX_SUNC_VER=`$CC -V 2>&1 | grep 'Sun C' 2>&1 \
| sed -e 's/^.* Sun C \(.*\)/\1/'`
@ -13,40 +21,67 @@ echo " + Sun C version: $NGX_SUNC_VER"
have=NGX_COMPILER value="\"Sun C $NGX_SUNC_VER\"" . auto/define
cat << END > $NGX_AUTOTEST.c
int main(void) {
printf("%d", __SUNPRO_C);
return 0;
}
END
eval "$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
ngx_sunc_ver=`$NGX_AUTOTEST`
fi
rm -rf $NGX_AUTOTEST*
# 1424 == 0x590, Sun Studio 12
if [ "$ngx_sunc_ver" -ge 1424 ]; then
ngx_sparc32="-m32"
ngx_sparc64="-m64"
ngx_amd64="-m64"
else
ngx_sparc32="-xarch=v8plus"
ngx_sparc64="-xarch=v9"
ngx_amd64="-xarch=amd64"
fi
case "$NGX_MACHINE" in
i86pc)
ngx_feature="PAUSE hardware capability bug"
ngx_feature_name=
ngx_feature_run=bug
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test='__asm ("pause")'
. auto/feature
if [ $ngx_found = yes ]; then
# disable [ PAUSE ] hwcap for Sun Studio 11
CORE_LINK="$CORE_LINK -Msrc/os/unix/ngx_sunpro_x86.map"
fi
NGX_AUX=" src/os/unix/ngx_sunpro_x86.il"
;;
sun4u | sun4v)
# "-xarch=v9" enables the "casa" assembler instruction
CFLAGS="$CFLAGS -xarch=v9"
CORE_LINK="$CORE_LINK -xarch=v9"
NGX_AUX=" src/os/unix/ngx_sunpro_sparc64.il"
;;
esac
MAIN_LINK=
MODULE_LINK="-G"
# optimizations
CFLAGS="$CFLAGS -fast"
# 20736 == 0x5100, Sun Studio 12.1
if [ "$ngx_sunc_ver" -ge 20736 ]; then
ngx_fast="-fast"
else
# older versions had problems with bit-fields
ngx_fast="-fast -xalias_level=any"
fi
IPO=-xipo
CFLAGS="$CFLAGS $ngx_fast $IPO"
CORE_LINK="$CORE_LINK $ngx_fast $IPO"
case $CPU in
@ -81,11 +116,29 @@ case $CPU in
CPU_OPT="$CPU_OPT -xcache=64/64/2:1024/64/16"
;;
sparc32)
# build 32-bit UltraSparc binary
CPU_OPT="$ngx_sparc32"
CORE_LINK="$CORE_LINK $ngx_sparc32"
CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_sparc32"
NGX_CPU_CACHE_LINE=64
;;
sparc64)
# build 64-bit UltraSparc binary
CPU_OPT="$ngx_sparc64"
CORE_LINK="$CORE_LINK $ngx_sparc64"
CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_sparc64"
NGX_CPU_CACHE_LINE=64
;;
amd64)
# build 64-bit amd64 binary
CPU_OPT="-xarch=amd64"
CORE_LINK="$CORE_LINK -xarch=amd64"
CPU_OPT="$ngx_amd64"
CORE_LINK="$CORE_LINK $ngx_amd64"
CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_amd64"
NGX_AUX=" src/os/unix/ngx_sunpro_amd64.il"
NGX_CPU_CACHE_LINE=64
;;
esac
@ -95,17 +148,16 @@ CFLAGS="$CFLAGS $CPU_OPT"
if [ ".$PCRE_OPT" = "." ]; then
PCRE_OPT="-fast $CPU_OPT"
fi
if [ ".$MD5_OPT" = "." ]; then
MD5_OPT="-fast $CPU_OPT"
PCRE_OPT="$ngx_fast $IPO $CPU_OPT"
fi
if [ ".$ZLIB_OPT" = "." ]; then
ZLIB_OPT="-fast $CPU_OPT"
ZLIB_OPT="$ngx_fast $IPO $CPU_OPT"
fi
# stop on warning
CFLAGS="$CFLAGS -errwarn=%all"
# debug
CFLAGS="$CFLAGS -g"

71
auto/configure vendored
View File

@ -1,15 +1,17 @@
#!/bin/sh
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
NGX_CONFIGURE=`echo $@ | sed 's/"/\\\\"/g'`
LC_ALL=C
export LC_ALL
. auto/options
. auto/init
. auto/sources
test -d $NGX_OBJS || mkdir $NGX_OBJS
test -d $NGX_OBJS || mkdir -p $NGX_OBJS
echo > $NGX_AUTO_HEADERS_H
echo > $NGX_AUTOCONF_ERR
@ -33,9 +35,16 @@ if test -z "$NGX_PLATFORM"; then
NGX_PLATFORM="$NGX_SYSTEM:$NGX_RELEASE:$NGX_MACHINE";
case "$NGX_SYSTEM" in
MINGW32_* | MINGW64_* | MSYS_*)
NGX_PLATFORM=win32
;;
esac
else
echo "building for $NGX_PLATFORM"
NGX_SYSTEM=$NGX_PLATFORM
NGX_MACHINE=i386
fi
. auto/cc/conf
@ -46,32 +55,41 @@ fi
. auto/os/conf
if [ "$NGX_PLATFORM" != win32 ]; then
. auto/os/features
. auto/threads
fi
. auto/modules
. auto/lib/conf
. auto/make
. auto/lib/make
. auto/install
if [ "$NGX_PLATFORM" != win32 ]; then
. auto/unix
fi
# STUB
. auto/stubs
. auto/threads
. auto/modules
. auto/lib/conf
case ".$NGX_PREFIX" in
.)
NGX_PREFIX=${NGX_PREFIX:-/usr/local/nginx}
have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
;;
.!)
NGX_PREFIX=
;;
*)
have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
;;
esac
if [ ".$NGX_CONF_PREFIX" != "." ]; then
have=NGX_CONF_PREFIX value="\"$NGX_CONF_PREFIX/\"" . auto/define
fi
have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
have=NGX_SBIN_PATH value="\"$NGX_SBIN_PATH\"" . auto/define
have=NGX_CONF_PATH value="\"$NGX_CONF_PATH\"" . auto/define
have=NGX_PID_PATH value="\"$NGX_PID_PATH\"" . auto/define
have=NGX_LOCK_PATH value="\"$NGX_LOCK_PATH\"" . auto/define
if test -n "$NGX_ERROR_LOG_PATH"; then
have=NGX_ERROR_LOG_PATH value="\"$NGX_ERROR_LOG_PATH\"" . auto/define
have=NGX_ERROR_LOG_PATH value="\"$NGX_ERROR_LOG_PATH\"" . auto/define
if [ ".$NGX_ERROR_LOG_PATH" = "." ]; then
have=NGX_ERROR_LOG_STDERR . auto/have
fi
have=NGX_HTTP_LOG_PATH value="\"$NGX_HTTP_LOG_PATH\"" . auto/define
@ -81,8 +99,23 @@ have=NGX_HTTP_PROXY_TEMP_PATH value="\"$NGX_HTTP_PROXY_TEMP_PATH\""
. auto/define
have=NGX_HTTP_FASTCGI_TEMP_PATH value="\"$NGX_HTTP_FASTCGI_TEMP_PATH\""
. auto/define
have=NGX_HTTP_UWSGI_TEMP_PATH value="\"$NGX_HTTP_UWSGI_TEMP_PATH\""
. auto/define
have=NGX_HTTP_SCGI_TEMP_PATH value="\"$NGX_HTTP_SCGI_TEMP_PATH\""
. auto/define
. auto/make
. auto/lib/make
. auto/install
# STUB
. auto/stubs
have=NGX_USER value="\"$NGX_USER\"" . auto/define
have=NGX_GROUP value="\"$NGX_GROUP\"" . auto/define
if [ ".$NGX_BUILD" != "." ]; then
have=NGX_BUILD value="\"$NGX_BUILD\"" . auto/define
fi
. auto/summary

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
cat << END >> $NGX_AUTO_CONFIG_H

View File

@ -1,15 +1,21 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
echo $ngx_n "checking for system endianess ...$ngx_c"
echo >> $NGX_ERR
echo "checking for system endianess" >> $NGX_ERR
echo $ngx_n "checking for system byte ordering ...$ngx_c"
cat << END >> $NGX_AUTOCONF_ERR
----------------------------------------
checking for system byte ordering
END
cat << END > $NGX_AUTOTEST.c
int main() {
int main(void) {
int i = 0x11223344;
char *p;
@ -27,18 +33,18 @@ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
if $NGX_AUTOTEST >/dev/null 2>&1; then
echo " little endianess"
echo " little endian"
have=NGX_HAVE_LITTLE_ENDIAN . auto/have
else
echo " big endianess"
echo " big endian"
fi
rm $NGX_AUTOTEST*
rm -rf $NGX_AUTOTEST*
else
rm $NGX_AUTOTEST*
rm -rf $NGX_AUTOTEST*
echo
echo "$0: error: can not detect system endianess"
echo "$0: error: cannot detect system byte ordering"
exit 1
fi

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
echo $ngx_n "checking for $ngx_feature ...$ngx_c"
@ -19,7 +20,9 @@ if test -n "$ngx_feature_name"; then
fi
if test -n "$ngx_feature_path"; then
ngx_feature_inc_path="-I $ngx_feature_path"
for ngx_temp in $ngx_feature_path; do
ngx_feature_inc_path="$ngx_feature_inc_path -I $ngx_temp"
done
fi
cat << END > $NGX_AUTOTEST.c
@ -28,7 +31,7 @@ cat << END > $NGX_AUTOTEST.c
$NGX_INCLUDE_UNISTD_H
$ngx_feature_incs
int main() {
int main(void) {
$ngx_feature_test;
return 0;
}
@ -37,7 +40,7 @@ END
ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS $ngx_feature_inc_path \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_TEST_LD_OPT $ngx_feature_libs"
ngx_feature_inc_path=
@ -50,7 +53,7 @@ if [ -x $NGX_AUTOTEST ]; then
yes)
# /bin/sh is used to intercept "Killed" or "Abort trap" messages
if /bin/sh -c $NGX_AUTOTEST >/dev/null 2>&1; then
if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
echo " found"
ngx_found=yes
@ -63,9 +66,27 @@ if [ -x $NGX_AUTOTEST ]; then
fi
;;
value)
# /bin/sh is used to intercept "Killed" or "Abort trap" messages
if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
echo " found"
ngx_found=yes
cat << END >> $NGX_AUTO_CONFIG_H
#ifndef $ngx_feature_name
#define $ngx_feature_name `$NGX_AUTOTEST`
#endif
END
else
echo " found but is not working"
fi
;;
bug)
# /bin/sh is used to intercept "Killed" or "Abort trap" messages
if /bin/sh -c $NGX_AUTOTEST >/dev/null 2>&1; then
if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
echo " not found"
else
@ -99,4 +120,4 @@ else
echo "----------" >> $NGX_AUTOCONF_ERR
fi
rm $NGX_AUTOTEST*
rm -rf $NGX_AUTOTEST*

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
cat << END >> $NGX_AUTO_CONFIG_H

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
cat << END >> $NGX_AUTO_HEADERS_H

View File

@ -1,8 +1,13 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
ngx_include="unistd.h"; . auto/include
ngx_include="inttypes.h"; . auto/include
ngx_include="limits.h"; . auto/include
ngx_include="sys/filio.h"; . auto/include
ngx_include="unistd.h"; . auto/include
ngx_include="inttypes.h"; . auto/include
ngx_include="limits.h"; . auto/include
ngx_include="sys/filio.h"; . auto/include
ngx_include="sys/param.h"; . auto/include
ngx_include="sys/mount.h"; . auto/include
ngx_include="sys/statvfs.h"; . auto/include
ngx_include="crypt.h"; . auto/include

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
echo $ngx_n "checking for $ngx_include ...$ngx_c"
@ -16,9 +17,10 @@ ngx_found=no
cat << END > $NGX_AUTOTEST.c
$NGX_INCLUDE_SYS_PARAM_H
#include <$ngx_include>
int main() {
int main(void) {
return 0;
}
@ -43,9 +45,6 @@ if [ -x $NGX_AUTOTEST ]; then
eval "NGX_INCLUDE_$ngx_name='#include <$ngx_include>'"
#STUB
eval "NGX_$ngx_name='#include <$ngx_include>'"
else
echo " not found"
@ -56,4 +55,4 @@ else
echo "----------" >> $NGX_AUTOCONF_ERR
fi
rm $NGX_AUTOTEST*
rm -rf $NGX_AUTOTEST*

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
NGX_MAKEFILE=$NGX_OBJS/Makefile
@ -43,27 +44,10 @@ fi
cat << END > Makefile
build:
\$(MAKE) -f $NGX_MAKEFILE
install:
\$(MAKE) -f $NGX_MAKEFILE install
default: build
clean:
rm -rf Makefile $NGX_OBJS
upgrade:
$NGX_SBIN_PATH -t
# upgrade compatibility from 0.1.x to 0.2.x
cp $NGX_PID_PATH $NGX_PID_PATH.oldbin
kill -USR2 \`cat $NGX_PID_PATH\`
sleep 1
test -f $NGX_PID_PATH.oldbin
# upgrade compatibility from 0.1.x to 0.2.x
cp $NGX_PID_PATH $NGX_PID_PATH.newbin
kill -WINCH \`cat $NGX_PID_PATH.oldbin\`
.PHONY: default clean
END

View File

@ -1,13 +1,14 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
if [ $USE_PERL = YES ]; then
if [ $USE_PERL != NO ]; then
cat << END >> $NGX_MAKEFILE
install_perl_modules:
cd $NGX_OBJS/src/http/modules/perl && make install
cd $NGX_OBJS/src/http/modules/perl && \$(MAKE) install
END
NGX_INSTALL_PERL_MODULES=install_perl_modules
@ -15,46 +16,205 @@ END
fi
case ".$NGX_SBIN_PATH" in
./*)
;;
*)
NGX_SBIN_PATH=$NGX_PREFIX/$NGX_SBIN_PATH
;;
esac
case ".$NGX_MODULES_PATH" in
./*)
;;
*)
NGX_MODULES_PATH=$NGX_PREFIX/$NGX_MODULES_PATH
;;
esac
NGX_MODULES_PATH=`dirname $NGX_MODULES_PATH/.`
case ".$NGX_CONF_PATH" in
./*)
;;
*)
NGX_CONF_PATH=$NGX_PREFIX/$NGX_CONF_PATH
;;
esac
NGX_CONF_PREFIX=`dirname $NGX_CONF_PATH`
case ".$NGX_PID_PATH" in
./*)
;;
*)
NGX_PID_PATH=$NGX_PREFIX/$NGX_PID_PATH
;;
esac
case ".$NGX_ERROR_LOG_PATH" in
./* | .)
;;
*)
NGX_ERROR_LOG_PATH=$NGX_PREFIX/$NGX_ERROR_LOG_PATH
;;
esac
case ".$NGX_HTTP_LOG_PATH" in
./*)
;;
*)
NGX_HTTP_LOG_PATH=$NGX_PREFIX/$NGX_HTTP_LOG_PATH
;;
esac
if test -f man/nginx.8 ; then
NGX_MAN=man/nginx.8
else
NGX_MAN=docs/man/nginx.8
fi
if test -d html ; then
NGX_HTML=html
else
NGX_HTML=docs/html
fi
cat << END >> $NGX_MAKEFILE
install: $NGX_OBJS${ngx_dirsep}nginx${ngx_binext} \
$NGX_INSTALL_PERL_MODULES
test -d '$NGX_PREFIX' || mkdir -p '$NGX_PREFIX'
manpage: $NGX_OBJS/nginx.8
test -d '`dirname "$NGX_SBIN_PATH"`' \
|| mkdir -p '`dirname "$NGX_SBIN_PATH"`'
test ! -f '$NGX_SBIN_PATH' || mv '$NGX_SBIN_PATH' '$NGX_SBIN_PATH.old'
cp $NGX_OBJS/nginx '$NGX_SBIN_PATH'
$NGX_OBJS/nginx.8: $NGX_MAN $NGX_AUTO_CONFIG_H
sed -e "s|%%PREFIX%%|$NGX_PREFIX|" \\
-e "s|%%PID_PATH%%|$NGX_PID_PATH|" \\
-e "s|%%CONF_PATH%%|$NGX_CONF_PATH|" \\
-e "s|%%ERROR_LOG_PATH%%|${NGX_ERROR_LOG_PATH:-stderr}|" \\
< $NGX_MAN > \$@
test -d '`dirname "$NGX_CONF_PATH"`' \
|| mkdir -p '`dirname "$NGX_CONF_PATH"`'
install: build $NGX_INSTALL_PERL_MODULES
test -d '\$(DESTDIR)$NGX_PREFIX' || mkdir -p '\$(DESTDIR)$NGX_PREFIX'
cp conf/koi-win '`dirname "$NGX_CONF_PATH"`'
cp conf/koi-utf '`dirname "$NGX_CONF_PATH"`'
cp conf/win-utf '`dirname "$NGX_CONF_PATH"`'
test -d '\$(DESTDIR)`dirname "$NGX_SBIN_PATH"`' \\
|| mkdir -p '\$(DESTDIR)`dirname "$NGX_SBIN_PATH"`'
test ! -f '\$(DESTDIR)$NGX_SBIN_PATH' \\
|| mv '\$(DESTDIR)$NGX_SBIN_PATH' \\
'\$(DESTDIR)$NGX_SBIN_PATH.old'
cp $NGX_OBJS/nginx '\$(DESTDIR)$NGX_SBIN_PATH'
test -f '`dirname "$NGX_CONF_PATH"`/mime.types' || \
cp conf/mime.types '`dirname "$NGX_CONF_PATH"`/mime.types'
cp conf/mime.types '`dirname "$NGX_CONF_PATH"`/mime.types.default'
test -d '\$(DESTDIR)$NGX_CONF_PREFIX' \\
|| mkdir -p '\$(DESTDIR)$NGX_CONF_PREFIX'
test -f '$NGX_CONF_PATH' || cp conf/nginx.conf '$NGX_CONF_PATH'
cp conf/nginx.conf '`dirname "$NGX_CONF_PATH"`/nginx.conf.default'
cp conf/koi-win '\$(DESTDIR)$NGX_CONF_PREFIX'
cp conf/koi-utf '\$(DESTDIR)$NGX_CONF_PREFIX'
cp conf/win-utf '\$(DESTDIR)$NGX_CONF_PREFIX'
test -d '`dirname "$NGX_PID_PATH"`' \
|| mkdir -p '`dirname "$NGX_PID_PATH"`'
test -f '\$(DESTDIR)$NGX_CONF_PREFIX/mime.types' \\
|| cp conf/mime.types '\$(DESTDIR)$NGX_CONF_PREFIX'
cp conf/mime.types '\$(DESTDIR)$NGX_CONF_PREFIX/mime.types.default'
test -d '`dirname "$NGX_HTTP_LOG_PATH"`' || \
mkdir -p '`dirname "$NGX_HTTP_LOG_PATH"`'
test -f '\$(DESTDIR)$NGX_CONF_PREFIX/fastcgi_params' \\
|| cp conf/fastcgi_params '\$(DESTDIR)$NGX_CONF_PREFIX'
cp conf/fastcgi_params \\
'\$(DESTDIR)$NGX_CONF_PREFIX/fastcgi_params.default'
test -d '$NGX_PREFIX/html' || cp -r html '$NGX_PREFIX'
test -f '\$(DESTDIR)$NGX_CONF_PREFIX/fastcgi.conf' \\
|| cp conf/fastcgi.conf '\$(DESTDIR)$NGX_CONF_PREFIX'
cp conf/fastcgi.conf '\$(DESTDIR)$NGX_CONF_PREFIX/fastcgi.conf.default'
test -f '\$(DESTDIR)$NGX_CONF_PREFIX/uwsgi_params' \\
|| cp conf/uwsgi_params '\$(DESTDIR)$NGX_CONF_PREFIX'
cp conf/uwsgi_params \\
'\$(DESTDIR)$NGX_CONF_PREFIX/uwsgi_params.default'
test -f '\$(DESTDIR)$NGX_CONF_PREFIX/scgi_params' \\
|| cp conf/scgi_params '\$(DESTDIR)$NGX_CONF_PREFIX'
cp conf/scgi_params \\
'\$(DESTDIR)$NGX_CONF_PREFIX/scgi_params.default'
test -f '\$(DESTDIR)$NGX_CONF_PATH' \\
|| cp conf/nginx.conf '\$(DESTDIR)$NGX_CONF_PATH'
cp conf/nginx.conf '\$(DESTDIR)$NGX_CONF_PREFIX/nginx.conf.default'
test -d '\$(DESTDIR)`dirname "$NGX_PID_PATH"`' \\
|| mkdir -p '\$(DESTDIR)`dirname "$NGX_PID_PATH"`'
test -d '\$(DESTDIR)`dirname "$NGX_HTTP_LOG_PATH"`' \\
|| mkdir -p '\$(DESTDIR)`dirname "$NGX_HTTP_LOG_PATH"`'
test -d '\$(DESTDIR)$NGX_PREFIX/html' \\
|| cp -R $NGX_HTML '\$(DESTDIR)$NGX_PREFIX'
END
if test -n "$NGX_ERROR_LOG_PATH"; then
cat << END >> $NGX_MAKEFILE
test -d '`dirname "$NGX_ERROR_LOG_PATH"`' || \
mkdir -p '`dirname "$NGX_ERROR_LOG_PATH"`'
test -d '\$(DESTDIR)`dirname "$NGX_ERROR_LOG_PATH"`' \\
|| mkdir -p '\$(DESTDIR)`dirname "$NGX_ERROR_LOG_PATH"`'
END
fi
if test -n "$DYNAMIC_MODULES"; then
cat << END >> $NGX_MAKEFILE
test -d '\$(DESTDIR)$NGX_MODULES_PATH' \\
|| mkdir -p '\$(DESTDIR)$NGX_MODULES_PATH'
END
fi
for ngx_module in $DYNAMIC_MODULES
do
ngx_module=$ngx_module$ngx_modext
cat << END >> $NGX_MAKEFILE
test ! -f '\$(DESTDIR)$NGX_MODULES_PATH/$ngx_module' \\
|| mv '\$(DESTDIR)$NGX_MODULES_PATH/$ngx_module' \\
'\$(DESTDIR)$NGX_MODULES_PATH/$ngx_module.old'
cp $NGX_OBJS/$ngx_module '\$(DESTDIR)$NGX_MODULES_PATH/$ngx_module'
END
done
# create Makefile
cat << END >> Makefile
build:
\$(MAKE) -f $NGX_MAKEFILE
install:
\$(MAKE) -f $NGX_MAKEFILE install
modules:
\$(MAKE) -f $NGX_MAKEFILE modules
upgrade:
$NGX_SBIN_PATH -t
kill -USR2 \`cat $NGX_PID_PATH\`
sleep 1
test -f $NGX_PID_PATH.oldbin
kill -QUIT \`cat $NGX_PID_PATH.oldbin\`
.PHONY: build install modules upgrade
END

View File

@ -1,44 +1,54 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
if [ $USE_PCRE = YES -o $PCRE != NONE ]; then
. auto/lib/pcre/conf
else
if [ $USE_PCRE = DISABLED -a $HTTP = YES -a $HTTP_REWRITE = YES ]; then
cat << END
$0: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option or you have to enable the PCRE support.
END
exit 1
fi
fi
if [ $USE_OPENSSL = YES ]; then
. auto/lib/openssl/conf
fi
if [ $USE_MD5 = YES ]; then
if [ $OPENSSL != NONE -a $OPENSSL != NO ]; then
have=NGX_HAVE_OPENSSL_MD5_H . auto/have
have=NGX_OPENSSL_MD5 . auto/have
MD5=YES
else
. auto/lib/md5/conf
fi
fi
if [ $USE_SHA1 = YES ]; then
if [ $OPENSSL != NONE -a $OPENSSL != NO ]; then
have=NGX_HAVE_OPENSSL_SHA1_H . auto/have
SHA1=YES
else
. auto/lib/sha1/conf
fi
fi
if [ $USE_ZLIB = YES ]; then
. auto/lib/zlib/conf
fi
if [ $USE_PERL = YES ]; then
if [ $USE_LIBXSLT != NO ]; then
. auto/lib/libxslt/conf
fi
if [ $USE_LIBGD != NO ]; then
. auto/lib/libgd/conf
fi
if [ $USE_PERL != NO ]; then
. auto/lib/perl/conf
fi
if [ $USE_GEOIP != NO ]; then
. auto/lib/geoip/conf
fi
if [ $NGX_GOOGLE_PERFTOOLS = YES ]; then
. auto/lib/google-perftools/conf
fi
if [ $NGX_LIBATOMIC != NO ]; then
. auto/lib/libatomic/conf
fi

97
auto/lib/geoip/conf Normal file
View File

@ -0,0 +1,97 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
ngx_feature="GeoIP library"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <GeoIP.h>"
ngx_feature_path=
ngx_feature_libs="-lGeoIP"
ngx_feature_test="GeoIP_open(NULL, 0)"
. auto/feature
if [ $ngx_found = no ]; then
# FreeBSD port
ngx_feature="GeoIP library in /usr/local/"
ngx_feature_path="/usr/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lGeoIP"
else
ngx_feature_libs="-L/usr/local/lib -lGeoIP"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# NetBSD port
ngx_feature="GeoIP library in /usr/pkg/"
ngx_feature_path="/usr/pkg/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lGeoIP"
else
ngx_feature_libs="-L/usr/pkg/lib -lGeoIP"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# MacPorts
ngx_feature="GeoIP library in /opt/local/"
ngx_feature_path="/opt/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lGeoIP"
else
ngx_feature_libs="-L/opt/local/lib -lGeoIP"
fi
. auto/feature
fi
if [ $ngx_found = yes ]; then
CORE_INCS="$CORE_INCS $ngx_feature_path"
if [ $USE_GEOIP = YES ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
fi
NGX_LIB_GEOIP=$ngx_feature_libs
ngx_feature="GeoIP IPv6 support"
ngx_feature_name="NGX_HAVE_GEOIP_V6"
ngx_feature_run=no
ngx_feature_incs="#include <stdio.h>
#include <GeoIP.h>"
#ngx_feature_path=
#ngx_feature_libs=
ngx_feature_test="printf(\"%d\", GEOIP_CITY_EDITION_REV0_V6);"
. auto/feature
else
cat << END
$0: error: the GeoIP module requires the GeoIP library.
You can either do not enable the module or install the library.
END
exit 1
fi

View File

@ -0,0 +1,62 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
ngx_feature="Google perftools"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs="-lprofiler"
ngx_feature_test="void ProfilerStop(void);
ProfilerStop()"
. auto/feature
if [ $ngx_found = no ]; then
# FreeBSD port
ngx_feature="Google perftools in /usr/local/"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lprofiler"
else
ngx_feature_libs="-L/usr/local/lib -lprofiler"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# MacPorts
ngx_feature="Google perftools in /opt/local/"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lprofiler"
else
ngx_feature_libs="-L/opt/local/lib -lprofiler"
fi
. auto/feature
fi
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
else
cat << END
$0: error: the Google perftools module requires the Google perftools
library. You can either do not enable the module or install the library.
END
exit 1
fi

43
auto/lib/libatomic/conf Normal file
View File

@ -0,0 +1,43 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
if [ $NGX_LIBATOMIC != YES ]; then
have=NGX_HAVE_LIBATOMIC . auto/have
CORE_INCS="$CORE_INCS $NGX_LIBATOMIC/src"
LINK_DEPS="$LINK_DEPS $NGX_LIBATOMIC/src/libatomic_ops.a"
CORE_LIBS="$CORE_LIBS $NGX_LIBATOMIC/src/libatomic_ops.a"
else
ngx_feature="atomic_ops library"
ngx_feature_name=NGX_HAVE_LIBATOMIC
ngx_feature_run=yes
ngx_feature_incs="#define AO_REQUIRE_CAS
#include <atomic_ops.h>"
ngx_feature_path=
ngx_feature_libs="-latomic_ops"
ngx_feature_test="long n = 0;
if (!AO_compare_and_swap(&n, 0, 1))
return 1;
if (AO_fetch_and_add(&n, 1) != 1)
return 1;
if (n != 2)
return 1;
AO_nop();"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
else
cat << END
$0: error: libatomic_ops library was not found.
END
exit 1
fi
fi

16
auto/lib/libatomic/make Normal file
View File

@ -0,0 +1,16 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
cat << END >> $NGX_MAKEFILE
$NGX_LIBATOMIC/src/libatomic_ops.a: $NGX_LIBATOMIC/Makefile
cd $NGX_LIBATOMIC && \$(MAKE)
$NGX_LIBATOMIC/Makefile: $NGX_MAKEFILE
cd $NGX_LIBATOMIC \\
&& if [ -f Makefile ]; then \$(MAKE) distclean; fi \\
&& ./configure
END

95
auto/lib/libgd/conf Normal file
View File

@ -0,0 +1,95 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
ngx_feature="GD library"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <gd.h>"
ngx_feature_path=
ngx_feature_libs="-lgd"
ngx_feature_test="gdImagePtr img = gdImageCreateFromGifPtr(1, NULL);
(void) img"
. auto/feature
if [ $ngx_found = no ]; then
# FreeBSD port
ngx_feature="GD library in /usr/local/"
ngx_feature_path="/usr/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lgd"
else
ngx_feature_libs="-L/usr/local/lib -lgd"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# NetBSD port
ngx_feature="GD library in /usr/pkg/"
ngx_feature_path="/usr/pkg/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lgd"
else
ngx_feature_libs="-L/usr/pkg/lib -lgd"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# MacPorts
ngx_feature="GD library in /opt/local/"
ngx_feature_path="/opt/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lgd"
else
ngx_feature_libs="-L/opt/local/lib -lgd"
fi
. auto/feature
fi
if [ $ngx_found = yes ]; then
CORE_INCS="$CORE_INCS $ngx_feature_path"
if [ $USE_LIBGD = YES ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
fi
NGX_LIB_LIBGD=$ngx_feature_libs
ngx_feature="GD WebP support"
ngx_feature_name="NGX_HAVE_GD_WEBP"
ngx_feature_test="gdImagePtr img = gdImageCreateFromWebpPtr(1, NULL);
(void) img"
. auto/feature
else
cat << END
$0: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
END
exit 1
fi

165
auto/lib/libxslt/conf Normal file
View File

@ -0,0 +1,165 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
ngx_feature="libxslt"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>"
ngx_feature_path="/usr/include/libxml2"
ngx_feature_libs="-lxml2 -lxslt"
ngx_feature_test="xmlParserCtxtPtr ctxt = NULL;
xsltStylesheetPtr sheet = NULL;
xmlDocPtr doc = NULL;
xmlParseChunk(ctxt, NULL, 0, 0);
xsltApplyStylesheet(sheet, doc, NULL);"
. auto/feature
if [ $ngx_found = no ]; then
# FreeBSD port
ngx_feature="libxslt in /usr/local/"
ngx_feature_path="/usr/local/include/libxml2 /usr/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lxml2 -lxslt"
else
ngx_feature_libs="-L/usr/local/lib -lxml2 -lxslt"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# NetBSD port
ngx_feature="libxslt in /usr/pkg/"
ngx_feature_path="/usr/pkg/include/libxml2 /usr/pkg/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lxml2 -lxslt"
else
ngx_feature_libs="-L/usr/pkg/lib -lxml2 -lxslt"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# MacPorts
ngx_feature="libxslt in /opt/local/"
ngx_feature_path="/opt/local/include/libxml2 /opt/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lxml2 -lxslt"
else
ngx_feature_libs="-L/opt/local/lib -lxml2 -lxslt"
fi
. auto/feature
fi
if [ $ngx_found = yes ]; then
CORE_INCS="$CORE_INCS $ngx_feature_path"
if [ $USE_LIBXSLT = YES ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
fi
NGX_LIB_LIBXSLT=$ngx_feature_libs
else
cat << END
$0: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
END
exit 1
fi
ngx_feature="libexslt"
ngx_feature_name=NGX_HAVE_EXSLT
ngx_feature_run=no
ngx_feature_incs="#include <libexslt/exslt.h>"
ngx_feature_path="/usr/include/libxml2"
ngx_feature_libs="-lexslt"
ngx_feature_test="exsltRegisterAll();"
. auto/feature
if [ $ngx_found = no ]; then
# FreeBSD port
ngx_feature="libexslt in /usr/local/"
ngx_feature_path="/usr/local/include/libxml2 /usr/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lexslt"
else
ngx_feature_libs="-L/usr/local/lib -lexslt"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# NetBSD port
ngx_feature="libexslt in /usr/pkg/"
ngx_feature_path="/usr/pkg/include/libxml2 /usr/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lexslt"
else
ngx_feature_libs="-L/usr/pkg/lib -lexslt"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# MacPorts
ngx_feature="libexslt in /opt/local/"
ngx_feature_path="/opt/local/include/libxml2 /opt/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lexslt"
else
ngx_feature_libs="-L/opt/local/lib -lexslt"
fi
. auto/feature
fi
if [ $ngx_found = yes ]; then
if [ $USE_LIBXSLT = YES ]; then
CORE_LIBS="$CORE_LIBS -lexslt"
fi
NGX_LIB_LIBXSLT="$NGX_LIB_LIBXSLT -lexslt"
fi

View File

@ -1,19 +1,12 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
if [ $PCRE != NONE -a $PCRE != NO -a $PCRE != YES ]; then
. auto/lib/pcre/make
fi
if [ $MD5 != NONE -a $MD5 != NO -a $MD5 != YES ]; then
. auto/lib/md5/make
fi
if [ $SHA1 != NONE -a $SHA1 != NO -a $SHA1 != YES ]; then
. auto/lib/sha1/make
fi
if [ $OPENSSL != NONE -a $OPENSSL != NO -a $OPENSSL != YES ]; then
. auto/lib/openssl/make
fi
@ -22,6 +15,10 @@ if [ $ZLIB != NONE -a $ZLIB != NO -a $ZLIB != YES ]; then
. auto/lib/zlib/make
fi
if [ $USE_PERL = YES ]; then
if [ $NGX_LIBATOMIC != NO -a $NGX_LIBATOMIC != YES ]; then
. auto/lib/libatomic/make
fi
if [ $USE_PERL != NO ]; then
. auto/lib/perl/make
fi

View File

@ -1,112 +0,0 @@
# Copyright (C) Igor Sysoev
if [ $MD5 != NONE ]; then
if grep MD5_Init $MD5/md5.h >/dev/null; then
# OpenSSL md5
OPENSSL_MD5=YES
have=NGX_HAVE_OPENSSL_MD5 . auto/have
have=NGX_OPENSSL_MD5 . auto/have
else
# rsaref md5
OPENSSL_MD5=NO
fi
CORE_INCS="$CORE_INCS $MD5"
case "$NGX_CC_NAME" in
msvc* | owc* | bcc)
LINK_DEPS="$LINK_DEPS $MD5/md5.lib"
CORE_LIBS="$CORE_LIBS $MD5/md5.lib"
;;
icc*)
LINK_DEPS="$LINK_DEPS $MD5/libmd5.a"
# to allow -ipo optimization we link with the *.o but not library
CORE_LIBS="$CORE_LIBS $MD5/md5_dgst.o"
if [ $MD5_ASM = YES ]; then
CORE_LIBS="$CORE_LIBS $MD5/asm/mx86-elf.o"
fi
;;
*)
LINK_DEPS="$LINK_DEPS $MD5/libmd5.a"
CORE_LIBS="$CORE_LIBS $MD5/libmd5.a"
#CORE_LIBS="$CORE_LIBS -L $MD5 -lmd5"
;;
esac
else
if [ "$NGX_PLATFORM" != win32 ]; then
MD5=NO
# Solaris 8/9
ngx_feature="rsaref md5 library"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <md5.h>"
ngx_feature_path=
ngx_feature_libs="-lmd5"
ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
MD5=YES
MD5_LIB=md5
ngx_found=no
else
# FreeBSD
ngx_feature="rsaref md library"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <md5.h>"
ngx_feature_path=
ngx_feature_libs="-lmd"
ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
. auto/feature
fi
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
MD5=YES
MD5_LIB=md
ngx_found=no
else
if [ $MD5 = NO ]; then
# OpenSSL crypto library
ngx_feature="OpenSSL md5 crypto library"
ngx_feature_name="NGX_OPENSSL_MD5"
ngx_feature_run=no
ngx_feature_incs="#include <openssl/md5.h>"
ngx_feature_path=
ngx_feature_libs="-lcrypto"
ngx_feature_test="MD5_CTX md5; MD5_Init(&md5)"
. auto/feature
fi
fi
if [ $ngx_found = yes ]; then
have=NGX_HAVE_OPENSSL_MD5_H . auto/have
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
MD5=YES
MD5_LIB=crypto
fi
fi
fi

View File

@ -1,96 +0,0 @@
# Copyright (C) Igor Sysoev
case "$NGX_CC_NAME" in
msvc*)
ngx_makefile=makefile.msvc
ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC MD5_ASM=$MD5_ASM"
;;
owc*)
ngx_makefile=makefile.owc
ngx_opt="CPU_OPT=\"$CPU_OPT\""
;;
bcc)
ngx_makefile=makefile.bcc
ngx_opt="-DCPU_OPT=\"$CPU_OPT\" -DMD5_ASM=$MD5_ASM"
;;
esac
done=NO
case "$NGX_PLATFORM" in
win32)
cp auto/lib/md5/$ngx_makefile $MD5
cat << END >> $NGX_MAKEFILE
`echo "$MD5/md5.lib: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"`
cd `echo $MD5 | sed -e "s/\//$ngx_regex_dirsep/g"`
\$(MAKE) -f $ngx_makefile $ngx_opt
cd ..\\..\\..
END
done=YES
;;
SunOS:*:i86pc)
if [ $MD5_ASM = YES ]; then
cat << END >> $NGX_MAKEFILE
$MD5/libmd5.a: $NGX_MAKEFILE
cd $MD5 \\
&& \$(MAKE) CFLAGS="$MD5_OPT -DSOL -DMD5_ASM -DL_ENDIAN" \\
CC="\$(CC)" CPP="\$(CPP)" \\
MD5_ASM_OBJ=asm/mx86-sol.o clean libmd5.a
END
done=YES
fi
;;
# FreeBSD: i386
# Linux: i686
*:i386 | *:i686)
if [ $MD5_ASM = YES ]; then
cat << END >> $NGX_MAKEFILE
$MD5/libmd5.a: $NGX_MAKEFILE
cd $MD5 \\
&& \$(MAKE) CFLAGS="$MD5_OPT -DELF -DMD5_ASM -DL_ENDIAN" \\
CC="\$(CC)" CPP="\$(CPP)" \\
MD5_ASM_OBJ=asm/mx86-elf.o clean libmd5.a
END
done=YES
fi
;;
esac
if [ $done = NO ]; then
cat << END >> $NGX_MAKEFILE
$MD5/libmd5.a: $NGX_MAKEFILE
cd $MD5 \\
&& \$(MAKE) CFLAGS="$MD5_OPT" \\
CC="\$(CC)" MD5_ASM_OBJ= clean libmd5.a
END
fi

View File

@ -1,19 +0,0 @@
# Copyright (C) Igor Sysoev
CFLAGS = -q -O2 -tWM $(CPU_OPT) -DL_ENDIAN
!if "$(MD5_ASM)" == "YES"
md5.lib:
bcc32 -c $(CFLAGS) -DMD5_ASM md5_dgst.c
tlib md5.lib +md5_dgst.obj +"asm\m-win32.obj"
!else
md5.lib:
bcc32 -c $(CFLAGS) md5_dgst.c
tlib md5.lib +md5_dgst.obj
!endif

View File

@ -1,19 +0,0 @@
# Copyright (C) Igor Sysoev
CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) -D L_ENDIAN
!IF "$(MD5_ASM)" == "YES"
md5.lib:
cl -c $(CFLAGS) -D MD5_ASM md5_dgst.c
link -lib -out:md5.lib md5_dgst.obj asm/m-win32.obj
!ELSE
md5.lib:
cl -c $(CFLAGS) md5_dgst.c
link -lib -out:md5.lib md5_dgst.obj
!ENDIF

View File

@ -1,9 +0,0 @@
# Copyright (C) Igor Sysoev
CFLAGS = -zq -bt=nt -bm -ot -op -oi -oe -s $(CPU_OPT)
md5.lib:
wcl386 -c $(CFLAGS) -dL_ENDIAN md5_dgst.c
wlib -n md5.lib md5_dgst.obj

View File

@ -1,70 +1,173 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
if [ $OPENSSL != NONE ]; then
CORE_INCS="$CORE_INCS $OPENSSL/include"
have=NGX_OPENSSL . auto/have
have=NGX_SSL . auto/have
if [ $USE_OPENSSL_QUIC = YES ]; then
have=NGX_QUIC . auto/have
have=NGX_QUIC_OPENSSL_COMPAT . auto/have
fi
case "$CC" in
*)
have=NGX_OPENSSL . auto/have
have=NGX_SSL . auto/have
LINK_DEPS="$LINK_DEPS $OPENSSL/libssl.a $OPENSSL/libcrypto.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/libssl.a $OPENSSL/libcrypto.a"
;;
esac
case "$NGX_SYSTEM" in
SunOS|Linux)
CORE_LIBS="$CORE_LIBS -ldl"
;;
esac
cl | bcc32)
CFLAGS="$CFLAGS -DNO_SYS_TYPES_H"
CORE_INCS="$CORE_INCS $OPENSSL/openssl/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/openssl/include/openssl/ssl.h"
else
case "$NGX_PLATFORM" in
win32)
have=NGX_OPENSSL . auto/have
have=NGX_SSL . auto/have
OPENSSL=YES
CORE_INCS="$CORE_INCS c:/openssl/include"
CORE_LIBS="$CORE_LIBS c:/openssl/ssleay32.lib"
CORE_LIBS="$CORE_LIBS c:/openssl/libeay32.lib"
if [ -f $OPENSSL/ms/do_ms.bat ]; then
# before OpenSSL 1.1.0
CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/ssleay32.lib"
CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/libeay32.lib"
else
# OpenSSL 1.1.0+
CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/libssl.lib"
CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/libcrypto.lib"
fi
# libeay32.lib requires gdi32.lib
CORE_LIBS="$CORE_LIBS gdi32.lib"
# OpenSSL 0.8's libeay32.lib requires advapi32.lib
CORE_LIBS="$CORE_LIBS advapi32.lib"
# OpenSSL 1.0.0 requires crypt32.lib
CORE_LIBS="$CORE_LIBS crypt32.lib"
;;
*)
OPENSSL=NO
CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
CORE_LIBS="$CORE_LIBS $NGX_LIBPTHREAD"
ngx_feature="OpenSSL library"
ngx_feature_name="NGX_OPENSSL"
ngx_feature_run=no
ngx_feature_incs="#include <openssl/ssl.h>"
ngx_feature_path=
ngx_feature_libs="-lssl -lcrypto"
ngx_feature_test="SSL_library_init()"
. auto/feature
if [ $ngx_found = yes ]; then
have=NGX_SSL . auto/have
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
OPENSSL=YES
case "$NGX_SYSTEM" in
SunOS)
CORE_LIBS="$CORE_LIBS -ldl"
;;
esac
if [ "$NGX_PLATFORM" = win32 ]; then
CORE_LIBS="$CORE_LIBS -lgdi32 -lcrypt32 -lws2_32"
fi
;;
esac
else
if [ "$NGX_PLATFORM" != win32 ]; then
OPENSSL=NO
ngx_feature="OpenSSL library"
ngx_feature_name="NGX_OPENSSL"
ngx_feature_run=no
ngx_feature_incs="#include <openssl/ssl.h>"
ngx_feature_path=
ngx_feature_libs="-lssl -lcrypto $NGX_LIBDL $NGX_LIBPTHREAD"
ngx_feature_test="SSL_CTX_set_options(NULL, 0)"
. auto/feature
if [ $ngx_found = no ]; then
# FreeBSD port
ngx_feature="OpenSSL library in /usr/local/"
ngx_feature_path="/usr/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lssl -lcrypto"
else
ngx_feature_libs="-L/usr/local/lib -lssl -lcrypto"
fi
ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD"
. auto/feature
fi
if [ $ngx_found = no ]; then
# NetBSD port
ngx_feature="OpenSSL library in /usr/pkg/"
ngx_feature_path="/usr/pkg/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lssl -lcrypto"
else
ngx_feature_libs="-L/usr/pkg/lib -lssl -lcrypto"
fi
ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD"
. auto/feature
fi
if [ $ngx_found = no ]; then
# MacPorts
ngx_feature="OpenSSL library in /opt/local/"
ngx_feature_path="/opt/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lssl -lcrypto"
else
ngx_feature_libs="-L/opt/local/lib -lssl -lcrypto"
fi
ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD"
. auto/feature
fi
if [ $ngx_found = yes ]; then
have=NGX_SSL . auto/have
CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
OPENSSL=YES
if [ $USE_OPENSSL_QUIC = YES ]; then
ngx_feature="OpenSSL QUIC support"
ngx_feature_name="NGX_QUIC"
ngx_feature_test="SSL_set_quic_method(NULL, NULL)"
. auto/feature
if [ $ngx_found = no ]; then
have=NGX_QUIC_OPENSSL_COMPAT . auto/have
ngx_feature="OpenSSL QUIC compatibility"
ngx_feature_test="SSL_CTX_add_custom_ext(NULL, 0, 0,
NULL, NULL, NULL, NULL, NULL)"
. auto/feature
fi
if [ $ngx_found = no ]; then
cat << END
$0: error: certain modules require OpenSSL QUIC support.
You can either do not enable the modules, or install the OpenSSL library with
QUIC support into the system, or build the OpenSSL library with QUIC support
statically from the source with nginx by using --with-openssl=<path> option.
END
exit 1
fi
fi
fi
fi
if [ $OPENSSL != YES ]; then
cat << END
$0: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
END
exit 1
fi
fi

View File

@ -1,27 +1,72 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
if test -n "$OPENSSL_OPT"; then
NGX_OPENSSL_CONFIG="./Configure \"$OPENSSL_OPT\""
else
NGX_OPENSSL_CONFIG="./config"
fi
case "$CC" in
case $USE_THREADS in
NO) NGX_OPENSSL_CONFIG="$NGX_OPENSSL_CONFIG no-threads" ;;
*) NGX_OPENSSL_CONFIG="$NGX_OPENSSL_CONFIG threads" ;;
esac
cl)
case "$NGX_MACHINE" in
amd64)
OPENSSL_TARGET=VC-WIN64A
;;
*)
OPENSSL_TARGET=VC-WIN32
;;
esac
case "$NGX_PLATFORM" in
*)
cat << END >> $NGX_MAKEFILE
$OPENSSL/libssl.a:
$OPENSSL/openssl/include/openssl/ssl.h: $NGX_MAKEFILE
\$(MAKE) -f auto/lib/openssl/makefile.msvc \
OPENSSL="$OPENSSL" OPENSSL_OPT="$OPENSSL_OPT" \
OPENSSL_TARGET="$OPENSSL_TARGET"
END
;;
bcc32)
ngx_opt=`echo "-DOPENSSL=\"$OPENSSL\" -DOPENSSL_OPT=\"$OPENSSL_OPT\"" \
| sed -e "s/\//$ngx_regex_dirsep/g"`
cat << END >> $NGX_MAKEFILE
`echo "$OPENSSL\\openssl\\lib\\libeay32.lib: \
$OPENSSL\\openssl\\include\\openssl\\ssl.h" \
| sed -e "s/\//$ngx_regex_dirsep/g"`
`echo "$OPENSSL\\openssl\\lib\\ssleay32.lib: \
$OPENSSL\\openssl\\include\\openssl\\ssl.h" \
| sed -e "s/\//$ngx_regex_dirsep/g"`
`echo "$OPENSSL\\openssl\\include\\openssl\\ssl.h: $NGX_MAKEFILE" \
| sed -e "s/\//$ngx_regex_dirsep/g"`
\$(MAKE) -f auto/lib/openssl/makefile.bcc $ngx_opt
END
;;
*)
case $OPENSSL in
/*) ngx_prefix="$OPENSSL/.openssl" ;;
*) ngx_prefix="$PWD/$OPENSSL/.openssl" ;;
esac
cat << END >> $NGX_MAKEFILE
$OPENSSL/.openssl/include/openssl/ssl.h: $NGX_MAKEFILE
cd $OPENSSL \\
&& \$(MAKE) clean \\
&& $NGX_OPENSSL_CONFIG no-shared \\
&& \$(MAKE)
&& if [ -f Makefile ]; then \$(MAKE) clean; fi \\
&& ./config --prefix=$ngx_prefix no-shared no-threads $OPENSSL_OPT \\
&& \$(MAKE) \\
&& \$(MAKE) install_sw LIBDIR=lib
END

View File

@ -0,0 +1,18 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
all:
cd $(OPENSSL)
perl Configure BC-32 no-shared --prefix=openssl $(OPENSSL_OPT)
ms\do_nasm
$(MAKE) -f ms\bcb.mak
$(MAKE) -f ms\bcb.mak install
# Borland's make does not expand "[ch]" in
# copy "inc32\openssl\*.[ch]" "openssl\include\openssl"
copy inc32\openssl\*.h openssl\include\openssl

View File

@ -0,0 +1,21 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
all:
cd $(OPENSSL)
perl Configure $(OPENSSL_TARGET) no-shared no-threads \
--prefix="%cd%/openssl" \
--openssldir="%cd%/openssl/ssl" \
$(OPENSSL_OPT)
if exist ms\do_ms.bat ( \
ms\do_ms \
&& $(MAKE) -f ms\nt.mak \
&& $(MAKE) -f ms\nt.mak install \
) else ( \
$(MAKE) \
&& $(MAKE) install_sw \
)

View File

@ -1,86 +1,116 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
if [ $PCRE != NONE ]; then
CORE_INCS="$CORE_INCS $PCRE"
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
case "$NGX_CC_NAME" in
if [ -f $PCRE/src/pcre2.h.generic ]; then
msvc* | owc* | bcc)
have=NGX_PCRE . auto/have
PCRE_LIBRARY=PCRE2
have=NGX_PCRE . auto/have
have=NGX_PCRE2 . auto/have
if [ "$NGX_PLATFORM" = win32 ]; then
have=PCRE2_STATIC . auto/have
fi
CORE_INCS="$CORE_INCS $PCRE/src/"
CORE_DEPS="$CORE_DEPS $PCRE/src/pcre2.h"
case "$NGX_CC_NAME" in
msvc)
LINK_DEPS="$LINK_DEPS $PCRE/src/pcre2-8.lib"
CORE_LIBS="$CORE_LIBS $PCRE/src/pcre2-8.lib"
;;
*)
LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre2-8.a"
CORE_LIBS="$CORE_LIBS $PCRE/.libs/libpcre2-8.a"
;;
esac
else
PCRE_LIBRARY=PCRE
have=NGX_PCRE . auto/have
if [ "$NGX_PLATFORM" = win32 ]; then
have=PCRE_STATIC . auto/have
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
LINK_DEPS="$LINK_DEPS $PCRE/pcre.lib"
CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib"
;;
fi
icc* | sunc )
have=NGX_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
CORE_INCS="$CORE_INCS $PCRE"
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
case "$NGX_CC_NAME" in
echo $ngx_n "checking for PCRE library ...$ngx_c"
msvc | owc | bcc)
LINK_DEPS="$LINK_DEPS $PCRE/pcre.lib"
CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib"
;;
if [ -e $PCRE/pcre.h ]; then
ngx_pcre_ver=`grep PCRE_MAJOR $PCRE/pcre.h \
| sed -e 's/^.*PCRE_MAJOR.* \(.*\)$/\1/'`
*)
LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
CORE_LIBS="$CORE_LIBS $PCRE/.libs/libpcre.a"
;;
else
ngx_pcre_ver=`grep PCRE_MAJOR= $PCRE/configure.in \
| sed -e 's/^.*=\(.*\)$/\1/'`
fi
esac
fi
echo " $ngx_pcre_ver major version found"
# to allow -ipo optimization we link with the *.o but not library
case "$ngx_pcre_ver" in
4|5)
CORE_LIBS="$CORE_LIBS $PCRE/pcre.o"
;;
6)
CORE_LIBS="$CORE_LIBS $PCRE/pcre_chartables.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_compile.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_exec.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_fullinfo.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_globals.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_tables.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_try_flipped.o"
;;
*)
CORE_LIBS="$CORE_LIBS $PCRE/pcre_chartables.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_compile.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_exec.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_fullinfo.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_globals.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_tables.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_try_flipped.o"
CORE_LIBS="$CORE_LIBS $PCRE/pcre_newline.o"
;;
esac
;;
*)
have=NGX_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
CORE_LIBS="$CORE_LIBS $PCRE/.libs/libpcre.a"
#CORE_LIBS="$CORE_LIBS -L $PCRE/.libs -lpcre"
;;
esac
if [ $PCRE_JIT = YES ]; then
have=NGX_HAVE_PCRE_JIT . auto/have
PCRE_CONF_OPT="$PCRE_CONF_OPT --enable-jit"
fi
else
if [ "$NGX_PLATFORM" != win32 ]; then
PCRE=NO
fi
if [ $PCRE = NO -a $PCRE2 != DISABLED ]; then
ngx_feature="PCRE2 library"
ngx_feature_name="NGX_PCRE2"
ngx_feature_run=no
ngx_feature_incs="#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>"
ngx_feature_path=
ngx_feature_libs="-lpcre2-8"
ngx_feature_test="pcre2_code *re;
re = pcre2_compile(NULL, 0, 0, NULL, NULL, NULL);
if (re == NULL) return 1"
. auto/feature
if [ $ngx_found = no ]; then
# pcre2-config
ngx_pcre2_prefix=`pcre2-config --prefix 2>/dev/null`
if [ -n "$ngx_pcre2_prefix" ]; then
ngx_feature="PCRE2 library in $ngx_pcre2_prefix"
ngx_feature_path=`pcre2-config --cflags \
| sed -n -e 's/.*-I *\([^ ][^ ]*\).*/\1/p'`
ngx_feature_libs=`pcre2-config --libs8`
. auto/feature
fi
fi
if [ $ngx_found = yes ]; then
have=NGX_PCRE . auto/have
CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES
PCRE_LIBRARY=PCRE2
fi
fi
if [ $PCRE = NO ]; then
ngx_feature="PCRE library"
ngx_feature_name="NGX_PCRE"
@ -88,113 +118,102 @@ else
ngx_feature_incs="#include <pcre.h>"
ngx_feature_path=
ngx_feature_libs="-lpcre"
ngx_feature_test="pcre *re; re = pcre_compile(NULL, 0, NULL, 0, NULL)"
ngx_feature_test="pcre *re;
re = pcre_compile(NULL, 0, NULL, 0, NULL);
if (re == NULL) return 1"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES
ngx_found=no
if [ $ngx_found = no ]; then
else
# FreeBSD port
ngx_feature="PCRE library in /usr/local/"
ngx_feature_name="NGX_PCRE"
ngx_feature_run=no
ngx_feature_incs="#include <pcre.h>"
ngx_feature_path="/usr/local/include"
ngx_feature_libs="-L /usr/local/lib -lpcre"
ngx_feature_test="pcre *re;
re = pcre_compile(NULL, 0, NULL, 0, NULL)"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lpcre"
else
ngx_feature_libs="-L/usr/local/lib -lpcre"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# RedHat RPM, Solaris package
ngx_feature="PCRE library in /usr/include/pcre/"
ngx_feature_path="/usr/include/pcre"
ngx_feature_libs="-lpcre"
. auto/feature
fi
if [ $ngx_found = no ]; then
# NetBSD port
ngx_feature="PCRE library in /usr/pkg/"
ngx_feature_path="/usr/pkg/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lpcre"
else
ngx_feature_libs="-L/usr/pkg/lib -lpcre"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# MacPorts
ngx_feature="PCRE library in /opt/local/"
ngx_feature_path="/opt/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lpcre"
else
ngx_feature_libs="-L/opt/local/lib -lpcre"
fi
. auto/feature
fi
if [ $ngx_found = yes ]; then
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES
ngx_found=no
PCRE_LIBRARY=PCRE
fi
else
# Linux package
if [ $PCRE = YES ]; then
ngx_feature="PCRE JIT support"
ngx_feature_name="NGX_HAVE_PCRE_JIT"
ngx_feature_test="int jit = 0;
pcre_free_study(NULL);
pcre_config(PCRE_CONFIG_JIT, &jit);
if (jit != 1) return 1;"
. auto/feature
if [ $PCRE = NO ]; then
ngx_feature="PCRE library in /usr/include/pcre/"
ngx_feature_name="NGX_PCRE"
ngx_feature_run=no
ngx_feature_incs="#include <pcre.h>"
ngx_feature_path="/usr/include/pcre"
ngx_feature_libs="-lpcre"
ngx_feature_test="pcre *re;
re = pcre_compile(NULL, 0, NULL, 0, NULL)"
. auto/feature
if [ $ngx_found = yes ]; then
PCRE_JIT=YES
fi
fi
if [ $ngx_found = yes ]; then
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES
ngx_found=no
else
# NetBSD port
if [ $PCRE = NO ]; then
ngx_feature="PCRE library in /usr/pkg/"
ngx_feature_name="NGX_PCRE"
ngx_feature_run=no
ngx_feature_incs="#include <pcre.h>"
ngx_feature_path="/usr/pkg/include"
ngx_feature_libs="-L /usr/pkg/lib -lpcre"
ngx_feature_test="pcre *re;
re = pcre_compile(NULL, 0, NULL, 0, NULL)"
. auto/feature
fi
fi
if [ $ngx_found = yes ]; then
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES
ngx_found=no
else
# MacPorts
if [ $PCRE = NO ]; then
ngx_feature="PCRE library in /opt/local/"
ngx_feature_name="NGX_PCRE"
ngx_feature_run=no
ngx_feature_incs="#include <pcre.h>"
ngx_feature_path="/opt/local/include"
ngx_feature_libs="-L/opt/local/lib -lpcre"
ngx_feature_test="pcre *re;
re = pcre_compile(NULL, 0, NULL, 0, NULL)"
. auto/feature
fi
fi
if [ $ngx_found = yes ]; then
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES
ngx_found=no
fi
fi
if [ $PCRE != YES ]; then
cat << END
$0: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
END
exit 1
fi
fi

View File

@ -1,56 +1,152 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
case "$NGX_CC_NAME" in
if [ $PCRE_LIBRARY = PCRE2 ]; then
msvc*)
ngx_makefile=makefile.msvc
ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC"
;;
# PCRE2
owc*)
ngx_makefile=makefile.owc
ngx_opt="CPU_OPT=\"$CPU_OPT\""
;;
if [ $NGX_CC_NAME = msvc ]; then
bcc)
ngx_makefile=makefile.bcc
ngx_opt="-DCPU_OPT=\"$CPU_OPT\""
;;
# With PCRE2, it is not possible to compile all sources.
# Since list of source files changes between versions, we
# test files which might not be present.
esac
ngx_pcre_srcs="pcre2_auto_possess.c \
pcre2_chartables.c \
pcre2_compile.c \
pcre2_config.c \
pcre2_context.c \
pcre2_dfa_match.c \
pcre2_error.c \
pcre2_jit_compile.c \
pcre2_maketables.c \
pcre2_match.c \
pcre2_match_data.c \
pcre2_newline.c \
pcre2_ord2utf.c \
pcre2_pattern_info.c \
pcre2_string_utils.c \
pcre2_study.c \
pcre2_substitute.c \
pcre2_substring.c \
pcre2_tables.c \
pcre2_ucd.c \
pcre2_valid_utf.c \
pcre2_xclass.c"
ngx_pcre_test="pcre2_convert.c \
pcre2_extuni.c \
pcre2_find_bracket.c \
pcre2_script_run.c \
pcre2_serialize.c"
case "$NGX_PLATFORM" in
for ngx_src in $ngx_pcre_test
do
if [ -f $PCRE/src/$ngx_src ]; then
ngx_pcre_srcs="$ngx_pcre_srcs $ngx_src"
fi
done
win32)
cp auto/lib/pcre/patch.pcre.in $PCRE
cp auto/lib/pcre/patch.pcre.in.owc $PCRE
cp auto/lib/pcre/patch.config.in $PCRE
cp auto/lib/pcre/patch.pcre.c $PCRE
cp auto/lib/pcre/$ngx_makefile $PCRE
ngx_pcre_objs=`echo $ngx_pcre_srcs \
| sed -e "s#\([^ ]*\.\)c#\1$ngx_objext#g"`
ngx_pcre=`echo $PCRE | sed -e "s/\//$ngx_regex_dirsep/g"`
ngx_pcre_srcs=`echo $ngx_pcre_srcs \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g"`
ngx_pcre_objs=`echo $ngx_pcre_objs \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g"`
cat << END >> $NGX_MAKEFILE
`echo "$PCRE/pcre.h: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"`
cd $ngx_pcre
\$(MAKE) -f $ngx_makefile pcre.h
cd ..\\..\\..
PCRE_CFLAGS = -O2 -Ob1 -Oi -Gs $LIBC $CPU_OPT
PCRE_FLAGS = -DHAVE_CONFIG_H -DPCRE2_STATIC -DPCRE2_CODE_UNIT_WIDTH=8 \\
-DHAVE_MEMMOVE
PCRE_SRCS = $ngx_pcre_srcs
PCRE_OBJS = $ngx_pcre_objs
`echo "$PCRE/pcre.lib: $PCRE/pcre.h" | sed -e "s/\//$ngx_regex_dirsep/g"`
cd $ngx_pcre
\$(MAKE) -f $ngx_makefile $ngx_opt
cd ..\\..\\..
$PCRE/src/pcre2.h:
cd $PCRE/src \\
&& copy /y config.h.generic config.h \\
&& copy /y pcre2.h.generic pcre2.h \\
&& copy /y pcre2_chartables.c.dist pcre2_chartables.c
$PCRE/src/pcre2-8.lib: $PCRE/src/pcre2.h $NGX_MAKEFILE
cd $PCRE/src \\
&& cl -nologo -c \$(PCRE_CFLAGS) -I . \$(PCRE_FLAGS) \$(PCRE_SRCS) \\
&& link -lib -out:pcre2-8.lib -verbose:lib \$(PCRE_OBJS)
END
;;
else
cat << END >> $NGX_MAKEFILE
$PCRE/src/pcre2.h: $PCRE/Makefile
$PCRE/Makefile: $NGX_MAKEFILE
cd $PCRE \\
&& if [ -f Makefile ]; then \$(MAKE) distclean; fi \\
&& CC="\$(CC)" CFLAGS="$PCRE_OPT" \\
./configure --disable-shared $PCRE_CONF_OPT
$PCRE/.libs/libpcre2-8.a: $PCRE/Makefile
cd $PCRE \\
&& \$(MAKE) libpcre2-8.la
END
fi
else
# PCRE
case "$NGX_CC_NAME" in
msvc)
ngx_makefile=makefile.msvc
ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC"
ngx_pcre="PCRE=\"$PCRE\""
;;
owc)
ngx_makefile=makefile.owc
ngx_opt="CPU_OPT=\"$CPU_OPT\""
ngx_pcre=`echo PCRE=\"$PCRE\" | sed -e "s/\//$ngx_regex_dirsep/g"`
;;
bcc)
ngx_makefile=makefile.bcc
ngx_opt="-DCPU_OPT=\"$CPU_OPT\""
ngx_pcre=`echo \-DPCRE=\"$PCRE\" \
| sed -e "s/\//$ngx_regex_dirsep/g"`
;;
*)
ngx_makefile=
;;
esac
if [ -n "$ngx_makefile" ]; then
cat << END >> $NGX_MAKEFILE
`echo "$PCRE/pcre.lib: $PCRE/pcre.h $NGX_MAKEFILE" \
| sed -e "s/\//$ngx_regex_dirsep/g"`
\$(MAKE) -f auto/lib/pcre/$ngx_makefile $ngx_pcre $ngx_opt
`echo "$PCRE/pcre.h:" | sed -e "s/\//$ngx_regex_dirsep/g"`
\$(MAKE) -f auto/lib/pcre/$ngx_makefile $ngx_pcre pcre.h
END
else
*)
cat << END >> $NGX_MAKEFILE
$PCRE/pcre.h: $PCRE/Makefile
@ -59,8 +155,7 @@ $PCRE/Makefile: $NGX_MAKEFILE
cd $PCRE \\
&& if [ -f Makefile ]; then \$(MAKE) distclean; fi \\
&& CC="\$(CC)" CFLAGS="$PCRE_OPT" \\
./configure --disable-shared
./configure --disable-shared $PCRE_CONF_OPT
$PCRE/.libs/libpcre.a: $PCRE/Makefile
cd $PCRE \\
@ -68,6 +163,6 @@ $PCRE/.libs/libpcre.a: $PCRE/Makefile
END
;;
fi
esac
fi

View File

@ -1,21 +1,27 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
CFLAGS = -q -O2 -tWM -w-8004 $(CPU_OPT)
PCREFLAGS = -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10
PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 \
-DSUPPORT_PCRE8 -DHAVE_MEMMOVE
pcre.lib: pcre.h
bcc32 -q -edftables dftables.c
pcre.lib:
cd $(PCRE)
dftables > chartables.c
bcc32 -c $(CFLAGS) -I. $(PCREFLAGS) pcre_*.c
bcc32 -c $(CFLAGS) $(PCREFLAGS) maketables.c get.c study.c pcre.c
copy /y nul pcre.lst
for %n in (*.obj) do @echo +%n ^^& >> pcre.lst
echo + >> pcre.lst
tlib pcre.lib +maketables.obj +get.obj +study.obj +pcre.obj
tlib pcre.lib @pcre.lst
pcre.h:
patch -o pcre.h pcre.in patch.pcre.in
patch -o config.h config.in patch.config.in
patch -o pcre.c pcre.c patch.pcre.c
cd $(PCRE)
copy /y pcre.h.generic pcre.h
copy /y config.h.generic config.h
copy /y pcre_chartables.c.dist pcre_chartables.c

View File

@ -1,23 +1,23 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
CFLAGS = -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT)
PCREFLAGS = -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10
PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 \
-DSUPPORT_PCRE8 -DHAVE_MEMMOVE
pcre.lib: pcre.h
cl -Fedftables dftables.c
pcre.lib:
cd $(PCRE)
dftables > chartables.c
cl -nologo -c $(CFLAGS) -I . $(PCREFLAGS) pcre_*.c
cl -nologo -c $(CFLAGS) $(PCREFLAGS) \
maketables.c get.c study.c pcre.c
link -lib -out:pcre.lib -verbose:lib \
maketables.obj get.obj study.obj pcre.obj
link -lib -out:pcre.lib -verbose:lib pcre_*.obj
pcre.h:
patch -o pcre.h pcre.in patch.pcre.in
patch -o config.h config.in patch.config.in
patch -o pcre.c pcre.c patch.pcre.c
cd $(PCRE)
copy /y pcre.h.generic pcre.h
copy /y config.h.generic config.h
copy /y pcre_chartables.c.dist pcre_chartables.c

View File

@ -1,19 +1,25 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
CFLAGS = -c -zq -bt=nt -ot -op -oi -oe -s -bm $(CPU_OPT)
PCREFLAGS = -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10
PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 &
-DSUPPORT_PCRE8 -DHAVE_MEMMOVE
pcre.lib: pcre.h
wcl386 -zq -bt=nt -l=nt -fe=dftables dftables.c
dftables > chartables.c
pcre.lib:
cd $(PCRE)
wcl386 $(CFLAGS) $(PCREFLAGS) maketables.c get.c study.c pcre.c
wlib -n pcre.lib maketables.obj get.obj study.obj pcre.obj
wcl386 $(CFLAGS) -i=. $(PCREFLAGS) pcre_*.c
dir /b *.obj > pcre.lst
wlib -n pcre.lib @pcre.lst
pcre.h:
patch -o pcre.h pcre.in patch.pcre.in.owc
patch -o config.h config.in patch.config.in
cd $(PCRE)
copy /y pcre.h.generic pcre.h
copy /y config.h.generic config.h
copy /y pcre_chartables.c.dist pcre_chartables.c

View File

@ -1,11 +0,0 @@
--- config.in Thu Aug 21 14:43:07 2003
+++ config.in Sun Mar 7 02:37:24 2004
@@ -28,7 +28,7 @@
found. */
#define HAVE_STRERROR 0
-#define HAVE_MEMMOVE 0
+#define HAVE_MEMMOVE 1
/* There are some non-Unix systems that don't even have bcopy(). If this macro
is false, an emulation is used. If HAVE_MEMMOVE is set to 1, the value of

View File

@ -1,13 +0,0 @@
--- pcre.c Thu Aug 21 14:43:07 2003
+++ pcre.c Tue Mar 22 12:56:59 2005
@@ -246,8 +246,8 @@
extern "C" void (*pcre_free)(void *) = free;
extern "C" int (*pcre_callout)(pcre_callout_block *) = NULL;
#else
-void *(*pcre_malloc)(size_t) = malloc;
-void (*pcre_free)(void *) = free;
+void *(__cdecl *pcre_malloc)(size_t) = malloc;
+void (__cdecl *pcre_free)(void *) = free;
int (*pcre_callout)(pcre_callout_block *) = NULL;
#endif
#endif

View File

@ -1,26 +0,0 @@
--- pcre.in Thu Aug 21 14:43:07 2003
+++ pcre.h Tue Mar 22 12:56:59 2005
@@ -10,9 +10,9 @@
/* The file pcre.h is build by "configure". Do not edit it; instead
make changes to pcre.in. */
-#define PCRE_MAJOR @PCRE_MAJOR@
-#define PCRE_MINOR @PCRE_MINOR@
-#define PCRE_DATE @PCRE_DATE@
+#define PCRE_MAJOR 4
+#define PCRE_MINOR 4
+#define PCRE_DATE 21-August-2003
/* Win32 uses DLL by default */
@@ -143,8 +143,8 @@
have to be different again. */
#ifndef VPCOMPAT
-PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);
-PCRE_DATA_SCOPE void (*pcre_free)(void *);
+PCRE_DATA_SCOPE void *(__cdecl *pcre_malloc)(size_t);
+PCRE_DATA_SCOPE void (__cdecl *pcre_free)(void *);
PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *);
#else /* VPCOMPAT */
extern void *pcre_malloc(size_t);

View File

@ -1,15 +0,0 @@
--- pcre.in Thu Aug 21 14:43:07 2003
+++ pcre.h Tue Mar 22 12:56:59 2005
@@ -10,9 +10,9 @@
/* The file pcre.h is build by "configure". Do not edit it; instead
make changes to pcre.in. */
-#define PCRE_MAJOR @PCRE_MAJOR@
-#define PCRE_MINOR @PCRE_MINOR@
-#define PCRE_DATE @PCRE_DATE@
+#define PCRE_MAJOR 4
+#define PCRE_MINOR 4
+#define PCRE_DATE 21-August-2003
/* Win32 uses DLL by default */

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
echo "checking for perl"
@ -11,16 +12,26 @@ NGX_PERL_VER=`$NGX_PERL -v 2>&1 | grep '^This is perl' 2>&1 \
if test -n "$NGX_PERL_VER"; then
echo " + perl version: $NGX_PERL_VER"
if [ "`echo 'use 5.006001; print "OK"' | $NGX_PERL 2>&1`" != OK ]; then
if [ "`$NGX_PERL -e 'use 5.008006; print "OK"'`" != "OK" ]; then
echo
echo "$0: error: perl 5.6.1 or higher is required"
echo "$0: error: perl 5.8.6 or higher is required"
echo
exit 1;
fi
if [ "`$NGX_PERL -MExtUtils::Embed -e 'print "OK"'`" != "OK" ]; then
echo
echo "$0: error: perl module ExtUtils::Embed is required"
echo
exit 1;
fi
NGX_PERL_CFLAGS="$CFLAGS `$NGX_PERL -MExtUtils::Embed -e ccopts`"
NGX_PM_CFLAGS=`$NGX_PERL -MExtUtils::Embed -e ccopts`
NGX_PM_LDFLAGS=`$NGX_PERL -MConfig -e 'print $Config{lddlflags}'`
NGX_PERL_CFLAGS="$CFLAGS `$NGX_PERL -MExtUtils::Embed -e ccopts`"
# gcc 4.1/4.2 warn about unused values in pTHX_
NGX_PERL_CFLAGS=`echo $NGX_PERL_CFLAGS \
@ -31,6 +42,10 @@ if test -n "$NGX_PERL_VER"; then
ngx_perl_ldopts=`$NGX_PERL -MExtUtils::Embed -e ldopts`
ngx_perl_dlext=`$NGX_PERL -MConfig -e 'print $Config{dlext}'`
ngx_perl_libdir="src/http/modules/perl/blib/arch/auto"
ngx_perl_module="$ngx_perl_libdir/nginx/nginx.$ngx_perl_dlext"
if $NGX_PERL -V:usemultiplicity | grep define > /dev/null; then
have=NGX_HAVE_PERL_MULTIPLICITY . auto/have
echo " + perl interpreter multiplicity found"
@ -41,8 +56,17 @@ if test -n "$NGX_PERL_VER"; then
ngx_perl_ldopts=`echo $ngx_perl_ldopts | sed 's/ -pthread//'`
fi
CORE_LINK="$CORE_LINK $ngx_perl_ldopts"
LINK_DEPS="$LINK_DEPS $NGX_OBJS/src/http/modules/perl/blib/arch/auto/nginx/nginx.so"
if [ "$NGX_SYSTEM" = "Darwin" ]; then
# OS X system perl wants to link universal binaries
ngx_perl_ldopts=`echo $ngx_perl_ldopts \
| sed -e 's/-arch i386//' -e 's/-arch x86_64//'`
fi
if [ $USE_PERL = YES ]; then
CORE_LINK="$CORE_LINK $ngx_perl_ldopts"
fi
NGX_LIB_PERL="$ngx_perl_ldopts"
if test -n "$NGX_PERL_MODULES"; then
have=NGX_PERL_MODULES value="(u_char *) \"$NGX_PERL_MODULES\""
@ -52,7 +76,7 @@ if test -n "$NGX_PERL_VER"; then
else
echo
echo "$0: error: perl 5.6.1 or higher is required"
echo "$0: error: perl 5.8.6 or higher is required"
echo
exit 1;

View File

@ -1,34 +1,46 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
cat << END >> $NGX_MAKEFILE
$NGX_OBJS/src/http/modules/perl/blib/arch/auto/nginx/nginx.so: \
src/http/modules/perl/nginx.pm \
src/http/modules/perl/nginx.xs \
src/http/modules/perl/ngx_http_perl_module.h \
$NGX_OBJS/src/http/modules/perl/Makefile
cp -p src/http/modules/perl/nginx.* $NGX_OBJS/src/http/modules/perl/
$NGX_OBJS/src/http/modules/perl/ngx_http_perl_module.o: \\
$NGX_OBJS/$ngx_perl_module
cd $NGX_OBJS/src/http/modules/perl && make
$NGX_OBJS/$ngx_perl_module: \\
\$(CORE_DEPS) \$(HTTP_DEPS) \\
src/http/modules/perl/ngx_http_perl_module.h \\
$NGX_OBJS/src/http/modules/perl/Makefile
cd $NGX_OBJS/src/http/modules/perl && \$(MAKE)
rm -rf $NGX_OBJS/install_perl
$NGX_OBJS/src/http/modules/perl/Makefile: \
src/http/modules/perl/Makefile.PL \
src/http/modules/perl/nginx.pm
cp -p src/http/modules/perl/nginx.* $NGX_OBJS/src/http/modules/perl/
$NGX_OBJS/src/http/modules/perl/Makefile: \\
$NGX_AUTO_CONFIG_H \\
src/core/nginx.h \\
src/http/modules/perl/Makefile.PL \\
src/http/modules/perl/nginx.pm \\
src/http/modules/perl/nginx.xs \\
src/http/modules/perl/typemap
grep 'define NGINX_VERSION' src/core/nginx.h \\
| sed -e 's/^.*"\(.*\)".*/\1/' > \\
$NGX_OBJS/src/http/modules/perl/version
sed "s/%%VERSION%%/\`cat $NGX_OBJS/src/http/modules/perl/version\`/" \\
src/http/modules/perl/nginx.pm > \\
$NGX_OBJS/src/http/modules/perl/nginx.pm
cp -p src/http/modules/perl/nginx.xs $NGX_OBJS/src/http/modules/perl/
cp -p src/http/modules/perl/typemap $NGX_OBJS/src/http/modules/perl/
cp -p src/http/modules/perl/Makefile.PL $NGX_OBJS/src/http/modules/perl/
cd $NGX_OBJS/src/http/modules/perl \
&& NGX_PM_CFLAGS="\$(NGX_PM_CFLAGS) -g $NGX_CC_OPT" \
NGX_PCRE=$PCRE \
NGX_OBJS=$NGX_OBJS \
$NGX_PERL Makefile.PL \
LIB=$NGX_PERL_MODULES \
cd $NGX_OBJS/src/http/modules/perl \\
&& NGX_PM_CFLAGS="\$(NGX_PM_CFLAGS) -g $NGX_CC_OPT" \\
NGX_PM_LDFLAGS="$NGX_LD_OPT \$(NGX_PM_LDFLAGS)" \\
NGX_INCS="$CORE_INCS $NGX_OBJS $HTTP_INCS" \\
NGX_DEPS="\$(CORE_DEPS) \$(HTTP_DEPS)" \\
$NGX_PERL Makefile.PL \\
LIB=$NGX_PERL_MODULES \\
INSTALLSITEMAN3DIR=$NGX_PERL_MODULES_MAN
END

View File

@ -1,83 +0,0 @@
# Copyright (C) Igor Sysoev
if [ $SHA1 != NONE ]; then
CORE_INCS="$CORE_INCS $SHA1"
case "$NGX_CC_NAME" in
msvc* | owc* | bcc)
LINK_DEPS="$LINK_DEPS $SHA1/sha1.lib"
CORE_LIBS="$CORE_LIBS $SHA1/sha1.lib"
;;
icc*)
LINK_DEPS="$LINK_DEPS $SHA1/libsha.a"
# to allow -ipo optimization we link with the *.o but not library
CORE_LIBS="$CORE_LIBS $SHA1/sha1_dgst.o"
if [ $SHA1_ASM = YES ]; then
CORE_LIBS="$CORE_LIBS $SHA1/asm/sx86-elf.o"
fi
;;
*)
LINK_DEPS="$LINK_DEPS $SHA1/libsha.a"
CORE_LIBS="$CORE_LIBS $SHA1/libsha.a"
#CORE_LIBS="$CORE_LIBS -L $SHA1 -lsha"
;;
esac
else
if [ "$NGX_PLATFORM" != win32 ]; then
SHA1=NO
# FreeBSD
ngx_feature="sha1 in system md library"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <sha.h>"
ngx_feature_path=
ngx_feature_libs="-lmd"
ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
SHA1=YES
SHA1_LIB=md
ngx_found=no
else
if [ $SHA1 = NO ]; then
# OpenSSL crypto library
ngx_feature="OpenSSL sha1 crypto library"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <openssl/sha.h>"
ngx_feature_path=
ngx_feature_libs="-lcrypto"
ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)"
. auto/feature
fi
fi
if [ $ngx_found = yes ]; then
have=NGX_HAVE_OPENSSL_SHA1_H . auto/have
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
SHA1=YES
SHA1_LIB=crypto
fi
fi
fi

View File

@ -1,96 +0,0 @@
# Copyright (C) Igor Sysoev
case "$NGX_CC_NAME" in
msvc*)
ngx_makefile=makefile.msvc
ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC SHA1_ASM=$SHA1_ASM"
;;
owc*)
ngx_makefile=makefile.owc
ngx_opt="CPU_OPT=\"$CPU_OPT\""
;;
bcc)
ngx_makefile=makefile.bcc
ngx_opt="-DCPU_OPT=\"$CPU_OPT\" -DSHA1_ASM=$SHA1_ASM"
;;
esac
done=NO
case "$NGX_PLATFORM" in
win32)
cp auto/lib/sha1/$ngx_makefile $SHA1
cat << END >> $NGX_MAKEFILE
`echo "$SHA1/sha1.lib: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"`
cd `echo $SHA1 | sed -e "s/\//$ngx_regex_dirsep/g"`
\$(MAKE) -f $ngx_makefile $ngx_opt
cd ..\\..\\..
END
done=YES
;;
SunOS:*:i86pc)
if [ $SHA1_ASM = YES ]; then
cat << END >> $NGX_MAKEFILE
$SHA1/libsha.a: $NGX_MAKEFILE
cd $SHA1 \\
&& \$(MAKE) CFLAGS="$SHA1_OPT -DSOL -DSHA1_ASM -DL_ENDIAN" \\
CC="\$(CC)" CPP="\$(CPP)" \\
SHA_ASM_OBJ=asm/sx86-sol.o clean libsha.a
END
done=YES
fi
;;
# FreeBSD: i386
# Linux: i686
*:i386 | *:i686)
if [ $SHA1_ASM = YES ]; then
cat << END >> $NGX_MAKEFILE
$SHA1/libsha.a: $NGX_MAKEFILE
cd $SHA1 \\
&& \$(MAKE) CFLAGS="$SHA1_OPT -DELF -DSHA1_ASM -DL_ENDIAN" \\
CC="\$(CC)" CPP="\$(CPP)" \\
SHA_ASM_OBJ=asm/sx86-elf.o clean libsha.a
END
done=YES
fi
;;
esac
if [ $done = NO ]; then
cat << END >> $NGX_MAKEFILE
$SHA1/libsha.a: $NGX_MAKEFILE
cd $SHA1 \\
&& \$(MAKE) CFLAGS="$SHA1_OPT" \\
CC="\$(CC)" SHA_ASM_OBJ= clean libsha.a
END
fi

View File

@ -1,19 +0,0 @@
# Copyright (C) Igor Sysoev
CFLAGS = -q -O2 -tWM $(CPU_OPT) -DL_ENDIAN
!if "$(SHA1_ASM)" == "YES"
sha1.lib:
bcc32 -c $(CFLAGS) -DSHA1_ASM sha1dgst.c
tlib sha1.lib +sha1dgst.obj +"asm\s-win32.obj"
!else
sha1.lib:
bcc32 -c $(CFLAGS) sha1dgst.c
tlib sha1.lib +sha1dgst.obj
!endif

View File

@ -1,19 +0,0 @@
# Copyright (C) Igor Sysoev
CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) -D L_ENDIAN
!IF "$(SHA1_ASM)" == "YES"
sha1.lib:
cl -c $(CFLAGS) -D SHA1_ASM sha1dgst.c
link -lib -out:sha1.lib sha1dgst.obj asm/s-win32.obj
!ELSE
sha1.lib:
cl -c $(CFLAGS) sha1dgst.c
link -lib -out:sha1.lib sha1dgst.obj
!ENDIF

View File

@ -1,9 +0,0 @@
# Copyright (C) Igor Sysoev
CFLAGS = -zq -bt=nt -bm -ot -op -oi -oe -s $(CPU_OPT)
sha1.lib:
wcl386 -c $(CFLAGS) -dL_ENDIAN sha1dgst.c
wlib -n sha1.lib sha1dgst.obj

View File

@ -1,39 +0,0 @@
# Copyright (C) Igor Sysoev
echo $ngx_n "checking for $ngx_lib ...$ngx_c"
cat << END >> $NGX_AUTOCONF_ERR
----------------------------------------
checking for $ngx_lib
END
ngx_found=no
cat << END > $NGX_AUTOTEST.c
$ngx_lib_incs
int main() {
$ngx_lib_test;
return 0;
}
eval "$CC $cc_test_flags $ngx_lib_cflags \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $ngx_libs \
>> $NGX_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
echo " found"
ngx_found=yes
else
echo " not found"
fi
rm $NGX_AUTOTEST*

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
if [ $ZLIB != NONE ]; then
@ -7,12 +8,14 @@ if [ $ZLIB != NONE ]; then
case "$NGX_CC_NAME" in
msvc* | owc* | bcc)
msvc | owc | bcc)
have=NGX_ZLIB . auto/have
LINK_DEPS="$LINK_DEPS $ZLIB/zlib.lib"
CORE_LIBS="$CORE_LIBS $ZLIB/zlib.lib"
;;
icc*)
icc)
have=NGX_ZLIB . auto/have
LINK_DEPS="$LINK_DEPS $ZLIB/libz.a"
# to allow -ipo optimization we link with the *.o but not library
@ -29,6 +32,7 @@ if [ $ZLIB != NONE ]; then
;;
*)
have=NGX_ZLIB . auto/have
LINK_DEPS="$LINK_DEPS $ZLIB/libz.a"
CORE_LIBS="$CORE_LIBS $ZLIB/libz.a"
#CORE_LIBS="$CORE_LIBS -L $ZLIB -lz"
@ -44,7 +48,7 @@ else
# FreeBSD, Solaris, Linux
ngx_feature="zlib library"
ngx_feature_name=
ngx_feature_name="NGX_ZLIB"
ngx_feature_run=no
ngx_feature_incs="#include <zlib.h>"
ngx_feature_path=
@ -60,4 +64,16 @@ else
fi
fi
if [ $ZLIB != YES ]; then
cat << END
$0: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
END
exit 1
fi
fi

View File

@ -1,23 +1,31 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
case "$NGX_CC_NAME" in
msvc*)
msvc)
ngx_makefile=makefile.msvc
ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC"
ngx_zlib="ZLIB=\"$ZLIB\""
;;
owc*)
owc)
ngx_makefile=makefile.owc
ngx_opt="CPU_OPT=\"$CPU_OPT\""
ngx_zlib=`echo ZLIB=\"$ZLIB\" | sed -e "s/\//$ngx_regex_dirsep/g"`
;;
bcc)
ngx_makefile=makefile.bcc
ngx_opt="-DCPU_OPT=\"$CPU_OPT\""
ngx_zlib=`echo \-DZLIB=\"$ZLIB\" | sed -e "s/\//$ngx_regex_dirsep/g"`
;;
*)
ngx_makefile=
;;
esac
@ -29,17 +37,30 @@ done=NO
case "$NGX_PLATFORM" in
win32)
cp auto/lib/zlib/$ngx_makefile $ZLIB
cat << END >> $NGX_MAKEFILE
if [ -n "$ngx_makefile" ]; then
cat << END >> $NGX_MAKEFILE
`echo "$ZLIB/zlib.lib: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"`
cd `echo $ZLIB | sed -e "s/\//$ngx_regex_dirsep/g"`
\$(MAKE) -f $ngx_makefile $ngx_opt
cd ..\\..\\..
\$(MAKE) -f auto/lib/zlib/$ngx_makefile $ngx_opt $ngx_zlib
END
else
cat << END >> $NGX_MAKEFILE
$ZLIB/libz.a: $NGX_MAKEFILE
cd $ZLIB \\
&& \$(MAKE) distclean \\
&& \$(MAKE) -f win32/Makefile.gcc \\
CFLAGS="$ZLIB_OPT" CC="\$(CC)" \\
libz.a
END
fi
done=YES
;;
@ -54,7 +75,7 @@ END
$ZLIB/libz.a: $NGX_MAKEFILE
cd $ZLIB \\
&& \$(MAKE) clean \\
&& \$(MAKE) distclean \\
&& cp contrib/asm586/match.S . \\
&& CFLAGS="$ZLIB_OPT -DASMV" CC="\$(CC)" \\
./configure \\
@ -71,7 +92,7 @@ END
$ZLIB/libz.a: $NGX_MAKEFILE
cd $ZLIB \\
&& \$(MAKE) clean \\
&& \$(MAKE) distclean \\
&& cp contrib/asm686/match.S . \\
&& CFLAGS="$ZLIB_OPT -DASMV" CC="\$(CC)" \\
./configure \\
@ -104,7 +125,7 @@ if [ $done = NO ]; then
$ZLIB/libz.a: $NGX_MAKEFILE
cd $ZLIB \\
&& \$(MAKE) clean \\
&& \$(MAKE) distclean \\
&& CFLAGS="$ZLIB_OPT" CC="\$(CC)" \\
./configure \\
&& \$(MAKE) libz.a

View File

@ -1,12 +1,17 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
CFLAGS = -q -O2 -tWM -w-8004 -w-8012 $(CPU_OPT)
zlib.lib:
bcc32 -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c \
compress.c
cd $(ZLIB)
bcc32 -c $(CFLAGS) adler32.c crc32.c deflate.c \
trees.c zutil.c compress.c \
inflate.c inffast.c inftrees.c
tlib zlib.lib +adler32.obj +crc32.obj +deflate.obj \
+trees.obj +zutil.obj +compress.obj
+trees.obj +zutil.obj +compress.obj \
+inflate.obj +inffast.obj +inftrees.obj

View File

@ -1,11 +1,17 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT)
zlib.lib:
cl -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c compress.c
cd $(ZLIB)
cl -c $(CFLAGS) adler32.c crc32.c deflate.c \
trees.c zutil.c compress.c \
inflate.c inffast.c inftrees.c
link -lib -out:zlib.lib adler32.obj crc32.obj deflate.obj \
trees.obj zutil.obj compress.obj
trees.obj zutil.obj compress.obj \
inflate.obj inffast.obj inftrees.obj

View File

@ -1,9 +1,14 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
CFLAGS = -zq -bt=nt -ot -op -oi -oe -s -bm $(CPU_OPT)
zlib.lib:
wcl386 -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c compress.c
wlib -n zlib.lib adler32.obj crc32.obj deflate.obj trees.obj zutil.obj compress.obj
cd $(ZLIB)
wcl386 -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c &
compress.c inflate.c inffast.c inftrees.c
wlib -n zlib.lib adler32.obj crc32.obj deflate.obj trees.obj &
zutil.obj compress.obj inflate.obj inffast.obj inftrees.obj

View File

@ -1,10 +0,0 @@
--- zlib.h Thu Jul 9 20:06:56 1998
+++ zlib-1.1.3/zlib.h Tue Mar 22 13:41:04 2005
@@ -709,7 +709,6 @@
(0 in case of error).
*/
-ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
/*
Converts, formats, and writes the args to the compressed file under
control of the format string, as in fprintf. gzprintf returns the number of

340
auto/make
View File

@ -1,12 +1,18 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
echo "creating $NGX_MAKEFILE"
mkdir -p $NGX_OBJS/src/core $NGX_OBJS/src/event $NGX_OBJS/src/event/modules \
$NGX_OBJS/src/event/quic \
$NGX_OBJS/src/os/unix $NGX_OBJS/src/os/win32 \
$NGX_OBJS/src/http $NGX_OBJS/src/http/modules \
$NGX_OBJS/src/http/modules/perl \
$NGX_OBJS/src/mail
$NGX_OBJS/src/http $NGX_OBJS/src/http/v2 $NGX_OBJS/src/http/v3 \
$NGX_OBJS/src/http/modules $NGX_OBJS/src/http/modules/perl \
$NGX_OBJS/src/mail \
$NGX_OBJS/src/stream \
$NGX_OBJS/src/misc
ngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep
@ -22,26 +28,17 @@ LINK = $LINK
END
if test -n "$NGX_PERL_CFLAGS"; then
echo NGX_PERL_CFLAGS = $NGX_PERL_CFLAGS >> $NGX_MAKEFILE
echo NGX_PM_CFLAGS = $NGX_PM_CFLAGS >> $NGX_MAKEFILE
fi
if [ "$BMAKE" = wmake ]; then
echo MAKE = wmake >> $NGX_MAKEFILE
ngx_regex_cont=' '
ngx_long_regex_cont=' '
ngx_cont=' '
ngx_long_cont=' '
ngx_tab=' '
echo NGX_PM_LDFLAGS = $NGX_PM_LDFLAGS >> $NGX_MAKEFILE
fi
# ALL_INCS, required by the addons and by OpenWatcom C precompiled headers
ngx_incs=`echo $CORE_INCS $NGX_OBJS $HTTP_INCS $MAIL_INCS\
ngx_incs=`echo $CORE_INCS $NGX_OBJS $HTTP_INCS $MAIL_INCS $STREAM_INCS\
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`
@ -55,7 +52,7 @@ END
ngx_all_srcs="$CORE_SRCS"
# the core dependences and include pathes
# the core dependencies and include paths
ngx_deps=`echo $CORE_DEPS $NGX_AUTO_CONFIG_H $NGX_PCH \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
@ -75,7 +72,7 @@ CORE_INCS = $ngx_include_opt$ngx_incs
END
# the http dependences and include pathes
# the http dependencies and include paths
if [ $HTTP = YES ]; then
@ -101,11 +98,13 @@ END
fi
# the mail dependences and include pathes
# the mail dependencies and include paths
if [ $MAIL = YES ]; then
if [ $MAIL != NO ]; then
ngx_all_srcs="$ngx_all_srcs $MAIL_SRCS"
if [ $MAIL = YES ]; then
ngx_all_srcs="$ngx_all_srcs $MAIL_SRCS"
fi
ngx_deps=`echo $MAIL_DEPS \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
@ -127,7 +126,38 @@ END
fi
if test -n "$NGX_ADDON_SRCS"; then
# the stream dependencies and include paths
if [ $STREAM != NO ]; then
if [ $STREAM = YES ]; then
ngx_all_srcs="$ngx_all_srcs $STREAM_SRCS"
fi
ngx_deps=`echo $STREAM_DEPS \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`
ngx_incs=`echo $STREAM_INCS \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`
cat << END >> $NGX_MAKEFILE
STREAM_DEPS = $ngx_deps
STREAM_INCS = $ngx_include_opt$ngx_incs
END
fi
ngx_all_srcs="$ngx_all_srcs $MISC_SRCS"
if test -n "$NGX_ADDON_SRCS$DYNAMIC_MODULES"; then
cat << END >> $NGX_MAKEFILE
@ -180,6 +210,7 @@ ngx_objs=`echo $ngx_all_objs $ngx_modules_obj \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_long_regex_cont\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`
ngx_libs=
if test -n "$NGX_LD_OPT$CORE_LIBS"; then
ngx_libs=`echo $NGX_LD_OPT $CORE_LIBS \
| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`
@ -188,13 +219,22 @@ fi
ngx_link=${CORE_LINK:+`echo $CORE_LINK \
| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}
ngx_main_link=${MAIN_LINK:+`echo $MAIN_LINK \
| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}
cat << END >> $NGX_MAKEFILE
$NGX_OBJS${ngx_dirsep}nginx${ngx_binext}: $ngx_deps$ngx_spacer
\$(LINK) ${ngx_long_start}${ngx_binout}$NGX_OBJS${ngx_dirsep}nginx$ngx_long_cont$ngx_objs$ngx_libs$ngx_link
build: binary modules manpage
binary: $NGX_OBJS${ngx_dirsep}nginx$ngx_binext
$NGX_OBJS${ngx_dirsep}nginx$ngx_binext: $ngx_deps$ngx_spacer
\$(LINK) $ngx_long_start$ngx_binout$NGX_OBJS${ngx_dirsep}nginx$ngx_binext$ngx_long_cont$ngx_objs$ngx_libs$ngx_link$ngx_main_link
$ngx_rcc
${ngx_long_end}
$ngx_long_end
modules:
END
@ -243,7 +283,7 @@ if [ $HTTP = YES ]; then
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(HTTP_INCS)"
ngx_perl_cc="\$(CC) $ngx_compile_opt \$(NGX_PERL_CFLAGS) "
ngx_perl_cc="\$(CC) $ngx_compile_opt \$(NGX_PERL_CFLAGS)"
ngx_perl_cc="$ngx_perl_cc \$(CORE_INCS) \$(HTTP_INCS)"
fi
@ -274,7 +314,7 @@ $ngx_obj: \$(CORE_DEPS) \$(HTTP_DEPS)$ngx_cont$ngx_src
END
fi
done
done
fi
@ -304,7 +344,63 @@ $ngx_obj: \$(CORE_DEPS) \$(MAIL_DEPS)$ngx_cont$ngx_src
$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
END
done
done
fi
# the stream sources
if [ $STREAM = YES ]; then
if test -n "$NGX_PCH"; then
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(STREAM_INCS)"
fi
for ngx_src in $STREAM_SRCS
do
ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
ngx_obj=`echo $ngx_src \
| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
cat << END >> $NGX_MAKEFILE
$ngx_obj: \$(CORE_DEPS) \$(STREAM_DEPS)$ngx_cont$ngx_src
$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
END
done
fi
# the misc sources
if test -n "$MISC_SRCS"; then
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
for ngx_src in $MISC_SRCS
do
ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
ngx_obj=`echo $ngx_src \
| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
cat << END >> $NGX_MAKEFILE
$ngx_obj: \$(CORE_DEPS) $ngx_cont$ngx_src
$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
END
done
fi
@ -336,16 +432,16 @@ $ngx_obj: \$(ADDON_DEPS)$ngx_cont$ngx_src
$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
END
done
done
fi
# the addons config.make
if test -n "$NGX_ADDONS"; then
if test -n "$NGX_ADDONS$DYNAMIC_ADDONS"; then
for ngx_addon_dir in $NGX_ADDONS
for ngx_addon_dir in $NGX_ADDONS $DYNAMIC_ADDONS
do
if test -f $ngx_addon_dir/config.make; then
. $ngx_addon_dir/config.make
@ -392,3 +488,187 @@ $ngx_pch
END
fi
# dynamic modules
if test -n "$NGX_PCH"; then
ngx_cc="\$(CC) $ngx_compile_opt $ngx_pic_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
ngx_cc="\$(CC) $ngx_compile_opt $ngx_pic_opt \$(CFLAGS) \$(ALL_INCS)"
ngx_perl_cc="\$(CC) $ngx_compile_opt $ngx_pic_opt \$(NGX_PERL_CFLAGS)"
ngx_perl_cc="$ngx_perl_cc \$(ALL_INCS)"
fi
for ngx_module in $DYNAMIC_MODULES
do
eval ngx_module_srcs="\$${ngx_module}_SRCS"
eval ngx_module_shrd="\$${ngx_module}_SHRD"
eval eval ngx_module_libs="\\\"\$${ngx_module}_LIBS\\\""
eval ngx_module_modules="\$${ngx_module}_MODULES"
eval ngx_module_order="\$${ngx_module}_ORDER"
ngx_modules_c=$NGX_OBJS/${ngx_module}_modules.c
cat << END > $ngx_modules_c
#include <ngx_config.h>
#include <ngx_core.h>
END
for mod in $ngx_module_modules
do
echo "extern ngx_module_t $mod;" >> $ngx_modules_c
done
echo >> $ngx_modules_c
echo 'ngx_module_t *ngx_modules[] = {' >> $ngx_modules_c
for mod in $ngx_module_modules
do
echo " &$mod," >> $ngx_modules_c
done
cat << END >> $ngx_modules_c
NULL
};
END
echo 'char *ngx_module_names[] = {' >> $ngx_modules_c
for mod in $ngx_module_modules
do
echo " \"$mod\"," >> $ngx_modules_c
done
cat << END >> $ngx_modules_c
NULL
};
END
echo 'char *ngx_module_order[] = {' >> $ngx_modules_c
for mod in $ngx_module_order
do
echo " \"$mod\"," >> $ngx_modules_c
done
cat << END >> $ngx_modules_c
NULL
};
END
ngx_modules_c=`echo $ngx_modules_c | sed -e "s/\//$ngx_regex_dirsep/g"`
ngx_modules_obj=`echo $ngx_modules_c \
| sed -e "s/\(.*\.\)c/\1$ngx_objext/"`
ngx_module_objs=
for ngx_src in $ngx_module_srcs $ngx_module_shrd
do
case "$ngx_src" in
src/*)
ngx_obj=$ngx_src
;;
*)
ngx_obj="addon/`basename \`dirname $ngx_src\``"
mkdir -p $NGX_OBJS/$ngx_obj
ngx_obj="$ngx_obj/`basename $ngx_src`"
;;
esac
ngx_module_objs="$ngx_module_objs $ngx_obj"
done
ngx_module_objs=`echo $ngx_module_objs \
| sed -e "s#\([^ ]*\.\)cpp#$NGX_OBJS\/\1$ngx_objext#g" \
-e "s#\([^ ]*\.\)cc#$NGX_OBJS\/\1$ngx_objext#g" \
-e "s#\([^ ]*\.\)c#$NGX_OBJS\/\1$ngx_objext#g" \
-e "s#\([^ ]*\.\)S#$NGX_OBJS\/\1$ngx_objext#g"`
ngx_deps=`echo $ngx_module_objs $ngx_modules_obj $LINK_DEPS \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`
ngx_objs=`echo $ngx_module_objs $ngx_modules_obj \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_long_regex_cont\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`
ngx_obj=$NGX_OBJS$ngx_dirsep$ngx_module$ngx_modext
if [ "$NGX_PLATFORM" = win32 ]; then
ngx_module_libs="$CORE_LIBS $ngx_module_libs"
fi
ngx_libs=
if test -n "$NGX_LD_OPT$ngx_module_libs"; then
ngx_libs=`echo $NGX_LD_OPT $ngx_module_libs \
| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`
fi
ngx_link=${CORE_LINK:+`echo $CORE_LINK \
| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}
ngx_module_link=${MODULE_LINK:+`echo $MODULE_LINK \
| sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_long_regex_cont/"`}
cat << END >> $NGX_MAKEFILE
modules: $ngx_obj
$ngx_obj: $ngx_deps$ngx_spacer
\$(LINK) $ngx_long_start$ngx_binout$ngx_obj$ngx_long_cont$ngx_objs$ngx_libs$ngx_link$ngx_module_link
$ngx_long_end
$ngx_modules_obj: \$(CORE_DEPS)$ngx_cont$ngx_modules_c
$ngx_cc$ngx_tab$ngx_objout$ngx_modules_obj$ngx_tab$ngx_modules_c$NGX_AUX
END
for ngx_source in $ngx_module_srcs
do
case "$ngx_source" in
src/*)
ngx_obj=`echo $ngx_source | sed -e "s/\//$ngx_regex_dirsep/g"`
;;
*)
ngx_obj="addon/`basename \`dirname $ngx_source\``"
ngx_obj=`echo $ngx_obj/\`basename $ngx_source\` \
| sed -e "s/\//$ngx_regex_dirsep/g"`
;;
esac
ngx_obj=`echo $ngx_obj \
| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
ngx_src=`echo $ngx_source | sed -e "s/\//$ngx_regex_dirsep/g"`
if [ $ngx_source = src/http/modules/perl/ngx_http_perl_module.c ]; then
cat << END >> $NGX_MAKEFILE
$ngx_obj: \$(ADDON_DEPS)$ngx_cont$ngx_src
$ngx_perl_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
END
else
cat << END >> $NGX_MAKEFILE
$ngx_obj: \$(ADDON_DEPS)$ngx_cont$ngx_src
$ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
END
fi
done
done

178
auto/module Normal file
View File

@ -0,0 +1,178 @@
# Copyright (C) Ruslan Ermilov
# Copyright (C) Nginx, Inc.
case $ngx_module_type in
HTTP_*) ngx_var=HTTP ;;
*) ngx_var=$ngx_module_type ;;
esac
if [ "$ngx_module_link" = DYNAMIC ]; then
for ngx_module in $ngx_module_name; do
# extract the first name
break
done
DYNAMIC_MODULES="$DYNAMIC_MODULES $ngx_module"
eval ${ngx_module}_MODULES=\"$ngx_module_name\"
if [ -z "$ngx_module_order" -a \
\( "$ngx_module_type" = "HTTP_FILTER" \
-o "$ngx_module_type" = "HTTP_AUX_FILTER" \) ]
then
eval ${ngx_module}_ORDER=\"$ngx_module_name \
ngx_http_copy_filter_module\"
else
eval ${ngx_module}_ORDER=\"$ngx_module_order\"
fi
srcs=
shrd=
for src in $ngx_module_srcs
do
found=no
for old in $DYNAMIC_MODULES_SRCS
do
if [ $src = $old ]; then
found=yes
break
fi
done
if [ $found = no ]; then
srcs="$srcs $src"
else
shrd="$shrd $src"
fi
done
eval ${ngx_module}_SRCS=\"$srcs\"
eval ${ngx_module}_SHRD=\"$shrd\"
DYNAMIC_MODULES_SRCS="$DYNAMIC_MODULES_SRCS $srcs"
if test -n "$ngx_module_incs"; then
CORE_INCS="$CORE_INCS $ngx_module_incs"
fi
if test -n "$ngx_module_deps"; then
NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_module_deps"
fi
libs=
for lib in $ngx_module_libs
do
case $lib in
LIBXSLT | LIBGD | GEOIP | PERL)
libs="$libs \$NGX_LIB_$lib"
if eval [ "\$USE_${lib}" = NO ] ; then
eval USE_${lib}=DYNAMIC
fi
;;
PCRE | OPENSSL | ZLIB)
eval USE_${lib}=YES
;;
MD5 | SHA1)
# obsolete
;;
*)
libs="$libs $lib"
;;
esac
done
eval ${ngx_module}_LIBS=\'$libs\'
elif [ "$ngx_module_link" = YES ]; then
eval ${ngx_module_type}_MODULES=\"\$${ngx_module_type}_MODULES \
$ngx_module_name\"
eval ${ngx_var}_SRCS=\"\$${ngx_var}_SRCS $ngx_module_srcs\"
if test -n "$ngx_module_incs"; then
eval ${ngx_var}_INCS=\"\$${ngx_var}_INCS $ngx_module_incs\"
fi
if test -n "$ngx_module_deps"; then
eval ${ngx_var}_DEPS=\"\$${ngx_var}_DEPS $ngx_module_deps\"
fi
for lib in $ngx_module_libs
do
case $lib in
PCRE | OPENSSL | ZLIB | LIBXSLT | LIBGD | PERL | GEOIP)
eval USE_${lib}=YES
;;
MD5 | SHA1)
# obsolete
;;
*)
CORE_LIBS="$CORE_LIBS $lib"
;;
esac
done
elif [ "$ngx_module_link" = ADDON ]; then
eval ${ngx_module_type}_MODULES=\"\$${ngx_module_type}_MODULES \
$ngx_module_name\"
srcs=
for src in $ngx_module_srcs
do
found=no
for old in $NGX_ADDON_SRCS
do
if [ $src = $old ]; then
found=yes
break
fi
done
if [ $found = no ]; then
srcs="$srcs $src"
fi
done
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $srcs"
if test -n "$ngx_module_incs"; then
eval ${ngx_var}_INCS=\"\$${ngx_var}_INCS $ngx_module_incs\"
fi
if test -n "$ngx_module_deps"; then
NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_module_deps"
fi
for lib in $ngx_module_libs
do
case $lib in
PCRE | OPENSSL | ZLIB | LIBXSLT | LIBGD | PERL | GEOIP)
eval USE_${lib}=YES
;;
MD5 | SHA1)
# obsolete
;;
*)
CORE_LIBS="$CORE_LIBS $lib"
;;
esac
done
fi

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
cat << END >> $NGX_AUTO_CONFIG_H

View File

@ -1,19 +1,23 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
help=no
NGX_PREFIX=
NGX_SBIN_PATH=
NGX_MODULES_PATH=
NGX_CONF_PREFIX=
NGX_CONF_PATH=
NGX_ERROR_LOG_PATH=
NGX_PID_PATH=
NGX_LOCK_PATH=
NGX_USER=
NGX_GROUP=
NGX_BUILD=
CC=${CC:-gcc}
CC=${CC:-cc}
CPP=
NGX_OBJS=objs
@ -22,10 +26,11 @@ NGX_CC_OPT=
NGX_LD_OPT=
CPU=NO
NGX_RPATH=NO
NGX_TEST_BUILD_DEVPOLL=NO
NGX_TEST_BUILD_EVENTPORT=NO
NGX_TEST_BUILD_EPOLL=NO
NGX_TEST_BUILD_RTSIG=NO
NGX_TEST_BUILD_SOLARIS_SENDFILEV=NO
NGX_PLATFORM=
@ -33,73 +38,124 @@ NGX_WINE=
EVENT_FOUND=NO
EVENT_RTSIG=NO
EVENT_SELECT=NO
EVENT_POLL=NO
EVENT_AIO=NO
USE_THREADS=NO
NGX_FILE_AIO=NO
QUIC_BPF=NO
HTTP=YES
NGX_HTTP_LOG_PATH=
NGX_HTTP_CLIENT_TEMP_PATH=
NGX_HTTP_PROXY_TEMP_PATH=
NGX_HTTP_FASTCGI_TEMP_PATH=
NGX_HTTP_UWSGI_TEMP_PATH=
NGX_HTTP_SCGI_TEMP_PATH=
HTTP_CACHE=YES
HTTP_CHARSET=YES
HTTP_GZIP=YES
HTTP_SSL=NO
HTTP_V2=NO
HTTP_V3=NO
HTTP_SSI=YES
HTTP_POSTPONE=NO
HTTP_REALIP=NO
HTTP_XSLT=NO
HTTP_IMAGE_FILTER=NO
HTTP_SUB=NO
HTTP_ADDITION=NO
HTTP_DAV=NO
HTTP_ACCESS=YES
HTTP_AUTH_BASIC=YES
HTTP_AUTH_REQUEST=NO
HTTP_MIRROR=YES
HTTP_USERID=YES
HTTP_SLICE=NO
HTTP_AUTOINDEX=YES
HTTP_RANDOM_INDEX=NO
HTTP_STATUS=NO
HTTP_GEO=YES
HTTP_GEOIP=NO
HTTP_MAP=YES
HTTP_SPLIT_CLIENTS=YES
HTTP_REFERER=YES
HTTP_REWRITE=YES
HTTP_PROXY=YES
HTTP_FASTCGI=YES
HTTP_UWSGI=YES
HTTP_SCGI=YES
HTTP_GRPC=YES
HTTP_PERL=NO
HTTP_MEMCACHED=YES
HTTP_LIMIT_ZONE=YES
HTTP_LIMIT_CONN=YES
HTTP_LIMIT_REQ=YES
HTTP_EMPTY_GIF=YES
HTTP_BROWSER=YES
HTTP_SECURE_LINK=NO
HTTP_DEGRADATION=NO
HTTP_FLV=NO
HTTP_MP4=NO
HTTP_GUNZIP=NO
HTTP_GZIP_STATIC=NO
HTTP_UPSTREAM_HASH=YES
HTTP_UPSTREAM_IP_HASH=YES
HTTP_UPSTREAM_LEAST_CONN=YES
HTTP_UPSTREAM_RANDOM=YES
HTTP_UPSTREAM_KEEPALIVE=YES
HTTP_UPSTREAM_ZONE=YES
# STUB
HTTP_STUB_STATUS=NO
MAIL=NO
MAIL_SSL=NO
MAIL_POP3=YES
MAIL_IMAP=YES
MAIL_SMTP=YES
STREAM=NO
STREAM_SSL=NO
STREAM_QUIC=NO
STREAM_REALIP=NO
STREAM_LIMIT_CONN=YES
STREAM_ACCESS=YES
STREAM_GEO=YES
STREAM_GEOIP=NO
STREAM_MAP=YES
STREAM_SPLIT_CLIENTS=YES
STREAM_RETURN=YES
STREAM_SET=YES
STREAM_UPSTREAM_HASH=YES
STREAM_UPSTREAM_LEAST_CONN=YES
STREAM_UPSTREAM_RANDOM=YES
STREAM_UPSTREAM_ZONE=YES
STREAM_SSL_PREREAD=NO
DYNAMIC_MODULES=
DYNAMIC_MODULES_SRCS=
NGX_ADDONS=
NGX_ADDON_SRCS=
NGX_ADDON_DEPS=
DYNAMIC_ADDONS=
NGX_COMPAT=NO
USE_PCRE=NO
PCRE=NONE
PCRE_OPT=
PCRE_CONF_OPT=
PCRE_JIT=NO
PCRE2=YES
USE_OPENSSL=NO
USE_OPENSSL_QUIC=NO
OPENSSL=NONE
USE_MD5=NO
MD5=NONE
MD5_OPT=
MD5_ASM=NO
USE_SHA1=NO
SHA1=NONE
SHA1_OPT=
SHA1_ASM=NO
USE_ZLIB=NO
ZLIB=NONE
ZLIB_OPT=
@ -108,11 +164,27 @@ ZLIB_ASM=NO
USE_PERL=NO
NGX_PERL=perl
USE_LIBXSLT=NO
USE_LIBGD=NO
USE_GEOIP=NO
NGX_GOOGLE_PERFTOOLS=NO
NGX_CPP_TEST=NO
SO_COOKIE_FOUND=NO
NGX_LIBATOMIC=NO
NGX_CPU_CACHE_LINE=
NGX_POST_CONF_MSG=
opt=
for option
do
opt="$opt `echo $option | sed -e \"s/\(--[^=]*=\)\(.* .*\)/\1'\2'/\"`"
case "$option" in
-*=*) value=`echo "$option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
*) value="" ;;
@ -121,8 +193,10 @@ do
case "$option" in
--help) help=yes ;;
--prefix=) NGX_PREFIX="!" ;;
--prefix=*) NGX_PREFIX="$value" ;;
--sbin-path=*) NGX_SBIN_PATH="$value" ;;
--modules-path=*) NGX_MODULES_PATH="$value" ;;
--conf-path=*) NGX_CONF_PATH="$value" ;;
--error-log-path=*) NGX_ERROR_LOG_PATH="$value";;
--pid-path=*) NGX_PID_PATH="$value" ;;
@ -132,30 +206,59 @@ do
--crossbuild=*) NGX_PLATFORM="$value" ;;
--build=*) NGX_BUILD="$value" ;;
--builddir=*) NGX_OBJS="$value" ;;
--with-rtsig_module) EVENT_RTSIG=YES ;;
--with-select_module) EVENT_SELECT=YES ;;
--without-select_module) EVENT_SELECT=NONE ;;
--with-poll_module) EVENT_POLL=YES ;;
--without-poll_module) EVENT_POLL=NONE ;;
--with-aio_module) EVENT_AIO=YES ;;
--with-threads=*) USE_THREADS="$value" ;;
--with-threads) USE_THREADS="pthreads" ;;
--with-threads) USE_THREADS=YES ;;
--with-file-aio) NGX_FILE_AIO=YES ;;
--without-quic_bpf_module) QUIC_BPF=NONE ;;
--with-ipv6)
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
$0: warning: the \"--with-ipv6\" option is deprecated"
;;
--without-http) HTTP=NO ;;
--without-http-cache) HTTP_CACHE=NO ;;
--http-log-path=*) NGX_HTTP_LOG_PATH="$value" ;;
--http-client-body-temp-path=*) NGX_HTTP_CLIENT_TEMP_PATH="$value" ;;
--http-proxy-temp-path=*) NGX_HTTP_PROXY_TEMP_PATH="$value" ;;
--http-fastcgi-temp-path=*) NGX_HTTP_FASTCGI_TEMP_PATH="$value" ;;
--http-uwsgi-temp-path=*) NGX_HTTP_UWSGI_TEMP_PATH="$value" ;;
--http-scgi-temp-path=*) NGX_HTTP_SCGI_TEMP_PATH="$value" ;;
--with-http_ssl_module) HTTP_SSL=YES ;;
--with-http_v2_module) HTTP_V2=YES ;;
--with-http_v3_module) HTTP_V3=YES ;;
--with-http_realip_module) HTTP_REALIP=YES ;;
--with-http_addition_module) HTTP_ADDITION=YES ;;
--with-http_xslt_module) HTTP_XSLT=YES ;;
--with-http_xslt_module=dynamic) HTTP_XSLT=DYNAMIC ;;
--with-http_image_filter_module) HTTP_IMAGE_FILTER=YES ;;
--with-http_image_filter_module=dynamic)
HTTP_IMAGE_FILTER=DYNAMIC ;;
--with-http_geoip_module) HTTP_GEOIP=YES ;;
--with-http_geoip_module=dynamic)
HTTP_GEOIP=DYNAMIC ;;
--with-http_sub_module) HTTP_SUB=YES ;;
--with-http_dav_module) HTTP_DAV=YES ;;
--with-http_flv_module) HTTP_FLV=YES ;;
--with-http_mp4_module) HTTP_MP4=YES ;;
--with-http_gunzip_module) HTTP_GUNZIP=YES ;;
--with-http_gzip_static_module) HTTP_GZIP_STATIC=YES ;;
--with-http_auth_request_module) HTTP_AUTH_REQUEST=YES ;;
--with-http_random_index_module) HTTP_RANDOM_INDEX=YES ;;
--with-http_secure_link_module) HTTP_SECURE_LINK=YES ;;
--with-http_degradation_module) HTTP_DEGRADATION=YES ;;
--with-http_slice_module) HTTP_SLICE=YES ;;
--without-http_charset_module) HTTP_CHARSET=NO ;;
--without-http_gzip_module) HTTP_GZIP=NO ;;
@ -163,21 +266,35 @@ do
--without-http_userid_module) HTTP_USERID=NO ;;
--without-http_access_module) HTTP_ACCESS=NO ;;
--without-http_auth_basic_module) HTTP_AUTH_BASIC=NO ;;
--without-http_mirror_module) HTTP_MIRROR=NO ;;
--without-http_autoindex_module) HTTP_AUTOINDEX=NO ;;
--without-http_status_module) HTTP_STATUS=NO ;;
--without-http_geo_module) HTTP_GEO=NO ;;
--without-http_map_module) HTTP_MAP=NO ;;
--without-http_split_clients_module) HTTP_SPLIT_CLIENTS=NO ;;
--without-http_referer_module) HTTP_REFERER=NO ;;
--without-http_rewrite_module) HTTP_REWRITE=NO ;;
--without-http_proxy_module) HTTP_PROXY=NO ;;
--without-http_fastcgi_module) HTTP_FASTCGI=NO ;;
--without-http_uwsgi_module) HTTP_UWSGI=NO ;;
--without-http_scgi_module) HTTP_SCGI=NO ;;
--without-http_grpc_module) HTTP_GRPC=NO ;;
--without-http_memcached_module) HTTP_MEMCACHED=NO ;;
--without-http_limit_zone_module) HTTP_LIMIT_ZONE=NO ;;
--without-http_limit_conn_module) HTTP_LIMIT_CONN=NO ;;
--without-http_limit_req_module) HTTP_LIMIT_REQ=NO ;;
--without-http_empty_gif_module) HTTP_EMPTY_GIF=NO ;;
--without-http_browser_module) HTTP_BROWSER=NO ;;
--without-http_upstream_hash_module) HTTP_UPSTREAM_HASH=NO ;;
--without-http_upstream_ip_hash_module) HTTP_UPSTREAM_IP_HASH=NO ;;
--without-http_upstream_least_conn_module)
HTTP_UPSTREAM_LEAST_CONN=NO ;;
--without-http_upstream_random_module)
HTTP_UPSTREAM_RANDOM=NO ;;
--without-http_upstream_keepalive_module) HTTP_UPSTREAM_KEEPALIVE=NO ;;
--without-http_upstream_zone_module) HTTP_UPSTREAM_ZONE=NO ;;
--with-http_perl_module) HTTP_PERL=YES ;;
--with-http_perl_module=dynamic) HTTP_PERL=DYNAMIC ;;
--with-perl_modules_path=*) NGX_PERL_MODULES="$value" ;;
--with-perl=*) NGX_PERL="$value" ;;
@ -185,12 +302,60 @@ do
--with-http_stub_status_module) HTTP_STUB_STATUS=YES ;;
--with-mail) MAIL=YES ;;
--with-mail=dynamic) MAIL=DYNAMIC ;;
--with-mail_ssl_module) MAIL_SSL=YES ;;
# STUB
--with-imap) MAIL=YES ;;
--with-imap_ssl_module) MAIL_SSL=YES ;;
--with-imap)
MAIL=YES
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
$0: warning: the \"--with-imap\" option is deprecated, \
use the \"--with-mail\" option instead"
;;
--with-imap_ssl_module)
MAIL_SSL=YES
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
$0: warning: the \"--with-imap_ssl_module\" option is deprecated, \
use the \"--with-mail_ssl_module\" option instead"
;;
--without-mail_pop3_module) MAIL_POP3=NO ;;
--without-mail_imap_module) MAIL_IMAP=NO ;;
--without-mail_smtp_module) MAIL_SMTP=NO ;;
--with-stream) STREAM=YES ;;
--with-stream=dynamic) STREAM=DYNAMIC ;;
--with-stream_ssl_module) STREAM_SSL=YES ;;
--with-stream_quic_module) STREAM_QUIC=YES ;;
--with-stream_realip_module) STREAM_REALIP=YES ;;
--with-stream_geoip_module) STREAM_GEOIP=YES ;;
--with-stream_geoip_module=dynamic)
STREAM_GEOIP=DYNAMIC ;;
--with-stream_ssl_preread_module)
STREAM_SSL_PREREAD=YES ;;
--without-stream_limit_conn_module)
STREAM_LIMIT_CONN=NO ;;
--without-stream_access_module) STREAM_ACCESS=NO ;;
--without-stream_geo_module) STREAM_GEO=NO ;;
--without-stream_map_module) STREAM_MAP=NO ;;
--without-stream_split_clients_module)
STREAM_SPLIT_CLIENTS=NO ;;
--without-stream_return_module) STREAM_RETURN=NO ;;
--without-stream_set_module) STREAM_SET=NO ;;
--without-stream_upstream_hash_module)
STREAM_UPSTREAM_HASH=NO ;;
--without-stream_upstream_least_conn_module)
STREAM_UPSTREAM_LEAST_CONN=NO ;;
--without-stream_upstream_random_module)
STREAM_UPSTREAM_RANDOM=NO ;;
--without-stream_upstream_zone_module)
STREAM_UPSTREAM_ZONE=NO ;;
--with-google_perftools_module) NGX_GOOGLE_PERFTOOLS=YES ;;
--with-cpp_test_module) NGX_CPP_TEST=YES ;;
--add-module=*) NGX_ADDONS="$NGX_ADDONS $value" ;;
--add-dynamic-module=*) DYNAMIC_ADDONS="$DYNAMIC_ADDONS $value" ;;
--with-compat) NGX_COMPAT=YES ;;
--with-cc=*) CC="$value" ;;
--with-cpp=*) CPP="$value" ;;
@ -200,28 +365,51 @@ do
--with-debug) NGX_DEBUG=YES ;;
--without-pcre) USE_PCRE=DISABLED ;;
--with-pcre) USE_PCRE=YES ;;
--with-pcre=*) PCRE="$value" ;;
--with-pcre-opt=*) PCRE_OPT="$value" ;;
--with-pcre-jit) PCRE_JIT=YES ;;
--without-pcre2) PCRE2=DISABLED ;;
--with-openssl=*) OPENSSL="$value" ;;
--with-openssl-opt=*) OPENSSL_OPT="$value" ;;
--with-md5=*) MD5="$value" ;;
--with-md5-opt=*) MD5_OPT="$value" ;;
--with-md5-asm) MD5_ASM=YES ;;
--with-md5=*)
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
$0: warning: the \"--with-md5\" option is deprecated"
;;
--with-md5-opt=*)
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
$0: warning: the \"--with-md5-opt\" option is deprecated"
;;
--with-md5-asm)
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
$0: warning: the \"--with-md5-asm\" option is deprecated"
;;
--with-sha1=*) SHA1="$value" ;;
--with-sha1-opt=*) SHA1_OPT="$value" ;;
--with-sha1-asm) SHA1_ASM=YES ;;
--with-sha1=*)
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
$0: warning: the \"--with-sha1\" option is deprecated"
;;
--with-sha1-opt=*)
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
$0: warning: the \"--with-sha1-opt\" option is deprecated"
;;
--with-sha1-asm)
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
$0: warning: the \"--with-sha1-asm\" option is deprecated"
;;
--with-zlib=*) ZLIB="$value" ;;
--with-zlib-opt=*) ZLIB_OPT="$value" ;;
--with-zlib-asm=*) ZLIB_ASM="$value" ;;
--with-libatomic) NGX_LIBATOMIC=YES ;;
--with-libatomic=*) NGX_LIBATOMIC="$value" ;;
--test-build-devpoll) NGX_TEST_BUILD_DEVPOLL=YES ;;
--test-build-eventport) NGX_TEST_BUILD_EVENTPORT=YES ;;
--test-build-epoll) NGX_TEST_BUILD_EPOLL=YES ;;
--test-build-rtsig) NGX_TEST_BUILD_RTSIG=YES ;;
--test-build-solaris-sendfilev) NGX_TEST_BUILD_SOLARIS_SENDFILEV=YES ;;
*)
@ -232,38 +420,65 @@ do
done
NGX_CONFIGURE="$opt"
if [ $help = yes ]; then
cat << END
--help this message
--help print this message
--prefix=PATH set the installation prefix
--sbin-path=PATH set path to the nginx binary file
--conf-path=PATH set path to the nginx.conf file
--error-log-path=PATH set path to the error log
--pid-path=PATH set path to nginx.pid file
--lock-path=PATH set path to nginx.lock file
--prefix=PATH set installation prefix
--sbin-path=PATH set nginx binary pathname
--modules-path=PATH set modules path
--conf-path=PATH set nginx.conf pathname
--error-log-path=PATH set error log pathname
--pid-path=PATH set nginx.pid pathname
--lock-path=PATH set nginx.lock pathname
--user=USER set non-privilege user
for the worker processes
--group=GROUP set non-privilege group
for the worker processes
--user=USER set non-privileged user for
worker processes
--group=GROUP set non-privileged group for
worker processes
--builddir=DIR set the build directory
--build=NAME set build name
--builddir=DIR set build directory
--with-rtsig_module enable rtsig module
--with-select_module enable select module
--without-select_module disable select module
--with-poll_module enable poll module
--without-poll_module disable poll module
--with-threads enable thread pool support
--with-file-aio enable file AIO support
--without-quic_bpf_module disable ngx_quic_bpf_module
--with-http_ssl_module enable ngx_http_ssl_module
--with-http_v2_module enable ngx_http_v2_module
--with-http_v3_module enable ngx_http_v3_module
--with-http_realip_module enable ngx_http_realip_module
--with-http_addition_module enable ngx_http_addition_module
--with-http_xslt_module enable ngx_http_xslt_module
--with-http_xslt_module=dynamic enable dynamic ngx_http_xslt_module
--with-http_image_filter_module enable ngx_http_image_filter_module
--with-http_image_filter_module=dynamic
enable dynamic ngx_http_image_filter_module
--with-http_geoip_module enable ngx_http_geoip_module
--with-http_geoip_module=dynamic enable dynamic ngx_http_geoip_module
--with-http_sub_module enable ngx_http_sub_module
--with-http_dav_module enable ngx_http_dav_module
--with-http_flv_module enable ngx_http_flv_module
--with-http_mp4_module enable ngx_http_mp4_module
--with-http_gunzip_module enable ngx_http_gunzip_module
--with-http_gzip_static_module enable ngx_http_gzip_static_module
--with-http_auth_request_module enable ngx_http_auth_request_module
--with-http_random_index_module enable ngx_http_random_index_module
--with-http_secure_link_module enable ngx_http_secure_link_module
--with-http_degradation_module enable ngx_http_degradation_module
--with-http_slice_module enable ngx_http_slice_module
--with-http_stub_status_module enable ngx_http_stub_status_module
--without-http_charset_module disable ngx_http_charset_module
@ -272,68 +487,124 @@ cat << END
--without-http_userid_module disable ngx_http_userid_module
--without-http_access_module disable ngx_http_access_module
--without-http_auth_basic_module disable ngx_http_auth_basic_module
--without-http_mirror_module disable ngx_http_mirror_module
--without-http_autoindex_module disable ngx_http_autoindex_module
--without-http_geo_module disable ngx_http_geo_module
--without-http_map_module disable ngx_http_map_module
--without-http_split_clients_module disable ngx_http_split_clients_module
--without-http_referer_module disable ngx_http_referer_module
--without-http_rewrite_module disable ngx_http_rewrite_module
--without-http_proxy_module disable ngx_http_proxy_module
--without-http_fastcgi_module disable ngx_http_fastcgi_module
--without-http_uwsgi_module disable ngx_http_uwsgi_module
--without-http_scgi_module disable ngx_http_scgi_module
--without-http_grpc_module disable ngx_http_grpc_module
--without-http_memcached_module disable ngx_http_memcached_module
--without-http_limit_zone_module disable ngx_http_limit_zone_module
--without-http_limit_conn_module disable ngx_http_limit_conn_module
--without-http_limit_req_module disable ngx_http_limit_req_module
--without-http_empty_gif_module disable ngx_http_empty_gif_module
--without-http_browser_module disable ngx_http_browser_module
--without-http_upstream_hash_module
disable ngx_http_upstream_hash_module
--without-http_upstream_ip_hash_module
disable ngx_http_upstream_ip_hash_module
--without-http_upstream_least_conn_module
disable ngx_http_upstream_least_conn_module
--without-http_upstream_random_module
disable ngx_http_upstream_random_module
--without-http_upstream_keepalive_module
disable ngx_http_upstream_keepalive_module
--without-http_upstream_zone_module
disable ngx_http_upstream_zone_module
--with-http_perl_module enable ngx_http_perl_module
--with-perl_modules_path=PATH set path to the perl modules
--with-perl=PATH set path to the perl binary
--with-http_perl_module=dynamic enable dynamic ngx_http_perl_module
--with-perl_modules_path=PATH set Perl modules path
--with-perl=PATH set perl binary pathname
--http-log-path=PATH set path to the http access log
--http-client-body-temp-path=PATH set path to the http client request body
temporary files
--http-proxy-temp-path=PATH set path to the http proxy temporary files
--http-fastcgi-temp-path=PATH set path to the http fastcgi temporary
files
--http-log-path=PATH set http access log pathname
--http-client-body-temp-path=PATH set path to store
http client request body temporary files
--http-proxy-temp-path=PATH set path to store
http proxy temporary files
--http-fastcgi-temp-path=PATH set path to store
http fastcgi temporary files
--http-uwsgi-temp-path=PATH set path to store
http uwsgi temporary files
--http-scgi-temp-path=PATH set path to store
http scgi temporary files
--without-http disable HTTP server
--without-http-cache disable HTTP cache
--with-mail enable IMAP4/POP3/SMTP proxy module
--with-mail enable POP3/IMAP4/SMTP proxy module
--with-mail=dynamic enable dynamic POP3/IMAP4/SMTP proxy module
--with-mail_ssl_module enable ngx_mail_ssl_module
--without-mail_pop3_module disable ngx_mail_pop3_module
--without-mail_imap_module disable ngx_mail_imap_module
--without-mail_smtp_module disable ngx_mail_smtp_module
--add-module=PATH enable an external module
--with-stream enable TCP/UDP proxy module
--with-stream=dynamic enable dynamic TCP/UDP proxy module
--with-stream_ssl_module enable ngx_stream_ssl_module
--with-stream_quic_module enable ngx_stream_quic_module
--with-stream_realip_module enable ngx_stream_realip_module
--with-stream_geoip_module enable ngx_stream_geoip_module
--with-stream_geoip_module=dynamic enable dynamic ngx_stream_geoip_module
--with-stream_ssl_preread_module enable ngx_stream_ssl_preread_module
--without-stream_limit_conn_module disable ngx_stream_limit_conn_module
--without-stream_access_module disable ngx_stream_access_module
--without-stream_geo_module disable ngx_stream_geo_module
--without-stream_map_module disable ngx_stream_map_module
--without-stream_split_clients_module
disable ngx_stream_split_clients_module
--without-stream_return_module disable ngx_stream_return_module
--without-stream_set_module disable ngx_stream_set_module
--without-stream_upstream_hash_module
disable ngx_stream_upstream_hash_module
--without-stream_upstream_least_conn_module
disable ngx_stream_upstream_least_conn_module
--without-stream_upstream_random_module
disable ngx_stream_upstream_random_module
--without-stream_upstream_zone_module
disable ngx_stream_upstream_zone_module
--with-cc=PATH set path to C compiler
--with-cpp=PATH set path to C preprocessor
--with-cc-opt=OPTIONS set additional options for C compiler
--with-ld-opt=OPTIONS set additional options for linker
--with-cpu-opt=CPU build for specified CPU, the valid values:
--with-google_perftools_module enable ngx_google_perftools_module
--with-cpp_test_module enable ngx_cpp_test_module
--add-module=PATH enable external module
--add-dynamic-module=PATH enable dynamic external module
--with-compat dynamic modules compatibility
--with-cc=PATH set C compiler pathname
--with-cpp=PATH set C preprocessor pathname
--with-cc-opt=OPTIONS set additional C compiler options
--with-ld-opt=OPTIONS set additional linker options
--with-cpu-opt=CPU build for the specified CPU, valid values:
pentium, pentiumpro, pentium3, pentium4,
athlon, opteron, sparc32, sparc64, ppc64
--without-pcre disable PCRE libarary usage
--without-pcre disable PCRE library usage
--with-pcre force PCRE library usage
--with-pcre=DIR set path to PCRE library sources
--with-pcre-opt=OPTIONS set additional options for PCRE building
--with-md5=DIR set path to md5 library sources
--with-md5-opt=OPTIONS set additional options for md5 building
--with-md5-asm use md5 assembler sources
--with-sha1=DIR set path to sha1 library sources
--with-sha1-opt=OPTIONS set additional options for sha1 building
--with-sha1-asm use sha1 assembler sources
--with-pcre-opt=OPTIONS set additional build options for PCRE
--with-pcre-jit build PCRE with JIT compilation support
--without-pcre2 do not use PCRE2 library
--with-zlib=DIR set path to zlib library sources
--with-zlib-opt=OPTIONS set additional options for zlib building
--with-zlib-opt=OPTIONS set additional build options for zlib
--with-zlib-asm=CPU use zlib assembler sources optimized
for specified CPU, the valid values:
for the specified CPU, valid values:
pentium, pentiumpro
--with-openssl=DIR set path to OpenSSL library sources
--with-openssl-opt=OPTIONS set additional options for OpenSSL building
--with-libatomic force libatomic_ops library usage
--with-libatomic=DIR set path to libatomic_ops library sources
--with-debug enable the debugging logging
--with-openssl=DIR set path to OpenSSL library sources
--with-openssl-opt=OPTIONS set additional build options for OpenSSL
--with-debug enable debug logging
END
@ -341,156 +612,30 @@ END
fi
if [ $HTTP = NO ]; then
HTTP_CHARSET=NO
HTTP_GZIP=NO
HTTP_SSI=NO
HTTP_USERID=NO
HTTP_ACCESS=NO
HTTP_STATUS=NO
HTTP_REWRITE=NO
HTTP_PROXY=NO
HTTP_FASTCGI=NO
fi
if [ ".$NGX_PLATFORM" = ".win32" ]; then
NGX_WINE=$WINE
fi
NGX_PREFIX=${NGX_PREFIX:-/usr/local/nginx}
NGX_SBIN_PATH=${NGX_SBIN_PATH:-sbin/nginx}
NGX_MODULES_PATH=${NGX_MODULES_PATH:-modules}
NGX_CONF_PATH=${NGX_CONF_PATH:-conf/nginx.conf}
NGX_CONF_PREFIX=`dirname $NGX_CONF_PATH`
NGX_PID_PATH=${NGX_PID_PATH:-logs/nginx.pid}
NGX_LOCK_PATH=${NGX_LOCK_PATH:-logs/nginx.lock}
if [ ".$NGX_ERROR_LOG_PATH" = ".stderr" ]; then
NGX_ERROR_LOG_PATH=
else
NGX_ERROR_LOG_PATH=${NGX_ERROR_LOG_PATH:-logs/error.log}
fi
case ".$NGX_SBIN_PATH" in
./*)
;;
.)
NGX_SBIN_PATH=$NGX_PREFIX/sbin/nginx
;;
*)
NGX_SBIN_PATH=$NGX_PREFIX/$NGX_SBIN_PATH
;;
esac
case ".$NGX_CONF_PATH" in
./*)
;;
.)
NGX_CONF_PATH=$NGX_PREFIX/conf/nginx.conf
;;
*)
NGX_CONF_PATH=$NGX_PREFIX/$NGX_CONF_PATH
;;
esac
case ".$NGX_PID_PATH" in
./*)
;;
.)
NGX_PID_PATH=$NGX_PREFIX/logs/nginx.pid
;;
*)
NGX_PID_PATH=$NGX_PREFIX/$NGX_PID_PATH
;;
esac
case ".$NGX_LOCK_PATH" in
./*)
;;
.)
NGX_LOCK_PATH=$NGX_PREFIX/logs/nginx.lock
;;
*)
NGX_LOCK_PATH=$NGX_PREFIX/$NGX_LOCK_PATH
;;
esac
case ".$NGX_ERROR_LOG_PATH" in
./*)
;;
.)
NGX_ERROR_LOG_PATH=$NGX_PREFIX/logs/error.log
;;
.stderr)
NGX_ERROR_LOG_PATH=
;;
*)
NGX_ERROR_LOG_PATH=$NGX_PREFIX/$NGX_ERROR_LOG_PATH
;;
esac
case ".$NGX_HTTP_LOG_PATH" in
./*)
;;
.)
NGX_HTTP_LOG_PATH=$NGX_PREFIX/logs/access.log
;;
*)
NGX_HTTP_LOG_PATH=$NGX_PREFIX/$NGX_HTTP_LOG_PATH
;;
esac
case ".$NGX_HTTP_CLIENT_TEMP_PATH" in
./*)
;;
.)
NGX_HTTP_CLIENT_TEMP_PATH=$NGX_PREFIX/client_body_temp
;;
*)
NGX_HTTP_CLIENT_TEMP_PATH=$NGX_PREFIX/$NGX_HTTP_CLIENT_TEMP_PATH
;;
esac
case ".$NGX_HTTP_PROXY_TEMP_PATH" in
./*)
;;
.)
NGX_HTTP_PROXY_TEMP_PATH=$NGX_PREFIX/proxy_temp
;;
*)
NGX_HTTP_PROXY_TEMP_PATH=$NGX_PREFIX/$NGX_HTTP_PROXY_TEMP_PATH
;;
esac
case ".$NGX_HTTP_FASTCGI_TEMP_PATH" in
./*)
;;
.)
NGX_HTTP_FASTCGI_TEMP_PATH=$NGX_PREFIX/fastcgi_temp
;;
*)
NGX_HTTP_FASTCGI_TEMP_PATH=$NGX_PREFIX/$NGX_HTTP_FASTCGI_TEMP_PATH
;;
esac
NGX_HTTP_LOG_PATH=${NGX_HTTP_LOG_PATH:-logs/access.log}
NGX_HTTP_CLIENT_TEMP_PATH=${NGX_HTTP_CLIENT_TEMP_PATH:-client_body_temp}
NGX_HTTP_PROXY_TEMP_PATH=${NGX_HTTP_PROXY_TEMP_PATH:-proxy_temp}
NGX_HTTP_FASTCGI_TEMP_PATH=${NGX_HTTP_FASTCGI_TEMP_PATH:-fastcgi_temp}
NGX_HTTP_UWSGI_TEMP_PATH=${NGX_HTTP_UWSGI_TEMP_PATH:-uwsgi_temp}
NGX_HTTP_SCGI_TEMP_PATH=${NGX_HTTP_SCGI_TEMP_PATH:-scgi_temp}
case ".$NGX_PERL_MODULES" in
./*)

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
echo "checking for $NGX_SYSTEM specific features"
@ -18,6 +19,10 @@ case "$NGX_PLATFORM" in
. auto/os/solaris
;;
Darwin:*)
. auto/os/darwin
;;
win32)
. auto/os/win32
;;
@ -36,22 +41,12 @@ case "$NGX_PLATFORM" in
'
;;
Darwin:*)
have=NGX_DARWIN . auto/have_headers
have=NGX_HAVE_INHERITED_NONBLOCK . auto/have
NetBSD:*)
CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $POSIX_DEPS"
CORE_SRCS="$UNIX_SRCS"
ngx_feature="atomic(3)"
ngx_feature_name=NGX_DARWIN_ATOMIC
ngx_feature_run=no
ngx_feature_incs="#include <libkern/OSAtomic.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int32_t lock, n;
n = OSAtomicCompareAndSwap32Barrier(0, 1, lock)"
. auto/feature
NGX_RPATH=YES
;;
HP-UX:*)
@ -61,6 +56,7 @@ case "$NGX_PLATFORM" in
CORE_DEPS="$UNIX_DEPS $POSIX_DEPS"
CORE_SRCS="$UNIX_SRCS"
CC_AUX_FLAGS="$CC_AUX_FLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
CC_AUX_FLAGS="$CC_AUX_FLAGS -D_HPUX_ALT_XOPEN_SOCKET_API"
;;
OSF1:*)
@ -72,6 +68,15 @@ case "$NGX_PLATFORM" in
CORE_SRCS="$UNIX_SRCS"
;;
GNU:*)
# GNU Hurd
have=NGX_GNU_HURD . auto/have_headers
CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $POSIX_DEPS"
CORE_SRCS="$UNIX_SRCS"
CC_AUX_FLAGS="$CC_AUX_FLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
;;
*)
CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $POSIX_DEPS"
@ -105,7 +110,13 @@ case "$NGX_MACHINE" in
NGX_MACH_CACHE_LINE=64
;;
aarch64 | arm64)
have=NGX_ALIGNMENT value=16 . auto/define
NGX_MACH_CACHE_LINE=64
;;
*)
have=NGX_ALIGNMENT value=16 . auto/define
NGX_MACH_CACHE_LINE=32
;;

120
auto/os/darwin Normal file
View File

@ -0,0 +1,120 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
have=NGX_DARWIN . auto/have_headers
CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $DARWIN_DEPS"
CORE_SRCS="$UNIX_SRCS $DARWIN_SRCS"
ngx_spacer='
'
MAIN_LINK=
MODULE_LINK="-shared -Wl,-undefined,dynamic_lookup"
CC_AUX_FLAGS="$CC_AUX_FLAGS -D__APPLE_USE_RFC_3542"
# kqueue
echo " + kqueue found"
have=NGX_HAVE_KQUEUE . auto/have
have=NGX_HAVE_CLEAR_EVENT . auto/have
EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
EVENT_FOUND=YES
NGX_KQUEUE_CHECKED=YES
ngx_feature="kqueue's EVFILT_TIMER"
ngx_feature_name="NGX_HAVE_TIMER_EVENT"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/event.h>
#include <sys/time.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int kq;
struct kevent kev;
struct timespec ts;
if ((kq = kqueue()) == -1) return 1;
kev.ident = 0;
kev.filter = EVFILT_TIMER;
kev.flags = EV_ADD|EV_ENABLE;
kev.fflags = 0;
kev.data = 1000;
kev.udata = 0;
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (kevent(kq, &kev, 1, &kev, 1, &ts) == -1) return 1;
if (kev.flags & EV_ERROR) return 1;"
. auto/feature
ngx_feature="Darwin 64-bit kqueue millisecond timeout bug"
ngx_feature_name=NGX_DARWIN_KEVENT_BUG
ngx_feature_run=bug
ngx_feature_incs="#include <sys/event.h>
#include <sys/time.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int kq;
struct kevent kev;
struct timespec ts;
struct timeval tv, tv0;
kq = kqueue();
ts.tv_sec = 0;
ts.tv_nsec = 999000000;
gettimeofday(&tv, 0);
kevent(kq, NULL, 0, &kev, 1, &ts);
gettimeofday(&tv0, 0);
timersub(&tv0, &tv, &tv);
if (tv.tv_sec * 1000000 + tv.tv_usec < 900000) return 1;"
. auto/feature
# sendfile()
ngx_feature="sendfile()"
ngx_feature_name="NGX_HAVE_SENDFILE"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <sys/errno.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int s = 0, fd = 1;
off_t n; off_t off = 0;
n = sendfile(s, fd, off, &n, NULL, 0);
if (n == -1 && errno == ENOSYS) return 1"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_SRCS="$CORE_SRCS $DARWIN_SENDFILE_SRCS"
fi
ngx_feature="atomic(3)"
ngx_feature_name=NGX_DARWIN_ATOMIC
ngx_feature_run=no
ngx_feature_incs="#include <libkern/OSAtomic.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int32_t lock = 0;
if (!OSAtomicCompareAndSwap32Barrier(0, 1, &lock)) return 1"
. auto/feature

View File

@ -1,202 +0,0 @@
# Copyright (C) Igor Sysoev
NGX_USER=${NGX_USER:-nobody}
if [ -z "$NGX_GROUP" ]; then
if [ $NGX_USER = nobody ]; then
if grep nobody /etc/group 2>&1 >/dev/null; then
echo "checking for nobody group ... found"
NGX_GROUP=nobody
else
echo "checking for nobody group ... not found"
if grep nogroup /etc/group 2>&1 >/dev/null; then
echo "checking for nogroup group ... found"
NGX_GROUP=nogroup
else
echo "checking for nogroup group ... not found"
NGX_GROUP=nobody
fi
fi
else
NGX_GROUP=$NGX_USER
fi
fi
ngx_feature="poll()"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <poll.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int n, dp; struct pollfd pl;
dp = 0;
pl.fd = 0;
pl.events = 0;
pl.revents = 0;
n = poll(&pl, 1, 0)"
. auto/feature
if [ $ngx_found = no ]; then
EVENT_POLL=NONE
fi
ngx_feature="/dev/poll"
ngx_feature_name="NGX_HAVE_DEVPOLL"
ngx_feature_run=no
ngx_feature_incs="#include <sys/devpoll.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int n, dp; struct dvpoll dvp;
dp = 0;
dvp.dp_fds = NULL;
dvp.dp_nfds = 0;
dvp.dp_timeout = 0;
n = ioctl(dp, DP_POLL, &dvp)"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
EVENT_FOUND=YES
fi
if test -z "$NGX_KQUEUE_CHECKED"; then
ngx_feature="kqueue"
ngx_feature_name="NGX_HAVE_KQUEUE"
ngx_feature_run=no
ngx_feature_incs="#include <sys/event.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int kq; kq = kqueue()"
. auto/feature
if [ $ngx_found = yes ]; then
have=NGX_HAVE_CLEAR_EVENT . auto/have
EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
EVENT_FOUND=YES
ngx_feature="kqueue's NOTE_LOWAT"
ngx_feature_name="NGX_HAVE_LOWAT_EVENT"
ngx_feature_run=no
ngx_feature_incs="#include <sys/event.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct kevent kev;
kev.fflags = NOTE_LOWAT;"
. auto/feature
ngx_feature="kqueue's EVFILT_TIMER"
ngx_feature_name="NGX_HAVE_TIMER_EVENT"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/event.h>
#include <sys/time.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int kq;
struct kevent kev;
struct timespec ts;
if ((kq = kqueue()) == -1) return 1;
kev.ident = 0;
kev.filter = EVFILT_TIMER;
kev.flags = EV_ADD|EV_ENABLE;
kev.fflags = 0;
kev.data = 1000;
kev.udata = 0;
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (kevent(kq, &kev, 1, &kev, 1, &ts) == -1) return 1;
if (kev.flags & EV_ERROR) return 1;"
. auto/feature
if [ "$NGX_SYSTEM" = "Darwin" ]; then
ngx_feature="Darwin 64-bit kqueue millisecond timeout bug"
ngx_feature_name=NGX_DARWIN_KEVENT_BUG
ngx_feature_run=bug
ngx_feature_incs="#include <sys/event.h>
#include <sys/time.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int kq;
struct kevent kev;
struct timespec ts;
struct timeval tv, tv0;
kq = kqueue();
ts.tv_sec = 0;
ts.tv_nsec = 999000000;
gettimeofday(&tv, 0);
kevent(kq, NULL, 0, &kev, 1, &ts);
gettimeofday(&tv0, 0);
timersub(&tv0, &tv, &tv);
if (tv.tv_sec * 1000000 + tv.tv_usec < 900000) return 1;"
. auto/feature
fi
fi
fi
if [ "$NGX_SYSTEM" = "NetBSD" ]; then
# NetBSD 2.0 incompatibly defines kevent.udata as "intptr_t"
cat << END >> $NGX_AUTO_CONFIG_H
#define NGX_KQUEUE_UDATA_T
END
else
cat << END >> $NGX_AUTO_CONFIG_H
#define NGX_KQUEUE_UDATA_T (void *)
END
fi
ngx_feature="crypt()"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="crypt(\"test\", \"salt\");"
. auto/feature
if [ $ngx_found = no ]; then
ngx_feature="crypt() in libcrypt"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=-lcrypt
. auto/feature
if [ $ngx_found = yes ]; then
CRYPT_LIB="-lcrypt"
fi
fi

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
have=NGX_FREEBSD . auto/have_headers
@ -43,6 +44,21 @@ if [ $osreldate -gt 300007 ]; then
CORE_SRCS="$CORE_SRCS $FREEBSD_SENDFILE_SRCS"
fi
if [ $osreldate -gt 1100093 ]; then
echo " + sendfile()'s SF_NODISKIO found"
have=NGX_HAVE_SENDFILE_NODISKIO . auto/have
fi
# POSIX semaphores
# http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/127545
if [ $osreldate -ge 701106 ]; then
echo " + POSIX semaphores should work"
else
have=NGX_HAVE_POSIX_SEM . auto/nohave
fi
# kqueue
@ -62,7 +78,7 @@ fi
NGX_KQUEUE_CHECKED=YES
# kqueue's NOTE_LAWAT
# kqueue's NOTE_LOWAT
if [ \( $version -lt 500000 -a $version -ge 430000 \) \
-o $version -ge 500018 ]
@ -81,40 +97,9 @@ then
fi
if [ $USE_THREADS = "rfork" ]; then
# cpuset_setaffinity()
echo " + using rfork()"
# # kqueue's EVFILT_SIGNAL is safe
#
# if [ $version -gt 460101 ]; then
# echo " + kqueue's EVFILT_SIGNAL is safe"
# have=NGX_HAVE_SAFE_EVFILT_SIGNAL . auto/have
# else
# echo "$0: error: the kqueue's EVFILT_SIGNAL is unsafe on this"
# echo "FreeBSD version, so --with-threads=rfork could not be used"
# echo
#
# exit 1
# fi
fi
if [ $EVENT_AIO = YES ]; then
if [ \( $version -lt 500000 -a $version -ge 430000 \) \
-o $version -ge 500014 ]
then
have=NGX_HAVE_AIO . auto/have
EVENT_MODULES="$EVENT_MODULES $AIO_MODULE"
CORE_SRCS="$CORE_SRCS $AIO_SRCS"
else
cat << END
$0: error: the kqueue does not support AIO on this FreeBSD version
END
exit 1
fi
if [ $version -ge 701000 ]; then
echo " + cpuset_setaffinity() found"
have=NGX_HAVE_CPUSET_SETAFFINITY . auto/have
fi

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
have=NGX_LINUX . auto/have_headers
@ -11,29 +12,26 @@ CORE_SRCS="$UNIX_SRCS $LINUX_SRCS"
ngx_spacer='
'
CC_AUX_FLAGS="$CC_AUX_FLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
cc_aux_flags="$CC_AUX_FLAGS"
CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
# Linux kernel version
version=`grep "#define LINUX_VERSION_CODE" /usr/include/linux/version.h \
| sed -e 's/^.* \(.*\)$/\1/'`
version=$((`uname -r \
| sed -n -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/ \
\1*256*256+\2*256+\3/p' \
-e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1*256*256+\2*256/p'`))
version=${version:-0}
# enable the rt signals on Linux 2.2.19 and onward
# posix_fadvise64() had been implemented in 2.5.60
if [ $version -ge 131609 -o $EVENT_RTSIG = YES ]; then
echo " + rt signals found"
have=NGX_HAVE_RTSIG . auto/have
have=NGX_HAVE_POLL . auto/have
EVENT_MODULES="$EVENT_MODULES $RTSIG_MODULE"
CORE_SRCS="$CORE_SRCS $RTSIG_SRCS"
EVENT_FOUND=YES
if [ $version -lt 132412 ]; then
have=NGX_HAVE_POSIX_FADVISE . auto/nohave
fi
# epoll, EPOLLET version
ngx_feature="epoll"
@ -42,10 +40,11 @@ ngx_feature_run=yes
ngx_feature_incs="#include <sys/epoll.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int efd = 0, fd = 1, n;
ngx_feature_test="int efd = 0;
struct epoll_event ee;
ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
ee.data.ptr = NULL;
(void) ee;
efd = epoll_create(100);
if (efd == -1) return 1;"
. auto/feature
@ -55,17 +54,90 @@ if [ $ngx_found = yes ]; then
CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
EVENT_FOUND=YES
# EPOLLRDHUP appeared in Linux 2.6.17, glibc 2.8
ngx_feature="EPOLLRDHUP"
ngx_feature_name="NGX_HAVE_EPOLLRDHUP"
ngx_feature_run=no
ngx_feature_incs="#include <sys/epoll.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int efd = 0, fd = 0;
struct epoll_event ee;
ee.events = EPOLLIN|EPOLLRDHUP|EPOLLET;
ee.data.ptr = NULL;
epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ee)"
. auto/feature
# EPOLLEXCLUSIVE appeared in Linux 4.5, glibc 2.24
ngx_feature="EPOLLEXCLUSIVE"
ngx_feature_name="NGX_HAVE_EPOLLEXCLUSIVE"
ngx_feature_run=no
ngx_feature_incs="#include <sys/epoll.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int efd = 0, fd = 0;
struct epoll_event ee;
ee.events = EPOLLIN|EPOLLEXCLUSIVE;
ee.data.ptr = NULL;
epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ee)"
. auto/feature
# eventfd()
ngx_feature="eventfd()"
ngx_feature_name="NGX_HAVE_EVENTFD"
ngx_feature_run=no
ngx_feature_incs="#include <sys/eventfd.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="(void) eventfd(0, 0)"
. auto/feature
if [ $ngx_found = yes ]; then
have=NGX_HAVE_SYS_EVENTFD_H . auto/have
fi
if [ $ngx_found = no ]; then
ngx_feature="eventfd() (SYS_eventfd)"
ngx_feature_incs="#include <sys/syscall.h>"
ngx_feature_test="(void) SYS_eventfd"
. auto/feature
fi
fi
# O_PATH and AT_EMPTY_PATH were introduced in 2.6.39, glibc 2.14
ngx_feature="O_PATH"
ngx_feature_name="NGX_HAVE_O_PATH"
ngx_feature_run=no
ngx_feature_incs="#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int fd; struct stat sb;
fd = openat(AT_FDCWD, \".\", O_PATH|O_DIRECTORY|O_NOFOLLOW);
if (fstatat(fd, \"\", &sb, AT_EMPTY_PATH) != 0) return 1"
. auto/feature
# sendfile()
CC_AUX_FLAGS="$CC_AUX_FLAGS -D_GNU_SOURCE"
CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE"
ngx_feature="sendfile()"
ngx_feature_name="NGX_HAVE_SENDFILE"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/sendfile.h>
#include <errno.h>"
#include <errno.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int s = 0, fd = 1;
@ -81,12 +153,12 @@ fi
# sendfile64()
CC_AUX_FLAGS="$CC_AUX_FLAGS -D_FILE_OFFSET_BITS=64"
CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
ngx_feature="sendfile64()"
ngx_feature_name="NGX_HAVE_SENDFILE64"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/sendfile.h>
#include <errno.h>"
#include <errno.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int s = 0, fd = 1;
@ -110,14 +182,113 @@ ngx_feature_test="if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) return 1"
. auto/feature
# sched_setaffinity()
# prctl(PR_SET_KEEPCAPS)
ngx_feature="sched_setaffinity()"
ngx_feature_name="NGX_HAVE_SCHED_SETAFFINITY"
ngx_feature_run=no
ngx_feature_incs="#include <sched.h>"
ngx_feature="prctl(PR_SET_KEEPCAPS)"
ngx_feature_name="NGX_HAVE_PR_SET_KEEPCAPS"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/prctl.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="long mask = 0;
sched_setaffinity(0, 32, (cpu_set_t *) &mask)"
ngx_feature_test="if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1) return 1"
. auto/feature
# capabilities
ngx_feature="capabilities"
ngx_feature_name="NGX_HAVE_CAPABILITIES"
ngx_feature_run=no
ngx_feature_incs="#include <linux/capability.h>
#include <sys/syscall.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct __user_cap_data_struct data;
struct __user_cap_header_struct header;
header.version = _LINUX_CAPABILITY_VERSION_1;
data.effective = CAP_TO_MASK(CAP_NET_RAW);
data.permitted = 0;
(void) header;
(void) data;
(void) SYS_capset"
. auto/feature
# crypt_r()
ngx_feature="crypt_r()"
ngx_feature_name="NGX_HAVE_GNU_CRYPT_R"
ngx_feature_run=no
ngx_feature_incs="#include <crypt.h>"
ngx_feature_path=
ngx_feature_libs=-lcrypt
ngx_feature_test="struct crypt_data cd;
crypt_r(\"key\", \"salt\", &cd);"
. auto/feature
ngx_include="sys/vfs.h"; . auto/include
# BPF sockhash
ngx_feature="BPF sockhash"
ngx_feature_name="NGX_HAVE_BPF"
ngx_feature_run=no
ngx_feature_incs="#include <linux/bpf.h>
#include <sys/syscall.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="union bpf_attr attr = { 0 };
attr.map_flags = 0;
attr.map_type = BPF_MAP_TYPE_SOCKHASH;
syscall(__NR_bpf, 0, &attr, 0);"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_SRCS="$CORE_SRCS src/core/ngx_bpf.c"
CORE_DEPS="$CORE_DEPS src/core/ngx_bpf.h"
if [ $QUIC_BPF != NONE ]; then
QUIC_BPF=YES
fi
fi
ngx_feature="SO_COOKIE"
ngx_feature_name="NGX_HAVE_SO_COOKIE"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
$NGX_INCLUDE_INTTYPES_H"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="socklen_t optlen = sizeof(uint64_t);
uint64_t cookie;
getsockopt(0, SOL_SOCKET, SO_COOKIE, &cookie, &optlen)"
. auto/feature
if [ $ngx_found = yes ]; then
SO_COOKIE_FOUND=YES
fi
# UDP segmentation offloading
ngx_feature="UDP_SEGMENT"
ngx_feature_name="NGX_HAVE_UDP_SEGMENT"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/udp.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="socklen_t optlen = sizeof(int);
int val;
getsockopt(0, SOL_UDP, UDP_SEGMENT, &val, &optlen)"
. auto/feature
CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
have=NGX_SOLARIS . auto/have_headers
@ -7,12 +8,14 @@ have=NGX_SOLARIS . auto/have_headers
CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $SOLARIS_DEPS"
CORE_SRCS="$UNIX_SRCS $SOLARIS_SRCS "
CORE_LIBS="$CORE_LIBS -lsocket -lnsl -lrt"
CORE_LIBS="$CORE_LIBS -lsocket -lnsl"
NGX_RPATH=YES
# Solaris's make does not support a blank line between target and rules
ngx_spacer=
CC_AUX_FLAGS="$CC_AUX_FLAGS -D_FILE_OFFSET_BITS=64 -lsocket -lnsl -lrt"
CC_AUX_FLAGS="$CC_AUX_FLAGS -D_FILE_OFFSET_BITS=64 -lsocket -lnsl"
if [ $ZLIB_ASM != NO ]; then
@ -32,7 +35,8 @@ ngx_feature_path=
ngx_feature_libs="-lsendfile"
ngx_feature_test="int fd = 1; sendfilevec_t vec[1];
size_t sent; ssize_t n;
n = sendfilev(fd, vec, 1, &sent)"
n = sendfilev(fd, vec, 1, &sent);
if (n == -1) return 1"
. auto/feature
@ -48,7 +52,7 @@ ngx_feature_run=no
ngx_feature_incs="#include <port.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int n = port_create()"
ngx_feature_test="(void) port_create()"
. auto/feature
if [ $ngx_found = yes ]; then

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
have=NGX_WIN32 . auto/have_headers
@ -8,16 +9,31 @@ CORE_INCS="$WIN32_INCS"
CORE_DEPS="$WIN32_DEPS"
CORE_SRCS="$WIN32_SRCS $IOCP_SRCS"
OS_CONFIG="$WIN32_CONFIG"
CORE_LIBS="$CORE_LIBS shell32.lib ws2_32.lib"
NGX_ICONS="$NGX_WIN32_ICONS"
SELECT_SRCS=$WIN32_SELECT_SRCS
POLL_SRCS=$WIN32_POLL_SRCS
ngx_pic_opt=
ngx_binext=".exe"
case "$NGX_CC_NAME" in
gcc)
CORE_LIBS="$CORE_LIBS -ladvapi32 -lws2_32"
MAIN_LINK="$MAIN_LINK -Wl,--export-all-symbols"
MAIN_LINK="$MAIN_LINK -Wl,--out-implib=$NGX_OBJS/libnginx.a"
MODULE_LINK="-shared -L $NGX_OBJS -lnginx"
;;
*)
CORE_LIBS="$CORE_LIBS advapi32.lib ws2_32.lib"
;;
esac
EVENT_MODULES="$EVENT_MODULES $IOCP_MODULE"
EVENT_FOUND=YES
#EVENT_FOUND=YES
if [ $EVENT_SELECT = NO ]; then
CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
fi
have=NGX_HAVE_INET6 . auto/have
have=NGX_HAVE_AIO . auto/have
have=NGX_HAVE_IOCP . auto/have

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
CORE_MODULES="ngx_core_module ngx_errlog_module ngx_conf_module"
@ -15,21 +16,32 @@ CORE_DEPS="src/core/nginx.h \
src/core/ngx_list.h \
src/core/ngx_hash.h \
src/core/ngx_buf.h \
src/core/ngx_queue.h \
src/core/ngx_string.h \
src/core/ngx_parse.h \
src/core/ngx_parse_time.h \
src/core/ngx_inet.h \
src/core/ngx_file.h \
src/core/ngx_crc.h \
src/core/ngx_crc32.h \
src/core/ngx_murmurhash.h \
src/core/ngx_md5.h \
src/core/ngx_sha1.h \
src/core/ngx_rbtree.h \
src/core/ngx_radix_tree.h \
src/core/ngx_rwlock.h \
src/core/ngx_slab.h \
src/core/ngx_times.h \
src/core/ngx_shmtx.h \
src/core/ngx_connection.h \
src/core/ngx_cycle.h \
src/core/ngx_conf_file.h \
src/core/ngx_garbage_collector.h"
src/core/ngx_module.h \
src/core/ngx_resolver.h \
src/core/ngx_open_file_cache.h \
src/core/ngx_crypt.h \
src/core/ngx_proxy_protocol.h \
src/core/ngx_syslog.h"
CORE_SRCS="src/core/nginx.c \
@ -39,12 +51,17 @@ CORE_SRCS="src/core/nginx.c \
src/core/ngx_list.c \
src/core/ngx_hash.c \
src/core/ngx_buf.c \
src/core/ngx_queue.c \
src/core/ngx_output_chain.c \
src/core/ngx_string.c \
src/core/ngx_parse.c \
src/core/ngx_parse_time.c \
src/core/ngx_inet.c \
src/core/ngx_file.c \
src/core/ngx_crc32.c \
src/core/ngx_murmurhash.c \
src/core/ngx_md5.c \
src/core/ngx_sha1.c \
src/core/ngx_rbtree.c \
src/core/ngx_radix_tree.c \
src/core/ngx_slab.c \
@ -53,45 +70,44 @@ CORE_SRCS="src/core/nginx.c \
src/core/ngx_connection.c \
src/core/ngx_cycle.c \
src/core/ngx_spinlock.c \
src/core/ngx_rwlock.c \
src/core/ngx_cpuinfo.c \
src/core/ngx_conf_file.c \
src/core/ngx_garbage_collector.c"
REGEX_DEPS=src/core/ngx_regex.h
REGEX_SRCS=src/core/ngx_regex.c
OPENSSL_MODULE=ngx_openssl_module
OPENSSL_DEPS=src/event/ngx_event_openssl.h
OPENSSL_SRCS=src/event/ngx_event_openssl.c
src/core/ngx_module.c \
src/core/ngx_resolver.c \
src/core/ngx_open_file_cache.c \
src/core/ngx_crypt.c \
src/core/ngx_proxy_protocol.c \
src/core/ngx_syslog.c"
EVENT_MODULES="ngx_events_module ngx_event_core_module"
EVENT_INCS="src/event src/event/modules"
EVENT_INCS="src/event src/event/modules src/event/quic"
EVENT_DEPS="src/event/ngx_event.h \
src/event/ngx_event_timer.h \
src/event/ngx_event_posted.h \
src/event/ngx_event_busy_lock.h \
src/event/ngx_event_connect.h \
src/event/ngx_event_pipe.h"
src/event/ngx_event_pipe.h \
src/event/ngx_event_udp.h"
EVENT_SRCS="src/event/ngx_event.c \
src/event/ngx_event_timer.c \
src/event/ngx_event_posted.c \
src/event/ngx_event_busy_lock.c \
src/event/ngx_event_accept.c \
src/event/ngx_event_udp.c \
src/event/ngx_event_connect.c \
src/event/ngx_event_pipe.c"
SELECT_MODULE=ngx_select_module
SELECT_SRCS=src/event/modules/ngx_select_module.c
WIN32_SELECT_SRCS=src/event/modules/ngx_win32_select_module.c
POLL_MODULE=ngx_poll_module
POLL_SRCS=src/event/modules/ngx_poll_module.c
WIN32_POLL_SRCS=src/event/modules/ngx_win32_poll_module.c
KQUEUE_MODULE=ngx_kqueue_module
KQUEUE_SRCS=src/event/modules/ngx_kqueue_module.c
@ -105,31 +121,23 @@ EVENTPORT_SRCS=src/event/modules/ngx_eventport_module.c
EPOLL_MODULE=ngx_epoll_module
EPOLL_SRCS=src/event/modules/ngx_epoll_module.c
RTSIG_MODULE=ngx_rtsig_module
RTSIG_SRCS=src/event/modules/ngx_rtsig_module.c
IOCP_MODULE=ngx_iocp_module
IOCP_SRCS=src/event/modules/ngx_iocp_module.c
AIO_MODULE=ngx_aio_module
AIO_SRCS="src/event/modules/ngx_aio_module.c \
src/os/unix/ngx_aio_read.c \
src/os/unix/ngx_aio_write.c \
src/os/unix/ngx_aio_read_chain.c \
src/os/unix/ngx_aio_write_chain.c"
FILE_AIO_SRCS="src/os/unix/ngx_file_aio_read.c"
LINUX_AIO_SRCS="src/os/unix/ngx_linux_aio_read.c"
UNIX_INCS="$CORE_INCS $EVENT_INCS src/os/unix"
UNIX_DEPS="$CORE_DEPS $EVENT_DEPS \
src/os/unix/ngx_time.h \
src/os/unix/ngx_types.h \
src/os/unix/ngx_errno.h \
src/os/unix/ngx_alloc.h \
src/os/unix/ngx_files.h \
src/os/unix/ngx_channel.h \
src/os/unix/ngx_shmem.h \
src/os/unix/ngx_process.h \
src/os/unix/ngx_setaffinity.h \
src/os/unix/ngx_setproctitle.h \
src/os/unix/ngx_atomic.h \
src/os/unix/ngx_gcc_atomic_x86.h \
@ -137,6 +145,7 @@ UNIX_DEPS="$CORE_DEPS $EVENT_DEPS \
src/os/unix/ngx_socket.h \
src/os/unix/ngx_os.h \
src/os/unix/ngx_user.h \
src/os/unix/ngx_dlopen.h \
src/os/unix/ngx_process_cycle.h"
# add to UNIX_DEPS
@ -157,44 +166,55 @@ UNIX_SRCS="$CORE_SRCS $EVENT_SRCS \
src/os/unix/ngx_socket.c \
src/os/unix/ngx_recv.c \
src/os/unix/ngx_readv_chain.c \
src/os/unix/ngx_udp_recv.c \
src/os/unix/ngx_send.c \
src/os/unix/ngx_writev_chain.c \
src/os/unix/ngx_udp_send.c \
src/os/unix/ngx_udp_sendmsg_chain.c \
src/os/unix/ngx_channel.c \
src/os/unix/ngx_shmem.c \
src/os/unix/ngx_process.c \
src/os/unix/ngx_daemon.c \
src/os/unix/ngx_setaffinity.c \
src/os/unix/ngx_setproctitle.c \
src/os/unix/ngx_posix_init.c \
src/os/unix/ngx_user.c \
src/os/unix/ngx_dlopen.c \
src/os/unix/ngx_process_cycle.c"
POSIX_DEPS=src/os/unix/ngx_posix_config.h
FREEBSD_DEPS=src/os/unix/ngx_freebsd_config.h
THREAD_POOL_MODULE=ngx_thread_pool_module
THREAD_POOL_DEPS=src/core/ngx_thread_pool.h
THREAD_POOL_SRCS="src/core/ngx_thread_pool.c
src/os/unix/ngx_thread_cond.c
src/os/unix/ngx_thread_mutex.c
src/os/unix/ngx_thread_id.c"
FREEBSD_DEPS="src/os/unix/ngx_freebsd_config.h src/os/unix/ngx_freebsd.h"
FREEBSD_SRCS=src/os/unix/ngx_freebsd_init.c
FREEBSD_SENDFILE_SRCS=src/os/unix/ngx_freebsd_sendfile_chain.c
FREEBSD_RFORK_DEPS="src/os/unix/ngx_freebsd_rfork_thread.h"
FREEBSD_RFORK_SRCS="src/os/unix/ngx_freebsd_rfork_thread.c"
FREEBSD_RFORK_THREAD_SRCS="src/os/unix/rfork_thread.S"
PTHREAD_SRCS="src/os/unix/ngx_pthread_thread.c"
LINUX_DEPS=src/os/unix/ngx_linux_config.h
LINUX_DEPS="src/os/unix/ngx_linux_config.h src/os/unix/ngx_linux.h"
LINUX_SRCS=src/os/unix/ngx_linux_init.c
LINUX_SENDFILE_SRCS=src/os/unix/ngx_linux_sendfile_chain.c
SOLARIS_DEPS=src/os/unix/ngx_solaris_config.h
SOLARIS_DEPS="src/os/unix/ngx_solaris_config.h src/os/unix/ngx_solaris.h"
SOLARIS_SRCS=src/os/unix/ngx_solaris_init.c
SOLARIS_SENDFILEV_SRCS=src/os/unix/ngx_solaris_sendfilev_chain.c
DARWIN_DEPS="src/os/unix/ngx_darwin_config.h src/os/unix/ngx_darwin.h"
DARWIN_SRCS=src/os/unix/ngx_darwin_init.c
DARWIN_SENDFILE_SRCS=src/os/unix/ngx_darwin_sendfile_chain.c
WIN32_INCS="$CORE_INCS $EVENT_INCS src/os/win32"
WIN32_DEPS="$CORE_DEPS $EVENT_DEPS \
src/os/win32/ngx_win32_config.h \
src/os/win32/ngx_time.h \
src/os/win32/ngx_types.h \
src/os/win32/ngx_errno.h \
src/os/win32/ngx_alloc.h \
src/os/win32/ngx_files.h \
@ -205,8 +225,7 @@ WIN32_DEPS="$CORE_DEPS $EVENT_DEPS \
src/os/win32/ngx_socket.h \
src/os/win32/ngx_os.h \
src/os/win32/ngx_user.h \
src/os/win32/ngx_gui.h \
src/os/win32/ngx_gui_resources.h \
src/os/win32/ngx_dlopen.h \
src/os/win32/ngx_process_cycle.h"
WIN32_CONFIG=src/os/win32/ngx_win32_config.h
@ -222,213 +241,21 @@ WIN32_SRCS="$CORE_SRCS $EVENT_SRCS \
src/os/win32/ngx_socket.c \
src/os/win32/ngx_wsarecv.c \
src/os/win32/ngx_wsarecv_chain.c \
src/os/win32/ngx_udp_wsarecv.c \
src/os/win32/ngx_wsasend.c \
src/os/win32/ngx_wsasend_chain.c \
src/os/win32/ngx_win32_init.c \
src/os/win32/ngx_user.c \
src/os/win32/ngx_gui.c \
src/os/win32/ngx_dlopen.c \
src/os/win32/ngx_event_log.c \
src/os/win32/ngx_process_cycle.c \
src/event/ngx_event_acceptex.c"
NGX_WIN32_ICONS="src/os/win32/nginx.ico src/os/win32/nginx_tray.ico"
NGX_WIN32_ICONS="src/os/win32/nginx.ico"
NGX_WIN32_RC="src/os/win32/nginx.rc"
# the http modules that have their logging formats
# must be after ngx_http_log_module
HTTP_FILE_CACHE_SRCS=src/http/ngx_http_file_cache.c
HTTP_MODULES="ngx_http_module \
ngx_http_core_module \
ngx_http_log_module \
ngx_http_upstream_module"
HTTP_CACHE_MODULE=ngx_http_cache_module
HTTP_WRITE_FILTER_MODULE="ngx_http_write_filter_module"
HTTP_HEADER_FILTER_MODULE="ngx_http_header_filter_module"
HTTP_POSTPONE_FILTER_MODULE=ngx_http_postpone_filter_module
HTTP_COPY_FILTER_MODULE=ngx_http_copy_filter_module
HTTP_CHUNKED_FILTER_MODULE=ngx_http_chunked_filter_module
HTTP_HEADERS_FILTER_MODULE=ngx_http_headers_filter_module
HTTP_RANGE_HEADER_FILTER_MODULE=ngx_http_range_header_filter_module
HTTP_RANGE_BODY_FILTER_MODULE=ngx_http_range_body_filter_module
HTTP_NOT_MODIFIED_FILTER_MODULE=ngx_http_not_modified_filter_module
HTTP_STATIC_MODULE=ngx_http_static_module
HTTP_INDEX_MODULE=ngx_http_index_module
HTTP_INCS="src/http src/http/modules"
HTTP_DEPS="src/http/ngx_http.h \
src/http/ngx_http_request.h \
src/http/ngx_http_config.h \
src/http/ngx_http_core_module.h \
src/http/ngx_http_cache.h \
src/http/ngx_http_variables.h \
src/http/ngx_http_script.h \
src/http/ngx_http_upstream.h \
src/http/ngx_http_upstream_round_robin.h \
src/http/ngx_http_busy_lock.h"
HTTP_SRCS="src/http/ngx_http.c \
src/http/ngx_http_core_module.c \
src/http/ngx_http_special_response.c \
src/http/ngx_http_request.c \
src/http/ngx_http_parse.c \
src/http/ngx_http_header_filter_module.c \
src/http/ngx_http_write_filter_module.c \
src/http/ngx_http_copy_filter_module.c \
src/http/modules/ngx_http_log_module.c \
src/http/ngx_http_request_body.c \
src/http/ngx_http_variables.c \
src/http/ngx_http_script.c \
src/http/ngx_http_upstream.c \
src/http/ngx_http_upstream_round_robin.c \
src/http/ngx_http_parse_time.c \
src/http/modules/ngx_http_static_module.c \
src/http/modules/ngx_http_index_module.c \
src/http/modules/ngx_http_chunked_filter_module.c \
src/http/modules/ngx_http_range_filter_module.c \
src/http/modules/ngx_http_headers_filter_module.c \
src/http/modules/ngx_http_not_modified_filter_module.c"
# STUB
HTTP_SRCS="$HTTP_SRCS src/http/ngx_http_busy_lock.c"
HTPP_POSTPONE_FILTER_SRCS=src/http/ngx_http_postpone_filter_module.c
HTPP_CACHE_SRCS=src/http/ngx_http_cache.c
HTPP_FILE_CACHE_SRCS=src/http/ngx_http_file_cache.c
HTTP_CHARSET_FILTER_MODULE=ngx_http_charset_filter_module
HTTP_CHARSET_SRCS=src/http/modules/ngx_http_charset_filter_module.c
HTTP_GZIP_FILTER_MODULE=ngx_http_gzip_filter_module
HTTP_GZIP_SRCS=src/http/modules/ngx_http_gzip_filter_module.c
HTTP_SSI_FILTER_MODULE=ngx_http_ssi_filter_module
HTTP_SSI_DEPS=src/http/modules/ngx_http_ssi_filter_module.h
HTTP_SSI_SRCS=src/http/modules/ngx_http_ssi_filter_module.c
HTTP_SUB_FILTER_MODULE=ngx_http_sub_filter_module
HTTP_SUB_SRCS=src/http/modules/ngx_http_sub_filter_module.c
HTTP_USERID_FILTER_MODULE=ngx_http_userid_filter_module
HTTP_USERID_SRCS=src/http/modules/ngx_http_userid_filter_module.c
HTTP_REALIP_MODULE=ngx_http_realip_module
HTTP_REALIP_SRCS=src/http/modules/ngx_http_realip_module.c
HTTP_ADDITION_FILTER_MODULE=ngx_http_addition_filter_module
HTTP_ADDITION_SRCS=src/http/modules/ngx_http_addition_filter_module.c
HTTP_DAV_MODULE=ngx_http_dav_module
HTTP_DAV_SRCS=src/http/modules/ngx_http_dav_module.c
HTTP_ACCESS_MODULE=ngx_http_access_module
HTTP_ACCESS_SRCS=src/http/modules/ngx_http_access_module.c
HTTP_AUTH_BASIC_MODULE=ngx_http_auth_basic_module
HTTP_AUTH_BASIC_SRCS=src/http/modules/ngx_http_auth_basic_module.c
HTTP_AUTOINDEX_MODULE=ngx_http_autoindex_module
HTTP_AUTOINDEX_SRCS=src/http/modules/ngx_http_autoindex_module.c
HTTP_STATUS_MODULE=ngx_http_status_module
HTTP_STATUS_SRCS=src/http/modules/ngx_http_status_module.c
HTTP_GEO_MODULE=ngx_http_geo_module
HTTP_GEO_SRCS=src/http/modules/ngx_http_geo_module.c
HTTP_MAP_MODULE=ngx_http_map_module
HTTP_MAP_SRCS=src/http/modules/ngx_http_map_module.c
HTTP_REFERER_MODULE=ngx_http_referer_module
HTTP_REFERER_SRCS=src/http/modules/ngx_http_referer_module.c
HTTP_REWRITE_MODULE=ngx_http_rewrite_module
HTTP_REWRITE_SRCS=src/http/modules/ngx_http_rewrite_module.c
HTTP_SSL_MODULE=ngx_http_ssl_module
HTTP_SSL_DEPS=src/http/modules/ngx_http_ssl_module.h
HTTP_SSL_SRCS=src/http/modules/ngx_http_ssl_module.c
HTTP_PROXY_MODULE=ngx_http_proxy_module
HTTP_PROXY_SRCS=src/http/modules/ngx_http_proxy_module.c
HTTP_FASTCGI_MODULE=ngx_http_fastcgi_module
HTTP_FASTCGI_SRCS=src/http/modules/ngx_http_fastcgi_module.c
HTTP_PERL_MODULE=ngx_http_perl_module
HTTP_PERL_INCS=src/http/modules/perl
HTTP_PERL_DEPS=src/http/modules/perl/ngx_http_perl_module.h
HTTP_PERL_SRCS=src/http/modules/perl/ngx_http_perl_module.c
HTTP_MEMCACHED_MODULE=ngx_http_memcached_module
HTTP_MEMCACHED_SRCS=src/http/modules/ngx_http_memcached_module.c
HTTP_LIMIT_ZONE_MODULE=ngx_http_limit_zone_module
HTTP_LIMIT_ZONE_SRCS=src/http/modules/ngx_http_limit_zone_module.c
HTTP_EMPTY_GIF_MODULE=ngx_http_empty_gif_module
HTTP_EMPTY_GIF_SRCS=src/http/modules/ngx_http_empty_gif_module.c
HTTP_BROWSER_MODULE=ngx_http_browser_module
HTTP_BROWSER_SRCS=src/http/modules/ngx_http_browser_module.c
HTTP_FLV_MODULE=ngx_http_flv_module
HTTP_FLV_SRCS=src/http/modules/ngx_http_flv_module.c
HTTP_UPSTREAM_IP_HASH_MODULE=ngx_http_upstream_ip_hash_module
HTTP_UPSTREAM_IP_HASH_SRCS=src/http/modules/ngx_http_upstream_ip_hash_module.c
MAIL_INCS="src/mail"
MAIL_DEPS="src/mail/ngx_mail.h"
MAIL_MODULES="ngx_mail_module ngx_mail_core_module"
MAIL_SRCS="src/mail/ngx_mail.c \
src/mail/ngx_mail_core_module.c \
src/mail/ngx_mail_handler.c \
src/mail/ngx_mail_parse.c"
MAIL_SSL_MODULE="ngx_mail_ssl_module"
MAIL_SSL_DEPS="src/mail/ngx_mail_ssl_module.h"
MAIL_SSL_SRCS="src/mail/ngx_mail_ssl_module.c"
MAIL_AUTH_HTTP_MODULE="ngx_mail_auth_http_module"
MAIL_AUTH_HTTP_SRCS="src/mail/ngx_mail_auth_http_module.c"
MAIL_PROXY_MODULE="ngx_mail_proxy_module"
MAIL_PROXY_SRCS="src/mail/ngx_mail_proxy_module.c"
HTTP_HUFF_SRCS="src/http/ngx_http_huff_decode.c
src/http/ngx_http_huff_encode.c"

View File

@ -1,8 +1,8 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
have=NGX_USE_HTTP_FILE_CACHE_UNIQ . auto/have
have=NGX_SUPPRESS_WARN . auto/have
have=NGX_SMP . auto/have

View File

@ -1,153 +1,53 @@
# Copyright (C) Igor Sysoev
### STUB
if [ $USE_THREADS != NO ]; then
cat << END
$0: error: the threads support is broken now.
END
exit 1
fi
###
# Copyright (C) Nginx, Inc.
echo
echo "Configuration summary"
case $USE_THREADS in
rfork) echo " + using rfork()ed threads" ;;
pthreads) echo " + using libpthread threads library" ;;
libthr) echo " + using FreeBSD libthr threads library" ;;
libc_r) echo " + using FreeBSD libc_r threads library" ;;
linuxthreads) echo " + using FreeBSD LinuxThreads port library" ;;
NO) echo " + threads are not used" ;;
*) echo " + using lib$USE_THREADS threads library" ;;
esac
if [ $USE_THREADS = YES ]; then
echo " + using threads"
fi
if [ $USE_PCRE = DISABLED ]; then
echo " + PCRE library is disabled"
else
case $PCRE in
YES) echo " + using system PCRE library" ;;
YES) echo " + using system $PCRE_LIBRARY library" ;;
NONE) echo " + PCRE library is not used" ;;
NO) echo " + PCRE library is not found" ;;
*) echo " + using PCRE library: $PCRE" ;;
*) echo " + using $PCRE_LIBRARY library: $PCRE" ;;
esac
fi
case $OPENSSL in
YES) echo " + using system OpenSSL library" ;;
NONE) echo " + OpenSSL library is not used" ;;
NO) echo " + OpenSSL library is not found" ;;
*) echo " + using OpenSSL library: $OPENSSL" ;;
esac
case $MD5 in
YES)
case $OPENSSL in
NONE|NO) echo " + md5: using system $MD5_LIB library" ;;
*) echo " + md5: using OpenSSL library" ;;
esac
;;
NONE) echo " + md5 library is not used" ;;
NO) echo " + md5 library is not found" ;;
*) echo " + using md5 library: $MD5" ;;
esac
case $SHA1 in
YES)
case $OPENSSL in
NONE|NO) echo " + sha1: using system $SHA1_LIB library" ;;
*) echo " + sha1: using OpenSSL library" ;;
esac
;;
NONE) echo " + sha1 library is not used" ;;
NO) echo " + sha1 library is not found" ;;
*) echo " + using sha1 library: $SHA1" ;;
esac
case $ZLIB in
YES) echo " + using system zlib library" ;;
NONE) echo " + zlib library is not used" ;;
NO) echo " + zlib library is not found" ;;
*) echo " + using zlib library: $ZLIB" ;;
esac
case $NGX_LIBATOMIC in
YES) echo " + using system libatomic_ops library" ;;
NO) ;; # not used
*) echo " + using libatomic_ops library: $NGX_LIBATOMIC" ;;
esac
echo
if [ $HTTP_REWRITE = YES ]; then
if [ $USE_PCRE = DISABLED ]; then
cat << END
$0: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option or you have to enable the PCRE support.
END
exit 1
fi
if [ $PCRE = NONE -o $PCRE = NO ]; then
cat << END
$0: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
END
exit 1
fi
fi
if [ $HTTP_GZIP = YES ]; then
if [ $ZLIB = NONE -o $ZLIB = NO ]; then
cat << END
$0: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
END
exit 1
fi
fi
if [ $HTTP_SSL = YES ]; then
if [ $OPENSSL = NONE -o $OPENSSL = NO ]; then
cat << END
$0: error: the HTTP SSL module requires the OpenSSL library.
You can either do not enable the module, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
END
exit 1
fi
fi
cat << END
nginx path prefix: "$NGX_PREFIX"
nginx binary file: "$NGX_SBIN_PATH"
nginx modules path: "$NGX_MODULES_PATH"
nginx configuration prefix: "$NGX_CONF_PREFIX"
nginx configuration file: "$NGX_CONF_PATH"
nginx pid file: "$NGX_PID_PATH"
END
@ -161,7 +61,22 @@ fi
cat << END
nginx http access log file: "$NGX_HTTP_LOG_PATH"
nginx http client request body temporary files: "$NGX_HTTP_CLIENT_TEMP_PATH"
nginx http proxy temporary files: "$NGX_HTTP_PROXY_TEMP_PATH"
nginx http fastcgi temporary files: "$NGX_HTTP_FASTCGI_TEMP_PATH"
END
if [ $HTTP_PROXY = YES ]; then
echo " nginx http proxy temporary files: \"$NGX_HTTP_PROXY_TEMP_PATH\""
fi
if [ $HTTP_FASTCGI = YES ]; then
echo " nginx http fastcgi temporary files: \"$NGX_HTTP_FASTCGI_TEMP_PATH\""
fi
if [ $HTTP_UWSGI = YES ]; then
echo " nginx http uwsgi temporary files: \"$NGX_HTTP_UWSGI_TEMP_PATH\""
fi
if [ $HTTP_SCGI = YES ]; then
echo " nginx http scgi temporary files: \"$NGX_HTTP_SCGI_TEMP_PATH\""
fi
echo "$NGX_POST_CONF_MSG"

View File

@ -1,70 +1,21 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
case $USE_THREADS in
rfork)
have=NGX_THREADS . auto/have
have=NGX_USE_RFORK . auto/have
CORE_DEPS="$CORE_DEPS $FREEBSD_RFORK_DEPS"
CORE_SRCS="$CORE_SRCS $FREEBSD_RFORK_SRCS"
if [ $USE_THREADS = YES ]; then
case "$NGX_PLATFORM" in
*:i386)
if [ \( $version -gt 500000 -a $version -lt 501000 \) \
-o $version -lt 491000 ]
then
CORE_SRCS="$CORE_SRCS $FREEBSD_RFORK_THREAD_SRCS"
fi
;;
esac
;;
if [ "$NGX_PLATFORM" = win32 ]; then
cat << END
pthreads)
have=NGX_THREADS . auto/have
CORE_SRCS="$CORE_SRCS $PTHREAD_SRCS"
CORE_LIBS="$CORE_LIBS -lpthread"
;;
$0: --with-threads is not supported on Windows
libthr)
have=NGX_THREADS . auto/have
CORE_SRCS="$CORE_SRCS $PTHREAD_SRCS"
CORE_LIBS="$CORE_LIBS -lthr"
;;
END
exit 1
fi
linuxthreads)
have=NGX_THREADS . auto/have
have=NGX_LINUXTHREADS . auto/have
CFLAGS="$CFLAGS -D_THREAD_SAFE"
CFLAGS="$CFLAGS -I /usr/local/include/pthread/linuxthreads"
CORE_SRCS="$CORE_SRCS $PTHREAD_SRCS"
CORE_LIBS="$CORE_LIBS -L /usr/local/lib -llthread -llgcc_r"
;;
libc_r)
case "$NGX_PLATFORM" in
FreeBSD:[34]*)
have=NGX_THREADS . auto/have
CFLAGS="$CFLAGS -pthread"
CORE_SRCS="$CORE_SRCS $PTHREAD_SRCS"
CORE_LIBS="$CORE_LIBS -pthread"
;;
FreeBSD:[56]*)
have=NGX_THREADS . auto/have
CORE_SRCS="$CORE_SRCS $PTHREAD_SRCS"
CORE_LIBS="$CORE_LIBS -lc_r"
;;
esac
;;
NO)
;;
*)
have=NGX_THREADS . auto/have
CORE_SRCS="$CORE_SRCS $PTHREAD_SRCS"
CORE_LIBS="$CORE_LIBS -l$USE_THREADS"
;;
esac
have=NGX_THREADS . auto/have
CORE_DEPS="$CORE_DEPS $THREAD_POOL_DEPS"
CORE_SRCS="$CORE_SRCS $THREAD_POOL_SRCS"
CORE_LIBS="$CORE_LIBS -lpthread"
NGX_LIBPTHREAD="-lpthread"
fi

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
echo $ngx_n "checking for $ngx_type size ...$ngx_c"
@ -19,12 +20,13 @@ cat << END > $NGX_AUTOTEST.c
#include <sys/time.h>
$NGX_INCLUDE_UNISTD_H
#include <signal.h>
#include <stdio.h>
#include <sys/resource.h>
$NGX_INCLUDE_INTTYPES_H
$NGX_INCLUDE_AUTO_CONFIG_H
int main() {
printf("%d", sizeof($ngx_type));
int main(void) {
printf("%d", (int) sizeof($ngx_type));
return 0;
}
@ -43,27 +45,14 @@ if [ -x $NGX_AUTOTEST ]; then
fi
rm -f $NGX_AUTOTEST
case $ngx_size in
4)
if [ "$ngx_type"="long" ]; then
ngx_max_value=2147483647L
else
ngx_max_value=2147483647
fi
ngx_max_value=2147483647
ngx_max_len='(sizeof("-2147483648") - 1)'
;;
8)
if [ "$ngx_type"="long long" ]; then
ngx_max_value=9223372036854775807LL
else
ngx_max_value=9223372036854775807L
fi
ngx_max_value=9223372036854775807LL
ngx_max_len='(sizeof("-9223372036854775808") - 1)'
;;
@ -77,6 +66,11 @@ case $ngx_size in
echo $ngx_test >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
rm -rf $NGX_AUTOTEST*
exit 1
esac
rm -rf $NGX_AUTOTEST*

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
echo $ngx_n "checking for $ngx_type ...$ngx_c"
@ -26,9 +27,9 @@ do
#include <netinet/in.h>
$NGX_INCLUDE_INTTYPES_H
int main() {
int main(void) {
$ngx_try i = 0;
return 0;
return (int) i;
}
END
@ -48,18 +49,23 @@ END
fi
fi
rm -f $NGX_AUTOTEST
if [ $ngx_found = no ]; then
echo $ngx_n " $ngx_try not found$ngx_c"
if [ $ngx_try = $ngx_type ]; then
echo $ngx_n " $ngx_try not found$ngx_c"
else
echo $ngx_n ", $ngx_try not found$ngx_c"
fi
echo "----------" >> $NGX_AUTOCONF_ERR
cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
echo $ngx_test >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
fi
else
rm -rf $NGX_AUTOTEST*
if [ $ngx_found != no ]; then
break
fi
done

View File

@ -1,26 +1,35 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
echo $ngx_n "checking for uintptr_t ...$ngx_c"
echo >> $NGX_ERR
echo "checking for uintptr_t" >> $NGX_ERR
cat << END >> $NGX_AUTOCONF_ERR
----------------------------------------
checking for uintptr_t
END
found=no
cat << END > $NGX_AUTOTEST.c
#include <sys/types.h>
$NGX_INTTYPES_H
$NGX_INCLUDE_INTTYPES_H
int main() {
int main(void) {
uintptr_t i = 0;
return 0;
return (int) i;
}
END
eval "$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT"
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
echo " uintptr_t found"
@ -29,12 +38,13 @@ else
echo $ngx_n " uintptr_t not found" $ngx_c
fi
rm $NGX_AUTOTEST*
rm -rf $NGX_AUTOTEST*
if [ $found = no ]; then
found="uint`expr 8 \* $ngx_ptr_size`_t"
echo ", $found used"
echo "typedef $found uintptr_t;" >> $NGX_AUTO_CONFIG_H
echo "typedef $found uintptr_t;" >> $NGX_AUTO_CONFIG_H
echo "typedef $found intptr_t;" | sed -e 's/u//g' >> $NGX_AUTO_CONFIG_H
fi

View File

@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
cat << END >> $NGX_AUTO_CONFIG_H

869
auto/unix Executable file → Normal file
View File

@ -1,5 +1,588 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
NGX_USER=${NGX_USER:-nobody}
if [ -z "$NGX_GROUP" ]; then
if [ $NGX_USER = nobody ]; then
if grep nobody /etc/group 2>&1 >/dev/null; then
echo "checking for nobody group ... found"
NGX_GROUP=nobody
else
echo "checking for nobody group ... not found"
if grep nogroup /etc/group 2>&1 >/dev/null; then
echo "checking for nogroup group ... found"
NGX_GROUP=nogroup
else
echo "checking for nogroup group ... not found"
NGX_GROUP=nobody
fi
fi
else
NGX_GROUP=$NGX_USER
fi
fi
ngx_feature="poll()"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <poll.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int n; struct pollfd pl;
pl.fd = 0;
pl.events = 0;
pl.revents = 0;
n = poll(&pl, 1, 0);
if (n == -1) return 1"
. auto/feature
if [ $ngx_found = no ]; then
EVENT_POLL=NONE
fi
ngx_feature="/dev/poll"
ngx_feature_name="NGX_HAVE_DEVPOLL"
ngx_feature_run=no
ngx_feature_incs="#include <sys/devpoll.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int n, dp; struct dvpoll dvp;
dp = 0;
dvp.dp_fds = NULL;
dvp.dp_nfds = 0;
dvp.dp_timeout = 0;
n = ioctl(dp, DP_POLL, &dvp);
if (n == -1) return 1"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
EVENT_FOUND=YES
fi
if test -z "$NGX_KQUEUE_CHECKED"; then
ngx_feature="kqueue"
ngx_feature_name="NGX_HAVE_KQUEUE"
ngx_feature_run=no
ngx_feature_incs="#include <sys/event.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="(void) kqueue()"
. auto/feature
if [ $ngx_found = yes ]; then
have=NGX_HAVE_CLEAR_EVENT . auto/have
EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
EVENT_FOUND=YES
ngx_feature="kqueue's NOTE_LOWAT"
ngx_feature_name="NGX_HAVE_LOWAT_EVENT"
ngx_feature_run=no
ngx_feature_incs="#include <sys/event.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct kevent kev;
kev.fflags = NOTE_LOWAT;
(void) kev"
. auto/feature
ngx_feature="kqueue's EVFILT_TIMER"
ngx_feature_name="NGX_HAVE_TIMER_EVENT"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/event.h>
#include <sys/time.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int kq;
struct kevent kev;
struct timespec ts;
if ((kq = kqueue()) == -1) return 1;
kev.ident = 0;
kev.filter = EVFILT_TIMER;
kev.flags = EV_ADD|EV_ENABLE;
kev.fflags = 0;
kev.data = 1000;
kev.udata = 0;
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (kevent(kq, &kev, 1, &kev, 1, &ts) == -1) return 1;
if (kev.flags & EV_ERROR) return 1;"
. auto/feature
fi
fi
if [ "$NGX_SYSTEM" = "NetBSD" ]; then
# NetBSD 2.0 incompatibly defines kevent.udata as "intptr_t"
cat << END >> $NGX_AUTO_CONFIG_H
#define NGX_KQUEUE_UDATA_T
END
else
cat << END >> $NGX_AUTO_CONFIG_H
#define NGX_KQUEUE_UDATA_T (void *)
END
fi
ngx_feature="crypt()"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="crypt(\"test\", \"salt\");"
. auto/feature
if [ $ngx_found = no ]; then
ngx_feature="crypt() in libcrypt"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=-lcrypt
. auto/feature
if [ $ngx_found = yes ]; then
CRYPT_LIB="-lcrypt"
fi
fi
ngx_feature="F_READAHEAD"
ngx_feature_name="NGX_HAVE_F_READAHEAD"
ngx_feature_run=no
ngx_feature_incs="#include <fcntl.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="fcntl(0, F_READAHEAD, 1);"
. auto/feature
ngx_feature="posix_fadvise()"
ngx_feature_name="NGX_HAVE_POSIX_FADVISE"
ngx_feature_run=no
ngx_feature_incs="#include <fcntl.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="posix_fadvise(0, 0, 0, POSIX_FADV_SEQUENTIAL);"
. auto/feature
ngx_feature="O_DIRECT"
ngx_feature_name="NGX_HAVE_O_DIRECT"
ngx_feature_run=no
ngx_feature_incs="#include <fcntl.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="fcntl(0, F_SETFL, O_DIRECT);"
. auto/feature
if [ $ngx_found = yes -a "$NGX_SYSTEM" = "Linux" ]; then
have=NGX_HAVE_ALIGNED_DIRECTIO . auto/have
fi
ngx_feature="F_NOCACHE"
ngx_feature_name="NGX_HAVE_F_NOCACHE"
ngx_feature_run=no
ngx_feature_incs="#include <fcntl.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="fcntl(0, F_NOCACHE, 1);"
. auto/feature
ngx_feature="directio()"
ngx_feature_name="NGX_HAVE_DIRECTIO"
ngx_feature_run=no
ngx_feature_incs="#include <sys/types.h>
#include <sys/fcntl.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="directio(0, DIRECTIO_ON);"
. auto/feature
ngx_feature="statfs()"
ngx_feature_name="NGX_HAVE_STATFS"
ngx_feature_run=no
ngx_feature_incs="$NGX_INCLUDE_SYS_PARAM_H
$NGX_INCLUDE_SYS_MOUNT_H
$NGX_INCLUDE_SYS_VFS_H"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct statfs fs;
statfs(\".\", &fs);"
. auto/feature
ngx_feature="statvfs()"
ngx_feature_name="NGX_HAVE_STATVFS"
ngx_feature_run=no
ngx_feature_incs="#include <sys/types.h>
#include <sys/statvfs.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct statvfs fs;
statvfs(\".\", &fs);"
. auto/feature
ngx_feature="dlopen()"
ngx_feature_name="NGX_HAVE_DLOPEN"
ngx_feature_run=no
ngx_feature_incs="#include <dlfcn.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="dlopen(NULL, RTLD_NOW | RTLD_GLOBAL); dlsym(NULL, \"\")"
. auto/feature
if [ $ngx_found = no ]; then
ngx_feature="dlopen() in libdl"
ngx_feature_libs="-ldl"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS -ldl"
NGX_LIBDL="-ldl"
fi
fi
ngx_feature="sched_yield()"
ngx_feature_name="NGX_HAVE_SCHED_YIELD"
ngx_feature_run=no
ngx_feature_incs="#include <sched.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="sched_yield()"
. auto/feature
if [ $ngx_found = no ]; then
ngx_feature="sched_yield() in librt"
ngx_feature_libs="-lrt"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS -lrt"
fi
fi
ngx_feature="sched_setaffinity()"
ngx_feature_name="NGX_HAVE_SCHED_SETAFFINITY"
ngx_feature_run=no
ngx_feature_incs="#include <sched.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="cpu_set_t mask;
CPU_ZERO(&mask);
sched_setaffinity(0, sizeof(cpu_set_t), &mask)"
. auto/feature
ngx_feature="SO_SETFIB"
ngx_feature_name="NGX_HAVE_SETFIB"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_SETFIB, NULL, 0)"
. auto/feature
ngx_feature="SO_REUSEPORT"
ngx_feature_name="NGX_HAVE_REUSEPORT"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_REUSEPORT, NULL, 0)"
. auto/feature
ngx_feature="SO_ACCEPTFILTER"
ngx_feature_name="NGX_HAVE_DEFERRED_ACCEPT"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_ACCEPTFILTER, NULL, 0)"
. auto/feature
# OpenBSD bind to any address for transparent proxying
ngx_feature="SO_BINDANY"
ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_BINDANY, NULL, 0)"
. auto/feature
# Linux transparent proxying
ngx_feature="IP_TRANSPARENT"
ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_TRANSPARENT, NULL, 0)"
. auto/feature
# FreeBSD bind to any address for transparent proxying
ngx_feature="IP_BINDANY"
ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_BINDANY, NULL, 0)"
. auto/feature
# Linux IP_BIND_ADDRESS_NO_PORT
ngx_feature="IP_BIND_ADDRESS_NO_PORT"
ngx_feature_name="NGX_HAVE_IP_BIND_ADDRESS_NO_PORT"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_BIND_ADDRESS_NO_PORT, NULL, 0)"
. auto/feature
# BSD way to get IPv4 datagram destination address
ngx_feature="IP_RECVDSTADDR"
ngx_feature_name="NGX_HAVE_IP_RECVDSTADDR"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_RECVDSTADDR, NULL, 0)"
. auto/feature
# BSD way to set IPv4 datagram source address
ngx_feature="IP_SENDSRCADDR"
ngx_feature_name="NGX_HAVE_IP_SENDSRCADDR"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_SENDSRCADDR, NULL, 0)"
. auto/feature
# Linux way to get IPv4 datagram destination address
ngx_feature="IP_PKTINFO"
ngx_feature_name="NGX_HAVE_IP_PKTINFO"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct in_pktinfo pkt;
pkt.ipi_spec_dst.s_addr = INADDR_ANY;
(void) pkt;
setsockopt(0, IPPROTO_IP, IP_PKTINFO, NULL, 0)"
. auto/feature
# RFC 3542 way to get IPv6 datagram destination address
ngx_feature="IPV6_RECVPKTINFO"
ngx_feature_name="NGX_HAVE_IPV6_RECVPKTINFO"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, IPPROTO_IPV6, IPV6_RECVPKTINFO, NULL, 0)"
. auto/feature
ngx_feature="TCP_DEFER_ACCEPT"
ngx_feature_name="NGX_HAVE_DEFERRED_ACCEPT"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_DEFER_ACCEPT, NULL, 0)"
. auto/feature
ngx_feature="TCP_KEEPIDLE"
ngx_feature_name="NGX_HAVE_KEEPALIVE_TUNABLE"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_KEEPIDLE, NULL, 0);
setsockopt(0, IPPROTO_TCP, TCP_KEEPINTVL, NULL, 0);
setsockopt(0, IPPROTO_TCP, TCP_KEEPCNT, NULL, 0)"
. auto/feature
ngx_feature="TCP_FASTOPEN"
ngx_feature_name="NGX_HAVE_TCP_FASTOPEN"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_FASTOPEN, NULL, 0)"
. auto/feature
ngx_feature="TCP_INFO"
ngx_feature_name="NGX_HAVE_TCP_INFO"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="socklen_t optlen = sizeof(struct tcp_info);
struct tcp_info ti;
ti.tcpi_rtt = 0;
ti.tcpi_rttvar = 0;
ti.tcpi_snd_cwnd = 0;
ti.tcpi_rcv_space = 0;
getsockopt(0, IPPROTO_TCP, TCP_INFO, &ti, &optlen)"
. auto/feature
ngx_feature="accept4()"
ngx_feature_name="NGX_HAVE_ACCEPT4"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="accept4(0, NULL, NULL, SOCK_NONBLOCK)"
. auto/feature
if [ $NGX_FILE_AIO = YES ]; then
ngx_feature="kqueue AIO support"
ngx_feature_name="NGX_HAVE_FILE_AIO"
ngx_feature_run=no
ngx_feature_incs="#include <aio.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct aiocb iocb;
iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
(void) aio_read(&iocb)"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_SRCS="$CORE_SRCS $FILE_AIO_SRCS"
fi
if [ $ngx_found = no ]; then
ngx_feature="Linux AIO support"
ngx_feature_name="NGX_HAVE_FILE_AIO"
ngx_feature_run=no
ngx_feature_incs="#include <linux/aio_abi.h>
#include <sys/eventfd.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct iocb iocb;
iocb.aio_lio_opcode = IOCB_CMD_PREAD;
iocb.aio_flags = IOCB_FLAG_RESFD;
iocb.aio_resfd = -1;
(void) iocb;
(void) eventfd(0, 0)"
. auto/feature
if [ $ngx_found = yes ]; then
have=NGX_HAVE_EVENTFD . auto/have
have=NGX_HAVE_SYS_EVENTFD_H . auto/have
CORE_SRCS="$CORE_SRCS $LINUX_AIO_SRCS"
fi
fi
if [ $ngx_found = no ]; then
ngx_feature="Linux AIO support (SYS_eventfd)"
ngx_feature_incs="#include <linux/aio_abi.h>
#include <sys/syscall.h>"
ngx_feature_test="struct iocb iocb;
iocb.aio_lio_opcode = IOCB_CMD_PREAD;
iocb.aio_flags = IOCB_FLAG_RESFD;
iocb.aio_resfd = -1;
(void) iocb;
(void) SYS_eventfd"
. auto/feature
if [ $ngx_found = yes ]; then
have=NGX_HAVE_EVENTFD . auto/have
CORE_SRCS="$CORE_SRCS $LINUX_AIO_SRCS"
fi
fi
if [ $ngx_found = no ]; then
cat << END
$0: no supported file AIO was found
Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only
END
exit 1
fi
fi
have=NGX_HAVE_UNIX_DOMAIN . auto/have
@ -21,15 +604,9 @@ ngx_param=NGX_PTR_SIZE; ngx_value=$ngx_size; . auto/types/value
# POSIX types
case "$NGX_AUTO_CONFIG_H" in
/*)
NGX_INCLUDE_AUTO_CONFIG_H="#include \"$NGX_AUTO_CONFIG_H\""
;;
*)
NGX_INCLUDE_AUTO_CONFIG_H="#include \"../$NGX_AUTO_CONFIG_H\""
;;
esac
NGX_INCLUDE_AUTO_CONFIG_H="#include \"ngx_auto_config.h\""
ngx_type="uint32_t"; ngx_types="u_int32_t"; . auto/types/typedef
ngx_type="uint64_t"; ngx_types="u_int64_t"; . auto/types/typedef
ngx_type="sig_atomic_t"; ngx_types="int"; . auto/types/typedef
@ -38,7 +615,7 @@ ngx_param=NGX_SIG_ATOMIC_T_SIZE; ngx_value=$ngx_size; . auto/types/value
ngx_type="socklen_t"; ngx_types="int"; . auto/types/typedef
ngx_type="in_addr_t"; ngx_types="uint32_t"; . auto/types/typedef
ngx_type="in_addr_t"; ngx_types="uint32_t u_int32_t"; . auto/types/typedef
ngx_type="in_port_t"; ngx_types="u_short"; . auto/types/typedef
@ -46,7 +623,7 @@ ngx_type="rlim_t"; ngx_types="int"; . auto/types/typedef
. auto/types/uintptr_t
. auto/endianess
. auto/endianness
ngx_type="size_t"; . auto/types/sizeof
ngx_param=NGX_MAX_SIZE_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
@ -59,15 +636,30 @@ ngx_param=NGX_OFF_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
ngx_type="time_t"; . auto/types/sizeof
ngx_param=NGX_TIME_T_SIZE; ngx_value=$ngx_size; . auto/types/value
ngx_param=NGX_TIME_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
ngx_param=NGX_MAX_TIME_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
# syscalls, libc calls and some features
ngx_feature="AF_INET6"
ngx_feature_name="NGX_HAVE_INET6"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct sockaddr_in6 sin6;
sin6.sin6_family = AF_INET6;
(void) sin6"
. auto/feature
ngx_feature="setproctitle()"
ngx_feature_name="NGX_HAVE_SETPROCTITLE"
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_incs="#include <stdlib.h>"
ngx_feature_path=
ngx_feature_libs=$NGX_SETPROCTITLE_LIB
ngx_feature_test="setproctitle(\"test\");"
@ -80,7 +672,8 @@ ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0)"
ngx_feature_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0);
if (n == -1) return 1"
. auto/feature
@ -90,34 +683,69 @@ ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0)"
ngx_feature_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0);
if (n == -1) return 1"
. auto/feature
ngx_feature="strerror_r()"
ngx_feature_name="NGX_HAVE_STRERROR_R"
ngx_feature_run=yes
ngx_feature_incs="#include <string.h>"
# pwritev() was introduced in FreeBSD 6 and Linux 2.6.30, glibc 2.10
ngx_feature="pwritev()"
ngx_feature_name="NGX_HAVE_PWRITEV"
ngx_feature_run=no
ngx_feature_incs='#include <sys/uio.h>'
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[1024]; long n; n = strerror_r(1, buf, 1024);
if (n < 0 || n > 1024) return 1;"
ngx_feature_test="char buf[1]; struct iovec vec[1]; ssize_t n;
vec[0].iov_base = buf;
vec[0].iov_len = 1;
n = pwritev(1, vec, 1, 0);
if (n == -1) return 1"
. auto/feature
# GNU style strerror_r() returns not length, but pointer
# strerrordesc_np(), introduced in glibc 2.32
ngx_feature="gnu style strerror_r()"
ngx_feature_name="NGX_HAVE_GNU_STRERROR_R"
ngx_feature_run=yes
ngx_feature_incs="#include <string.h>"
ngx_feature="strerrordesc_np()"
ngx_feature_name="NGX_HAVE_STRERRORDESC_NP"
ngx_feature_run=no
ngx_feature_incs='#include <string.h>'
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="char buf[1024]; long n; n = strerror_r(1, buf, 1024);
if (n >= 0 && n < 1024) return 1;"
ngx_feature_test="char *p; p = strerrordesc_np(0);
if (p == NULL) return 1"
. auto/feature
if [ $ngx_found = no ]; then
ngx_feature="sys_nerr"
ngx_feature_name="NGX_SYS_NERR"
ngx_feature_run=value
ngx_feature_incs='#include <errno.h>
#include <stdio.h>'
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test='printf("%d", sys_nerr);'
. auto/feature
fi
if [ $ngx_found = no ]; then
# Cygiwn defines _sys_nerr
ngx_feature="_sys_nerr"
ngx_feature_name="NGX_SYS_NERR"
ngx_feature_run=value
ngx_feature_incs='#include <errno.h>
#include <stdio.h>'
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test='printf("%d", _sys_nerr);'
. auto/feature
fi
ngx_feature="localtime_r()"
ngx_feature_name="NGX_HAVE_LOCALTIME_R"
ngx_feature_run=no
@ -128,33 +756,50 @@ ngx_feature_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
. auto/feature
ngx_feature="clock_gettime(CLOCK_MONOTONIC)"
ngx_feature_name="NGX_HAVE_CLOCK_MONOTONIC"
ngx_feature_run=no
ngx_feature_incs="#include <time.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts)"
. auto/feature
if [ $ngx_found = no ]; then
# Linux before glibc 2.17, notably CentOS 6
ngx_feature="clock_gettime(CLOCK_MONOTONIC) in librt"
ngx_feature_libs="-lrt"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS -lrt"
fi
fi
ngx_feature="posix_memalign()"
ngx_feature_name="NGX_HAVE_POSIX_MEMALIGN"
ngx_feature_run=no
ngx_feature_incs="#include <stdlib.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="void *p; int n; n = posix_memalign(&p, 4096, 4096)"
ngx_feature_test="void *p; int n; n = posix_memalign(&p, 4096, 4096);
if (n != 0) return 1"
. auto/feature
ngx_feature="memalign()"
ngx_feature_name="NGX_HAVE_MEMALIGN"
ngx_feature_run=no
ngx_feature_incs="#include <stdlib.h>"
ngx_feature_incs="#include <stdlib.h>
#include <malloc.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="void *p; p = memalign(4096, 4096)"
. auto/feature
ngx_feature="sched_yield()"
ngx_feature_name="NGX_HAVE_SCHED_YIELD"
ngx_feature_run=no
ngx_feature_incs="#include <sched.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="sched_yield()"
ngx_feature_test="void *p; p = memalign(4096, 4096);
if (p == NULL) return 1"
. auto/feature
@ -175,8 +820,8 @@ ngx_feature='mmap("/dev/zero", MAP_SHARED)'
ngx_feature_name="NGX_HAVE_MAP_DEVZERO"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>"
#include <sys/stat.h>
#include <fcntl.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test='void *p; int fd;
@ -190,7 +835,7 @@ ngx_feature="System V shared memory"
ngx_feature_name="NGX_HAVE_SYSVSHM"
ngx_feature_run=yes
ngx_feature_incs="#include <sys/ipc.h>
#include <sys/shm.h>"
#include <sys/shm.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int id;
@ -200,13 +845,54 @@ ngx_feature_test="int id;
. auto/feature
ngx_feature="POSIX semaphores"
ngx_feature_name="NGX_HAVE_POSIX_SEM"
ngx_feature_run=yes
ngx_feature_incs="#include <semaphore.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="sem_t sem;
if (sem_init(&sem, 1, 0) == -1) return 1;
sem_destroy(&sem);"
. auto/feature
if [ $ngx_found = no ]; then
# Linux has POSIX semaphores in libpthread
ngx_feature="POSIX semaphores in libpthread"
ngx_feature_libs=-lpthread
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS -lpthread"
NGX_LIBPTHREAD="-lpthread"
fi
fi
if [ $ngx_found = no ]; then
# Solaris has POSIX semaphores in librt
ngx_feature="POSIX semaphores in librt"
ngx_feature_libs=-lrt
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS -lrt"
fi
fi
ngx_feature="struct msghdr.msg_control"
ngx_feature_name="NGX_HAVE_MSGHDR_MSG_CONTROL"
ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>"
ngx_feature_incs="#include <sys/socket.h>
#include <stdio.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct msghdr msg; msg.msg_control = NULL"
ngx_feature_test="struct msghdr msg;
printf(\"%d\", (int) sizeof(msg.msg_control))"
. auto/feature
@ -214,18 +900,105 @@ ngx_feature="ioctl(FIONBIO)"
ngx_feature_name="NGX_HAVE_FIONBIO"
ngx_feature_run=no
ngx_feature_incs="#include <sys/ioctl.h>
$NGX_INCLUDE_SYS_FILIO_H"
#include <stdio.h>
$NGX_INCLUDE_SYS_FILIO_H"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int i; i = FIONBIO"
ngx_feature_test="int i = FIONBIO; printf(\"%d\", i)"
. auto/feature
ngx_feature="ioctl(FIONREAD)"
ngx_feature_name="NGX_HAVE_FIONREAD"
ngx_feature_run=no
ngx_feature_incs="#include <sys/ioctl.h>
#include <stdio.h>
$NGX_INCLUDE_SYS_FILIO_H"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="int i = FIONREAD; printf(\"%d\", i)"
. auto/feature
ngx_feature="struct tm.tm_gmtoff"
ngx_feature_name="NGX_HAVE_GMTOFF"
ngx_feature_run=no
ngx_feature_incs="#include <time.h>"
ngx_feature_incs="#include <time.h>
#include <stdio.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct tm tm; tm.tm_gmtoff = 0"
ngx_feature_test="struct tm tm; tm.tm_gmtoff = 0;
printf(\"%d\", (int) tm.tm_gmtoff)"
. auto/feature
ngx_feature="struct dirent.d_namlen"
ngx_feature_name="NGX_HAVE_D_NAMLEN"
ngx_feature_run=no
ngx_feature_incs="#include <dirent.h>
#include <stdio.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct dirent dir; dir.d_namlen = 0;
printf(\"%d\", (int) dir.d_namlen)"
. auto/feature
ngx_feature="struct dirent.d_type"
ngx_feature_name="NGX_HAVE_D_TYPE"
ngx_feature_run=no
ngx_feature_incs="#include <dirent.h>
#include <stdio.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct dirent dir; dir.d_type = DT_REG;
printf(\"%d\", (int) dir.d_type)"
. auto/feature
ngx_feature="sysconf(_SC_NPROCESSORS_ONLN)"
ngx_feature_name="NGX_HAVE_SC_NPROCESSORS_ONLN"
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="sysconf(_SC_NPROCESSORS_ONLN)"
. auto/feature
ngx_feature="sysconf(_SC_LEVEL1_DCACHE_LINESIZE)"
ngx_feature_name="NGX_HAVE_LEVEL1_DCACHE_LINESIZE"
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="sysconf(_SC_LEVEL1_DCACHE_LINESIZE)"
. auto/feature
ngx_feature="openat(), fstatat()"
ngx_feature_name="NGX_HAVE_OPENAT"
ngx_feature_run=no
ngx_feature_incs="#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct stat sb;
openat(AT_FDCWD, \".\", O_RDONLY|O_NOFOLLOW);
fstatat(AT_FDCWD, \".\", &sb, AT_SYMLINK_NOFOLLOW);"
. auto/feature
ngx_feature="getaddrinfo()"
ngx_feature_name="NGX_HAVE_GETADDRINFO"
ngx_feature_run=no
ngx_feature_incs="#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test='struct addrinfo *res;
if (getaddrinfo("localhost", NULL, NULL, &res) != 0) return 1;
freeaddrinfo(res)'
. auto/feature

26
conf/fastcgi.conf Normal file
View File

@ -0,0 +1,26 @@
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

View File

@ -9,9 +9,11 @@ fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;

View File

@ -1,69 +1,99 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml rss;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
application/atom+xml atom;
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/avif avif;
image/png png;
image/svg+xml svg svgz;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/webp webp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.wap.xhtml+xml xhtml;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/zip zip;
font/woff woff;
font/woff2 woff2;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.oasis.opendocument.graphics odg;
application/vnd.oasis.opendocument.presentation odp;
application/vnd.oasis.opendocument.spreadsheet ods;
application/vnd.oasis.opendocument.text odt;
application/vnd.openxmlformats-officedocument.presentationml.presentation
pptx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xlsx;
application/vnd.openxmlformats-officedocument.wordprocessingml.document
docx;
application/vnd.wap.wmlc wmlc;
application/wasm wasm;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/x-realaudio ra;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
video/3gpp 3gpp 3gp;
video/mpeg mpeg mpg;
video/quicktime mov;
video/x-flv flv;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}

View File

@ -15,11 +15,11 @@ events {
http {
include conf/mime.types;
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] $request '
# '"$status" $body_bytes_sent "$http_referer" '
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
@ -63,10 +63,11 @@ http {
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include conf/fastcgi_params;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
@ -95,18 +96,17 @@ http {
# HTTPS server
#
#server {
# listen 443;
# listen 443 ssl;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;

17
conf/scgi_params Normal file
View File

@ -0,0 +1,17 @@
scgi_param REQUEST_METHOD $request_method;
scgi_param REQUEST_URI $request_uri;
scgi_param QUERY_STRING $query_string;
scgi_param CONTENT_TYPE $content_type;
scgi_param DOCUMENT_URI $document_uri;
scgi_param DOCUMENT_ROOT $document_root;
scgi_param SCGI 1;
scgi_param SERVER_PROTOCOL $server_protocol;
scgi_param REQUEST_SCHEME $scheme;
scgi_param HTTPS $https if_not_empty;
scgi_param REMOTE_ADDR $remote_addr;
scgi_param REMOTE_PORT $remote_port;
scgi_param SERVER_PORT $server_port;
scgi_param SERVER_NAME $server_name;

17
conf/uwsgi_params Normal file
View File

@ -0,0 +1,17 @@
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REQUEST_SCHEME $scheme;
uwsgi_param HTTPS $https if_not_empty;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;

View File

@ -13,3 +13,9 @@ unicode2nginx by Maxim Dounin
configuration file format.
Two generated full maps for windows-1251 and koi8-r.
vim by Evan Miller
Syntax highlighting of nginx configuration for vim, to be
placed into ~/.vim/.

View File

@ -10,7 +10,7 @@
# Needs perl 5.6 or later.
# Written by Maxim Dounin, mdounin@rambler-co.ru
# Written by Maxim Dounin, mdounin@mdounin.ru
###############################################################################
@ -33,7 +33,10 @@ while (<>) {
# Produce UTF-8 sequence from character code;
my $un_utf8 = join('', map { sprintf("%02X", $_) } unpack("C*", pack("U", hex($un_code))));
my $un_utf8 = join('',
map { sprintf("%02X", $_) }
unpack("U0C*", pack("U", hex($un_code)))
);
print " $cs_code $un_utf8 ; $un_name\n";

View File

@ -0,0 +1,4 @@
au BufRead,BufNewFile *.nginx set ft=nginx
au BufRead,BufNewFile */etc/nginx/* set ft=nginx
au BufRead,BufNewFile */usr/local/nginx/conf/* set ft=nginx
au BufRead,BufNewFile nginx.conf set ft=nginx

View File

@ -0,0 +1 @@
setlocal commentstring=#\ %s

View File

@ -0,0 +1,11 @@
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal indentexpr=
" cindent actually works for nginx' simple file structure
setlocal cindent
" Just make sure that the comments are not reset as defs would be.
setlocal cinkeys-=0#

2010
contrib/vim/syntax/nginx.vim Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +1,41 @@
VER= $(shell grep 'define NGINX_VERSION' src/core/nginx.h \
| sed -e 's/^.*\"\(.*\)\"/\1/')
| sed -e 's/^.*"\(.*\)".*/\1/')
NGINX= nginx-$(VER)
TEMP= tmp
CP= $(HOME)/java
XSLS?= xslscript.pl
define XSLScript
javavm -cp $(CP)/xsls/saxon.jar:$(CP)/xsls/xsls.jar \
com.pault.StyleSheet \
-x com.pault.XX -y com.pault.XX \
$(1) docs/xsls/dump.xsls \
| awk 'BEGIN{e=0}/^\n*$$/{e=1;next}{if(e){print"";e=0};print}' > $(2)
if [ ! -s $(2) ]; then rm $(2); fi; test -s $(2)
endef
define XSLT
xsltproc $(shell echo $4 \
| sed -e "s/\([^= ]*\)=\([^= ]*\)/--param \1 \"'\2'\"/g") \
$3 $1 \
> $(HTML)/$(strip $(2))
endef
all: changes
changes: $(TEMP)/$(NGINX)/CHANGES.ru \
$(TEMP)/$(NGINX)/CHANGES
$(TEMP)/$(NGINX)/CHANGES.ru: docs/xml/nginx/changes.xml \
$(TEMP)/$(NGINX)/CHANGES.ru: docs/dtd/changes.dtd \
docs/xml/nginx/changes.xml \
docs/xml/change_log_conf.xml \
docs/xslt/changes.xslt
test -d $(TEMP)/$(NGINX) || mkdir -p $(TEMP)/$(NGINX)
mkdir -p $(TEMP)/$(NGINX)
xsltproc --param lang "'ru'" \
-o $(TEMP)/$(NGINX)/CHANGES.ru \
docs/xslt/changes.xslt docs/xml/nginx/changes.xml
xmllint --noout --valid docs/xml/nginx/changes.xml
xsltproc --stringparam lang ru \
-o $@ docs/xslt/changes.xslt docs/xml/nginx/changes.xml
$(TEMP)/$(NGINX)/CHANGES: docs/xml/nginx/changes.xml \
$(TEMP)/$(NGINX)/CHANGES: docs/dtd/changes.dtd \
docs/xml/nginx/changes.xml \
docs/xml/change_log_conf.xml \
docs/xslt/changes.xslt
test -d $(TEMP)/$(NGINX) || mkdir - p$(TEMP)/$(NGINX)
mkdir -p $(TEMP)/$(NGINX)
xsltproc --param lang "'en'" \
-o $(TEMP)/$(NGINX)/CHANGES \
docs/xslt/changes.xslt docs/xml/nginx/changes.xml
xmllint --noout --valid docs/xml/nginx/changes.xml
xsltproc --stringparam lang en \
-o $@ docs/xslt/changes.xslt docs/xml/nginx/changes.xml
docs/xslt/changes.xslt: docs/xsls/changes.xsls
$(call XSLScript, docs/xsls/changes.xsls, $@)
$(XSLS) -o $@ $<

View File

@ -12,10 +12,10 @@
>
<!ELEMENT change (para)* >
<!ATTLIST change type (bugfix | feature | change | workaround) #IMPLIED >
<!ATTLIST change type (bugfix | feature | change | security | workaround) #IMPLIED >
<!ELEMENT para (#PCDATA | at | br | nobr)* >
<!ATTLIST para lang (ru | en) #IMPLIED >
<!ATTLIST para lang (ru | en) #REQUIRED >
<!ELEMENT at EMPTY >
<!ELEMENT br EMPTY >

View File

@ -1,18 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>The page is temporarily unavailable</title>
<title>Error</title>
<style>
body { font-family: Tahoma, Verdana, Arial, sans-serif; }
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body bgcolor="white" text="black">
<table width="100%" height="100%">
<tr>
<td align="center" valign="middle">
The page you are looking for is temporarily unavailable.<br/>
Please try again later.
</td>
</tr>
</table>
<body>
<h1>An error occurred.</h1>
<p>Sorry, the page you are looking for is currently unavailable.<br/>
Please try again later.</p>
<p>If you are the system administrator of this resource then you should check
the error log for details.</p>
<p><em>Faithfully yours, nginx.</em></p>
</body>
</html>

View File

@ -1,8 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body bgcolor="white" text="black">
<center><h1>Welcome to nginx!</h1></center>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>

214
docs/man/nginx.8 Normal file
View File

@ -0,0 +1,214 @@
.\"
.\" Copyright (C) 2010, 2019 Sergey A. Osokin
.\" Copyright (C) Nginx, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"
.Dd November 5, 2020
.Dt NGINX 8
.Os
.Sh NAME
.Nm nginx
.Nd "HTTP and reverse proxy server, mail proxy server"
.Sh SYNOPSIS
.Nm
.Op Fl ?hqTtVv
.Op Fl c Ar file
.Op Fl e Ar file
.Op Fl g Ar directives
.Op Fl p Ar prefix
.Op Fl s Ar signal
.Sh DESCRIPTION
.Nm
(pronounced
.Dq engine x )
is an HTTP and reverse proxy server, a mail proxy server, and a generic
TCP/UDP proxy server.
It is known for its high performance, stability, rich feature set, simple
configuration, and low resource consumption.
.Pp
The options are as follows:
.Bl -tag -width ".Fl d Ar directives"
.It Fl ?\& , h
Print help.
.It Fl c Ar file
Use an alternative configuration
.Ar file .
.It Fl e Ar file
Use an alternative error log
.Ar file .
Special value
.Cm stderr
indicates that the standard error output should be used.
.It Fl g Ar directives
Set global configuration directives.
See
.Sx EXAMPLES
for details.
.It Fl p Ar prefix
Set the prefix path.
The default value is
.Pa %%PREFIX%% .
.It Fl q
Suppress non-error messages during configuration testing.
.It Fl s Ar signal
Send a signal to the master process.
The argument
.Ar signal
can be one of:
.Cm stop , quit , reopen , reload .
The following table shows the corresponding system signals:
.Pp
.Bl -tag -width ".Cm reopen" -compact
.It Cm stop
.Dv SIGTERM
.It Cm quit
.Dv SIGQUIT
.It Cm reopen
.Dv SIGUSR1
.It Cm reload
.Dv SIGHUP
.El
.It Fl T
Same as
.Fl t ,
but additionally dump configuration files to standard output.
.It Fl t
Do not run, just test the configuration file.
.Nm
checks the configuration file syntax and then tries to open files
referenced in the configuration file.
.It Fl V
Print the
.Nm
version, compiler version, and
.Pa configure
script parameters.
.It Fl v
Print the
.Nm
version.
.El
.Sh SIGNALS
The master process of
.Nm
can handle the following signals:
.Pp
.Bl -tag -width ".Dv SIGINT , SIGTERM" -compact
.It Dv SIGINT , SIGTERM
Shut down quickly.
.It Dv SIGHUP
Reload configuration, start the new worker process with a new
configuration, and gracefully shut down old worker processes.
.It Dv SIGQUIT
Shut down gracefully.
.It Dv SIGUSR1
Reopen log files.
.It Dv SIGUSR2
Upgrade the
.Nm
executable on the fly.
.It Dv SIGWINCH
Shut down worker processes gracefully.
.El
.Pp
While there is no need to explicitly control worker processes normally,
they support some signals too:
.Pp
.Bl -tag -width ".Dv SIGINT , SIGTERM" -compact
.It Dv SIGTERM
Shut down quickly.
.It Dv SIGQUIT
Shut down gracefully.
.It Dv SIGUSR1
Reopen log files.
.El
.Sh DEBUGGING LOG
To enable a debugging log, reconfigure
.Nm
to build with debugging:
.Pp
.Dl "./configure --with-debug ..."
.Pp
and then set the
.Cm debug
level of the
.Va error_log :
.Pp
.Dl "error_log /path/to/log debug;"
.Pp
It is also possible to enable the debugging for a particular IP address:
.Bd -literal -offset indent
events {
debug_connection 127.0.0.1;
}
.Ed
.Sh ENVIRONMENT
The
.Ev NGINX
environment variable is used internally by
.Nm
and should not be set directly by the user.
.Sh FILES
.Bl -tag -width indent
.It Pa %%PID_PATH%%
Contains the process ID of
.Nm .
The contents of this file are not sensitive, so it can be world-readable.
.It Pa %%CONF_PATH%%
The main configuration file.
.It Pa %%ERROR_LOG_PATH%%
Error log file.
.El
.Sh EXIT STATUS
Exit status is 0 on success, or 1 if the command fails.
.Sh EXAMPLES
Test configuration file
.Pa ~/mynginx.conf
with global directives for PID and quantity of worker processes:
.Bd -literal -offset indent
nginx -t -c ~/mynginx.conf \e
-g "pid /var/run/mynginx.pid; worker_processes 2;"
.Ed
.Sh SEE ALSO
.\"Xr nginx.conf 5
.\"Pp
Documentation at
.Pa http://nginx.org/en/docs/ .
.Pp
For questions and technical support, please refer to
.Pa http://nginx.org/en/support.html .
.Sh HISTORY
Development of
.Nm
started in 2002, with the first public release on October 4, 2004.
.Sh AUTHORS
.An -nosplit
.An Igor Sysoev Aq Mt igor@sysoev.ru .
.Pp
This manual page was originally written by
.An Sergey A. Osokin Aq Mt osa@FreeBSD.org.ru
as a result of compiling many
.Nm
documents from all over the world.

Some files were not shown because too many files have changed in this diff Show More