]> git.feebdaed.xyz Git - 0xmirror/nginx.git/log
0xmirror/nginx.git
3 weeks agoDisabled bare LF in chunked transfer encoding.
Sergey Kandaurov [Mon, 24 Nov 2025 22:06:29 +0000 (02:06 +0400)]
Disabled bare LF in chunked transfer encoding.

Chunked transfer encoding, since originally introduced in HTTP/1.1
in RFC 2068, is specified to use CRLF as the only line terminator.

Although tolerant applications may recognize a single LF, formally
this covers the start line and fields, and doesn't apply to chunks.
Strict chunked parsing is reaffirmed as intentional in RFC errata
ID 7633, notably "because it does not have to retain backwards
compatibility with 1.0 parsers".

A general RFC 2616 recommendation to tolerate deviations whenever
interpreted unambiguously doesn't apply here, because chunked body
is used to determine HTTP message framing; a relaxed parsing may
cause various security problems due to a broken delimitation.
For instance, this is possible when receiving chunked body from
intermediates that blindly parse chunk-ext or a trailer section
until CRLF, and pass it further without re-coding.

3 weeks agoSSL: avoid warning when ECH is not configured and not supported.
QirunGao [Tue, 2 Dec 2025 22:32:47 +0000 (23:32 +0100)]
SSL: avoid warning when ECH is not configured and not supported.

3 weeks agoUpdate GitHub templates and markdown files.
Alessandro Fael Garcia [Tue, 10 Jun 2025 14:14:53 +0000 (16:14 +0200)]
Update GitHub templates and markdown files.

- Issue templates are replaced with forms.  Forms allow to explicitly ask
  for certain info before an issue is opened, they can be programmatically
  queried via GH actions to get the data in fields.

- Added language around GH discussions vs the forum in the issue forms.

- Added GH discussions templates.  These templates delineate which types
  of discussions belong on GitHub vs the community forum.

- Created SUPPORT.md to delineate which types of topics belong on GitHub
  vs different support channels (community forum/docs/commercial support).

- Updated CONTRIBUTING.md:
  - Removed text that belongs in SUPPORT.md.
  - Added F5 CLA clarifying text.

- Added badges to README.md.  Most of these are there to make information
  even clearer, moreso for users reading README.md from sources outside
  GitHub.

3 weeks agoAdd basic ECH shared-mode via OpenSSL.
sftcd [Wed, 26 Nov 2025 14:12:07 +0000 (14:12 +0000)]
Add basic ECH shared-mode via OpenSSL.

4 weeks agoProxy: fixed segfault in URI change.
Sergey Kandaurov [Mon, 24 Nov 2025 11:57:09 +0000 (15:57 +0400)]
Proxy: fixed segfault in URI change.

If request URI was shorter than location prefix, as after replacement
with try_files, location length was used to copy the remaining URI part
leading to buffer overread.

The fix is to replace full request URI in this case.  In the following
configuration, request "/123" is changed to "/" when sent to backend.

    location /1234 {
        try_files /123 =404;
        proxy_pass http://127.0.0.1:8080/;
    }

Closes #983 on GitHub.

4 weeks agoChanged interface of ngx_http_validate_host().
Sergey Kandaurov [Wed, 5 Nov 2025 12:15:12 +0000 (16:15 +0400)]
Changed interface of ngx_http_validate_host().

This allows to process a port subcomponent and save it in r->port
in a unified way, similar to r->headers_in.server.  For HTTP/1.x
request line in the absolute form, r->host_end now includes a port
subcomponent, which is also consistent with HTTP/2 and HTTP/3.

4 weeks agoImproved host header validation.
Sergey Kandaurov [Tue, 4 Nov 2025 12:34:32 +0000 (16:34 +0400)]
Improved host header validation.

Validation is rewritten to follow RFC 3986 host syntax, based on
ngx_http_parse_request_line().  The following is now rejected:
- the rest of gen-delims "#", "?", "@", "[", "]"
- other unwise delims <">, "<", ">", "\", "^", "`', "{", "|", "}"
- IP literals with a trailing dot, missing closing bracket, or pct-encoded
- a port subcomponent with invalid values
- characters in upper half

5 weeks agoHTTP/2: extended guard for NULL buffer and zero length.
Sergey Kandaurov [Fri, 14 Nov 2025 14:14:18 +0000 (18:14 +0400)]
HTTP/2: extended guard for NULL buffer and zero length.

In addition to moving memcpy() under the length condition in 15bf6d8cc,
which addressed a reported UB due to string function conventions, this
is repeated for advancing an input buffer, to make the resulting code
more clean and readable.

Additionally, although considered harmless for both string functions and
additive operators, as previously discussed in GitHub PR 866, this fixes
the main source of annoying sanitizer reports in the module.

Prodded by UndefinedBehaviorSanitizer (pointer-overflow).

6 weeks agoSSL: fixed build with BoringSSL, broken by 38a701d88.
Sergey Kandaurov [Mon, 10 Nov 2025 17:36:40 +0000 (21:36 +0400)]
SSL: fixed build with BoringSSL, broken by 38a701d88.

6 weeks agoSSL: ngx_ssl_set_client_hello_callback() error handling.
Sergey Kandaurov [Thu, 6 Nov 2025 13:30:41 +0000 (17:30 +0400)]
SSL: ngx_ssl_set_client_hello_callback() error handling.

The function interface is changed to follow a common approach
to other functions used to setup SSL_CTX, with an exception of
"ngx_conf_t *cf" since it is not bound to nginx configuration.

This is required to report and propagate SSL_CTX_set_ex_data()
errors, as reminded by Coverity (CID 1668589).

7 weeks agoConfigure: MSVC compatibility with PCRE2 10.47.
Thierry Bastian [Tue, 4 Nov 2025 17:28:52 +0000 (18:28 +0100)]
Configure: MSVC compatibility with PCRE2 10.47.

7 weeks agoVersion bump.
Sergey Kandaurov [Thu, 6 Nov 2025 11:31:37 +0000 (15:31 +0400)]
Version bump.

7 weeks agoConfigure: ensure we get the "built by ..." line in nginx -V.
Andrew Clayton [Tue, 23 Sep 2025 02:46:43 +0000 (03:46 +0100)]
Configure: ensure we get the "built by ..." line in nginx -V.

For certain compilers we embed the compiler version used to build nginx
in the binary, retrievable via 'nginx -V', e.g.

  $ ./objs/nginx -V
  ...
  built by gcc 15.2.1 20250808 (Red Hat 15.2.1-1) (GCC)
  ...

However if the CFLAGS environment variable is set this would be omitted.

This is due to the compiler specific auto/cc files not being run when
the CFLAGS environment variable is set, this is so entities can set
their own compiler flags, and thus the NGX_COMPILER variable isn't set.

Nonetheless it is a useful thing to have so re-work the auto scripts to
move the version gathering out of the individual auto/cc/$NGX_CC_NAME
files and merge them into auto/cc/name.

Link: <https://github.com/nginx/nginx/issues/878>

8 weeks agonginx-1.29.3-RELEASE
Roman Arutyunyan [Mon, 27 Oct 2025 11:32:12 +0000 (15:32 +0400)]
nginx-1.29.3-RELEASE

8 weeks agoModules compatibility: increased compat section size.
Roman Arutyunyan [Mon, 27 Oct 2025 12:12:46 +0000 (16:12 +0400)]
Modules compatibility: increased compat section size.

8 weeks agoFixed compilation warnings on Windows after c93a0c48af87.
Roman Arutyunyan [Mon, 27 Oct 2025 17:16:49 +0000 (21:16 +0400)]
Fixed compilation warnings on Windows after c93a0c48af87.

2 months agoOCSP: fixed invalid type for the 'ssl_ocsp' directive.
Roman Semenov [Wed, 22 Oct 2025 18:24:27 +0000 (11:24 -0700)]
OCSP: fixed invalid type for the 'ssl_ocsp' directive.

2 months agoHeaders filter: inheritance control for add_header and add_trailer.
Roman Arutyunyan [Mon, 14 Jul 2025 17:44:05 +0000 (21:44 +0400)]
Headers filter: inheritance control for add_header and add_trailer.

The new directives add_header_inherit and add_trailer_inherit allow
to alter inheritance rules for the values specified in the add_header
and add_trailer directives in a convenient way.

The "merge" parameter enables appending the values from the previous level
to the current level values.

The "off" parameter cancels inheritance of the values from the previous
configuration level, similar to add_header "" (2194e75bb).

The "on" parameter (default) enables the standard inheritance behaviour,
which is to inherit values from the previous level only if there are no
directives on the current level.

The inheritance rules themselves are inherited in a standard way.  Thus,
for example, "add_header_inherit merge;" specified at the top level will
be inherited in all nested levels recursively unless redefined below.

2 months agoGeo: the "volatile" parameter.
Dmitry Plotnikov [Tue, 21 Oct 2025 19:48:36 +0000 (19:48 +0000)]
Geo: the "volatile" parameter.

Similar to map's volatile parameter, creates a non-cacheable geo variable.

2 months agoSSL: $ssl_sigalg, $ssl_client_sigalg.
Sergey Kandaurov [Fri, 17 Oct 2025 16:38:17 +0000 (20:38 +0400)]
SSL: $ssl_sigalg, $ssl_client_sigalg.

Variables contain the IANA name of the signature scheme[1] used to sign
the TLS handshake.

Variables are only meaningful when using OpenSSL 3.5 and above, with older
versions they are empty.  Moreover, since this data isn't stored in a
serialized session, variables are only available for new sessions.

[1] https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml

Requested by willmafh.

2 months agoUpstream: reset local address in case of error.
Roman Arutyunyan [Thu, 23 Oct 2025 14:21:57 +0000 (18:21 +0400)]
Upstream: reset local address in case of error.

After f10bc5a763bb the address was set to NULL only when local address was
not specified at all.  In case complex value evaluated to an empty or
invalid string, local address remained unchanged.  Currenrly this is not
a problem since the value is only set once.  This change is a preparation
for being able to change the local address after initial setting.

2 months agoCONNECT method support for HTTP/1.1.
Roman Arutyunyan [Tue, 23 Sep 2025 11:03:52 +0000 (15:03 +0400)]
CONNECT method support for HTTP/1.1.

The change allows modules to use the CONNECT method with HTTP/1.1 requests.
To do so, they need to set the "allow_connect" flag in the core server
configuration.

2 months agoAdded $request_port and $is_request_port variables.
Roman Arutyunyan [Mon, 29 Sep 2025 16:47:27 +0000 (20:47 +0400)]
Added $request_port and $is_request_port variables.

The $request_port variable contains the port passed by the client in the
request line (for HTTP/1.x) or ":authority" pseudo-header (for HTTP/2 and
HTTP/3).  If the request line contains no host, or ":authority" is missing,
then $request_port is taken from the "Host" header, similar to the $host
variable.

The $is_request_port variable contains ":" if $request_port is non-empty,
and is empty otherwise.

2 months agoSSL: support for compressed server certificates with BoringSSL.
Sergey Kandaurov [Tue, 15 Jul 2025 18:22:53 +0000 (22:22 +0400)]
SSL: support for compressed server certificates with BoringSSL.

BoringSSL/AWS-LC provide two callbacks for each compression algorithm,
which may be used to compress and decompress certificates in runtime.
This change implements compression support with zlib, as enabled with
the ssl_certificate_compression directive.  Compressed certificates
are stored in certificate exdata and reused in subsequent connections.

Notably, AWS-LC saves an X509 pointer in SSL connection, which allows
to use it from SSL_get_certificate() for caching purpose.  In contrast,
BoringSSL reconstructs X509 on-the-fly, though given that it doesn't
support multiple certificates, always replacing previously configured
certificates, we use the last configured one from ssl->certs, instead.

2 months agoSSL: disabled using certificate compression with OCSP stapling.
Sergey Kandaurov [Thu, 2 Oct 2025 11:22:24 +0000 (15:22 +0400)]
SSL: disabled using certificate compression with OCSP stapling.

OCSP response in TLSv1.3 is sent in the Certificate message.  This
is incompatible with pre-compression of the configured certificates.

2 months agoUpdated OpenSSL and PCRE used for win32 builds.
Sergey Kandaurov [Tue, 7 Oct 2025 18:21:37 +0000 (22:21 +0400)]
Updated OpenSSL and PCRE used for win32 builds.

2 months agoVersion bump.
Sergey Kandaurov [Tue, 7 Oct 2025 18:19:01 +0000 (22:19 +0400)]
Version bump.

2 months agonginx-1.29.2-RELEASE
Sergey Kandaurov [Tue, 7 Oct 2025 12:46:15 +0000 (16:46 +0400)]
nginx-1.29.2-RELEASE

2 months agoFixed a typo.
Sergey Kandaurov [Tue, 7 Oct 2025 13:05:09 +0000 (17:05 +0400)]
Fixed a typo.

2 months agoSSL: fixed "key values mismatch" with object cache inheritance.
Sergey Kandaurov [Thu, 29 May 2025 13:49:48 +0000 (17:49 +0400)]
SSL: fixed "key values mismatch" with object cache inheritance.

In rare cases, it was possible to get into this error state on reload
with improperly updated file timestamps for certificate and key pairs.

The fix is to retry on X509_R_KEY_VALUES_MISMATCH, similar to 5d5d9adcc.
Additionally, loading SSL certificate is updated to avoid certificates
discarded on retry to appear in ssl->certs and in extra chain.

2 months agoAdded F5 CLA workflow.
Maryna-f5 [Thu, 25 Sep 2025 19:51:40 +0000 (12:51 -0700)]
Added F5 CLA workflow.

3 months agoMail: xtext encoding (RFC 3461) in XCLIENT LOGIN.
Sergey Kandaurov [Thu, 11 Sep 2025 14:23:10 +0000 (18:23 +0400)]
Mail: xtext encoding (RFC 3461) in XCLIENT LOGIN.

The XCLIENT command uses xtext encoding for attribute values,
as specified in https://www.postfix.org/XCLIENT_README.html.

Reported by Igor Morgenstern of Aisle Research.

3 months agoUpstream: overflow detection in Cache-Control delta-seconds.
Sergey Kandaurov [Wed, 10 Sep 2025 14:39:52 +0000 (18:39 +0400)]
Upstream: overflow detection in Cache-Control delta-seconds.

Overflowing calculations are now aligned to the greatest positive integer
as specified in RFC 9111, Section 1.2.2.

3 months agoSSL: AWS-LC compatibility.
Sergey Kandaurov [Wed, 30 Jul 2025 12:26:21 +0000 (16:26 +0400)]
SSL: AWS-LC compatibility.

3 months agoQUIC: a new macro to differentiate BoringSSL specific EVP API.
Sergey Kandaurov [Wed, 30 Jul 2025 12:23:43 +0000 (16:23 +0400)]
QUIC: a new macro to differentiate BoringSSL specific EVP API.

3 months agoQUIC: localized OpenSSL headers used for QUIC protection.
Sergey Kandaurov [Wed, 30 Jul 2025 12:09:21 +0000 (16:09 +0400)]
QUIC: localized OpenSSL headers used for QUIC protection.

3 months agoSNI: support for early ClientHello callback with BoringSSL.
Sergey Kandaurov [Mon, 22 Sep 2025 15:55:16 +0000 (19:55 +0400)]
SNI: support for early ClientHello callback with BoringSSL.

This brings feature parity with OpenSSL after the previous change,
making it possible to set SSL protocols per virtual server.

3 months agoSNI: using the ClientHello callback.
Sergey Kandaurov [Mon, 27 Jan 2025 20:53:15 +0000 (00:53 +0400)]
SNI: using the ClientHello callback.

The change introduces an SNI based virtual server selection during
early ClientHello processing.  The callback is available since
OpenSSL 1.1.1; for older OpenSSL versions, the previous behaviour
is kept.

Using the ClientHello callback sets a reasonable processing order
for the "server_name" TLS extension.  Notably, session resumption
decision now happens after applying server configuration chosen by
SNI, useful with enabled verification of client certificates, which
brings consistency with BoringSSL behaviour.  The change supersedes
and reverts a fix made in 46b9f5d38 for TLSv1.3 resumed sessions.

In addition, since the callback is invoked prior to the protocol
version negotiation, this makes it possible to set "ssl_protocols"
on a per-virtual server basis.

To keep the $ssl_server_name variable working with TLSv1.2 resumed
sessions, as previously fixed in fd97b2a80, a limited server name
callback is preserved in order to acknowledge the extension.

Note that to allow third-party modules to properly chain the call to
ngx_ssl_client_hello_callback(), the servername callback function is
passed through exdata.

3 months agoFixed inaccurate index directive error report.
willmafh [Mon, 8 Sep 2025 14:03:30 +0000 (22:03 +0800)]
Fixed inaccurate index directive error report.

3 months agoUpdated link to xslscript.
Sergey Kandaurov [Mon, 18 Aug 2025 18:10:25 +0000 (22:10 +0400)]
Updated link to xslscript.

3 months agoQUIC: fixed ssl_reject_handshake error handling.
Sergey Kandaurov [Wed, 10 Sep 2025 13:25:36 +0000 (17:25 +0400)]
QUIC: fixed ssl_reject_handshake error handling.

This was broken in 7468a10b6 (1.29.0), resulting in a missing diagnostics
and SSL error queue not cleared for SSL handshakes rejected by SNI, seen
as "ignoring stale global SSL error" alerts, for instance, when doing SSL
shutdown of a long standing connection after rejecting another one by SNI.

The fix is to move the qc->error check after c->ssl->handshake_rejected is
handled first, to make the error queue cleared.  Although not practicably
visible as needed, this is accompanied by clearing the error queue under
the qc->error case as well, to be on the safe side.

As an implementation note, due to the way of handling invalid transport
parameters for OpenSSL 3.5 and above, which leaves a passed pointer not
advanced on error, SSL_get_error() may return either SSL_ERROR_WANT_READ
or SSL_ERROR_WANT_WRITE depending on a library.  To cope with that, both
qc->error and c->ssl->handshake_rejected checks were moved out of
"sslerr != SSL_ERROR_WANT_READ".

Also, this reconstructs a missing "SSL_do_handshake() failed" diagnostics
for the qc->error case, replacing using ngx_ssl_connection_error() with
ngx_connection_error().  It is made this way to avoid logging at the crit
log level because qc->error set is expected to have an empty error queue.

Reported and tested by Vladimir Homutov.

4 months agoRemoved legacy charset directive from default config example.
Mohamed Karrab [Mon, 18 Aug 2025 19:28:06 +0000 (20:28 +0100)]
Removed legacy charset directive from default config example.

The example configuration previously specified 'charset koi8-r',
which is a legacy Cyrillic encoding.  As koi8-r is rarely used today
and modern browsers handle UTF-8 by default, specifying the charset
explicitly is unnecessary.  Removing the directive keeps the example
configuration concise and aligned with current best practices.

4 months agoAdded a previously missed changes entry in 1.29.1 relnotes.
Sergey Kandaurov [Wed, 13 Aug 2025 16:26:56 +0000 (20:26 +0400)]
Added a previously missed changes entry in 1.29.1 relnotes.

4 months agoVersion bump.
Sergey Kandaurov [Wed, 13 Aug 2025 16:07:38 +0000 (20:07 +0400)]
Version bump.

4 months agonginx-1.29.1-RELEASE
Sergey Kandaurov [Tue, 12 Aug 2025 14:46:04 +0000 (18:46 +0400)]
nginx-1.29.1-RELEASE

4 months agoUpdated OpenSSL used for win32 builds.
Sergey Kandaurov [Wed, 13 Aug 2025 13:55:56 +0000 (17:55 +0400)]
Updated OpenSSL used for win32 builds.

4 months agoMail: logging upstream to the error log with "smtp_auth none;".
Sergey Kandaurov [Mon, 21 Jul 2025 13:44:28 +0000 (17:44 +0400)]
Mail: logging upstream to the error log with "smtp_auth none;".

Previously, it was never logged because of missing login.

4 months agoMail: reset stale auth credentials with "smtp_auth none;".
Sergey Kandaurov [Mon, 7 Jul 2025 19:48:44 +0000 (23:48 +0400)]
Mail: reset stale auth credentials with "smtp_auth none;".

They might be reused in a session if an SMTP client proceeded
unauthenticated after previous invalid authentication attempts.
This could confuse an authentication server when passing stale
credentials along with "Auth-Method: none".

The condition to send the "Auth-Salt" header is similarly refined.

4 months agoMail: improved error handling in plain/login/cram-md5 auth methods.
Sergey Kandaurov [Tue, 12 Aug 2025 11:55:02 +0000 (15:55 +0400)]
Mail: improved error handling in plain/login/cram-md5 auth methods.

Previously, login and password storage could be left in inconsistent
state in a session after decoding errors.

4 months agoAuth basic: fixed file descriptor leak on memory allocation error.
Sergey Kandaurov [Fri, 8 Aug 2025 15:44:27 +0000 (19:44 +0400)]
Auth basic: fixed file descriptor leak on memory allocation error.

Found by Coverity (CID 1662016).

4 months agoSSL: support for compressed server certificates with OpenSSL.
Sergey Kandaurov [Wed, 9 Jul 2025 15:02:09 +0000 (19:02 +0400)]
SSL: support for compressed server certificates with OpenSSL.

The ssl_certificate_compression directive allows to send compressed
server certificates.  In OpenSSL, they are pre-compressed on startup.
To simplify configuration, the SSL_OP_NO_TX_CERTIFICATE_COMPRESSION
option is automatically cleared if certificates were pre-compressed.

SSL_CTX_compress_certs() may return an error in legitimate cases,
e.g., when none of compression algorithms is available or if the
resulting compressed size is larger than the original one, thus it
is silently ignored.

Certificate compression is supported in Chrome with brotli only,
in Safari with zlib only, and in Firefox with all listed algorithms.
It is supported since Ubuntu 24.10, which has OpenSSL with enabled
zlib and zstd support.

The actual list of algorithms supported in OpenSSL depends on how
the library was configured; it can be brotli, zlib, zstd as listed
in RFC 8879.

4 months agoSSL: disabled certificate compression by default with OpenSSL.
Sergey Kandaurov [Tue, 15 Jul 2025 11:55:26 +0000 (15:55 +0400)]
SSL: disabled certificate compression by default with OpenSSL.

Certificate compression is supported since OpenSSL 3.2, it is enabled
automatically as negotiated in a TLSv1.3 handshake.

Using certificate compression and decompression in runtime may be
suboptimal in terms of CPU and memory consumption in certain typical
scenarios, hence it is disabled by default on both server and client
sides.  It can be enabled with ssl_conf_command and similar directives
in upstream as appropriate, for example:

    ssl_conf_command Options RxCertificateCompression;
    ssl_conf_command Options TxCertificateCompression;

Compressing server certificates requires additional support, this is
addressed separately.

4 months agoUpdated ngx_http_process_multi_header_lines() comments.
Sergey Kandaurov [Thu, 31 Jul 2025 17:31:27 +0000 (21:31 +0400)]
Updated ngx_http_process_multi_header_lines() comments.

Missed in fcf4331a0.

4 months agoHTTP/3: improved invalid ":authority" error message.
Sergey Kandaurov [Wed, 30 Jul 2025 13:43:44 +0000 (17:43 +0400)]
HTTP/3: improved invalid ":authority" error message.

4 months agoMade ngx_http_process_request_header() static again.
Sergey Kandaurov [Wed, 23 Jul 2025 11:56:37 +0000 (15:56 +0400)]
Made ngx_http_process_request_header() static again.

The function contains mostly HTTP/1.x specific request processing,
which has no use in other protocols.  After the previous change in
HTTP/2, it can now be hidden.

This is an API change.

4 months agoHTTP/2: fixed handling of the ":authority" header.
Sergey Kandaurov [Wed, 23 Jul 2025 10:54:07 +0000 (14:54 +0400)]
HTTP/2: fixed handling of the ":authority" header.

Previously, it misused the Host header processing resulting in
400 (Bad Request) errors for a valid request that contains both
":authority" and Host headers with the same value, treating it
after 37984f0be as if client sent more than one Host header.
Such an overly strict handling violates RFC 9113.

The fix is to process ":authority" as a distinct header, similarly
to processing an authority component in the HTTP/1.x request line.
This allows to disambiguate and compare Host and ":authority"
values after all headers were processed.

With this change, the ngx_http_process_request_header() function
can no longer be used here, certain parts were inlined similar to
the HTTP/3 module.

To provide compatibility for misconfigurations that use $http_host
to return the value of the ":authority" header, the Host header,
if missing, is now reconstructed from ":authority".

4 months agoHTTP/2: factored out constructing the Host header.
Sergey Kandaurov [Wed, 23 Jul 2025 10:32:34 +0000 (14:32 +0400)]
HTTP/2: factored out constructing the Host header.

No functional changes.

5 months agoHTTP/2: fixed flushing early hints over SSL.
Roman Arutyunyan [Thu, 24 Jul 2025 14:29:21 +0000 (18:29 +0400)]
HTTP/2: fixed flushing early hints over SSL.

Previously, when using HTTP/2 over SSL, an early hints HEADERS frame was
queued in SSL buffer, and might not be immediately flushed.  This resulted
in a delay of early hints delivery until the main response was sent.

The fix is to set the flush flag for the early hints HEADERS frame buffer.

5 months agoHTTP/3: fixed handling of :authority and Host with port.
Roman Arutyunyan [Thu, 26 Jun 2025 16:19:59 +0000 (20:19 +0400)]
HTTP/3: fixed handling of :authority and Host with port.

RFC 9114, Section 4.3.1. specifies a restriction for :authority and Host
coexistence in an HTTP/3 request:

: If both fields are present, they MUST contain the same value.

Previously, this restriction was correctly enforced only for portless
values.  When Host contained a port, the request failed as if :authority
and Host were different, regardless of :authority presence.

This happens because the value of r->headers_in.server used for :authority
has port stripped.  The fix is to use r->host_start / r->host_end instead.

5 months agoHTTP/3: fixed potential type overflow in string literal parser.
Sergey Kandaurov [Thu, 5 Sep 2024 15:35:43 +0000 (19:35 +0400)]
HTTP/3: fixed potential type overflow in string literal parser.

This might happen for Huffman encoded string literals as the result
of length expansion.  Notably, the maximum length of string literals
is already limited with the "large_client_header_buffers" directive,
so this was only possible with nonsensically large configured limits.

5 months agoEvents: compatibility with NetBSD 10.0 in kqueue.
Sergey Kandaurov [Thu, 10 Jul 2025 12:59:05 +0000 (16:59 +0400)]
Events: compatibility with NetBSD 10.0 in kqueue.

The kevent udata field was changed from intptr_t to "void *",
similar to other BSDs and Darwin.

The NGX_KQUEUE_UDATA_T macro is adjusted to reflect that change,
fixing -Werror=int-conversion errors.

5 months agoConfigure: set NGX_KQUEUE_UDATA_T at compile time.
Sergey Kandaurov [Thu, 10 Jul 2025 12:30:35 +0000 (16:30 +0400)]
Configure: set NGX_KQUEUE_UDATA_T at compile time.

The NGX_KQUEUE_UDATA_T macro is used to compensate the incompatible
kqueue() API in NetBSD, it doesn't really belong to feature tests.

The change limits the macro visibility to the kqueue event module.
Moving from autotests also simplifies testing a particular NetBSD
version as seen in a subsequent change.

5 months agoEvents: fixed -Wzero-as-null-pointer-constant warnings in kqueue.
Sergey Kandaurov [Tue, 8 Jul 2025 18:45:33 +0000 (22:45 +0400)]
Events: fixed -Wzero-as-null-pointer-constant warnings in kqueue.

The kevent udata field is special in that we maintain compatibility
with NetBSD versions that predate using the "void *" type.

The fix is to cast to intermediate uintptr_t that is casted back to
"void *" where appropriate.

5 months agoSSL: fixed testing OPENSSL_VERSION_NUMBER for OpenSSL 3.0+.
Sergey Kandaurov [Tue, 8 Jul 2025 14:07:04 +0000 (18:07 +0400)]
SSL: fixed testing OPENSSL_VERSION_NUMBER for OpenSSL 3.0+.

Prior to OpenSSL 3.0, OPENSSL_VERSION_NUMBER used the following format:

MNNFFPPS: major minor fix patch status

Where the status nibble (S) has 0+ for development and f for release.

The format was changed in OpenSSL 3.0.0, where it is always zero:

MNN00PP0: major minor patch

5 months agoSSL: SSL_group_to_name() compatibility macro.
Sergey Kandaurov [Tue, 8 Jul 2025 13:59:50 +0000 (17:59 +0400)]
SSL: SSL_group_to_name() compatibility macro.

No functional changes.

5 months agoQUIC: adjusted OpenSSL 3.5 QUIC API feature test.
Sergey Kandaurov [Sun, 22 Jun 2025 16:40:05 +0000 (20:40 +0400)]
QUIC: adjusted OpenSSL 3.5 QUIC API feature test.

A bug with the "quic_transport_parameters" extension and SNI described
in cedb855d7 is now fixed in the OpenSSL 3.5.1 release, as requested
in https://github.com/openssl/openssl/pull/27706.

6 months agoWin32: fixed PCRE license for nginx/Windows zip.
Sergey Kandaurov [Tue, 24 Jun 2025 18:46:00 +0000 (22:46 +0400)]
Win32: fixed PCRE license for nginx/Windows zip.

6 months agoVersion bump.
Sergey Kandaurov [Tue, 24 Jun 2025 18:45:32 +0000 (22:45 +0400)]
Version bump.

6 months agonginx-1.29.0-RELEASE
Sergey Kandaurov [Tue, 24 Jun 2025 12:40:21 +0000 (16:40 +0400)]
nginx-1.29.0-RELEASE

6 months agoUpdated OpenSSL and PCRE used for win32 builds.
Sergey Kandaurov [Tue, 24 Jun 2025 11:20:27 +0000 (15:20 +0400)]
Updated OpenSSL and PCRE used for win32 builds.

6 months agoWin32: skip OpenSSL dependency generation to conserve time.
Sergey Kandaurov [Tue, 24 Jun 2025 12:42:20 +0000 (16:42 +0400)]
Win32: skip OpenSSL dependency generation to conserve time.

Disabling the build dependency feature is safe assuming that
nginx/Windows release zip is always built from a clean tree.
This allows to speed up total build time by around 40%.

As it may not be suitable in general, the option resides here
and not in configure.

6 months agoQUIC: disabled OpenSSL 3.5 QUIC API support by default.
Sergey Kandaurov [Tue, 27 May 2025 17:56:40 +0000 (21:56 +0400)]
QUIC: disabled OpenSSL 3.5 QUIC API support by default.

In OpenSSL 3.5.0, the "quic_transport_parameters" extension set
internally by the QUIC API is cleared on the SSL context switch,
which disables sending QUIC transport parameters if switching to
a different server block on SNI.  See the initial report in [1].

This is fixed post OpenSSL 3.5.0 [2].  The fix is anticipated in
OpenSSL 3.5.1, which has not been released yet.  When building
with OpenSSL 3.5, OpenSSL compat layer is now used by default.
The OpenSSL 3.5 QUIC API support can be switched back using
--with-cc-opt='-DNGX_QUIC_OPENSSL_API=1'.

[1] https://github.com/nginx/nginx/issues/711
[2] https://github.com/openssl/openssl/commit/45bd3c3798

6 months agoUpstream: fixed reinit request with gRPC and Early Hints.
Sergey Kandaurov [Mon, 23 Jun 2025 10:55:32 +0000 (14:55 +0400)]
Upstream: fixed reinit request with gRPC and Early Hints.

The gRPC module context has connection specific state, which can be lost
after request reinitialization when it comes to processing early hints.

The fix is to do only a portion of u->reinit_request() implementation
required after processing early hints, now inlined in modules.

Now NGX_HTTP_UPSTREAM_EARLY_HINTS is returned from u->process_header()
for early hints.  When reading a cached response, this code is mapped
to NGX_HTTP_UPSTREAM_INVALID_HEADER to indicate invalid header format.

6 months agoUse NULL instead of 0 for null pointer constant.
Andrew Clayton [Wed, 21 May 2025 21:30:20 +0000 (22:30 +0100)]
Use NULL instead of 0 for null pointer constant.

There were a few random places where 0 was being used as a null pointer
constant.

We have a NULL macro for this very purpose, use it.

There is also some interest in actually deprecating the use of 0 as a
null pointer constant in C.

This was found with -Wzero-as-null-pointer-constant which was enabled
for C in GCC 15 (not enabled with Wall or Wextra... yet).

Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117059>

6 months agoUse NGX_CONF_OK in some function return checks.
Andrew Clayton [Wed, 21 May 2025 21:19:32 +0000 (22:19 +0100)]
Use NGX_CONF_OK in some function return checks.

The functions ngx_http_merge_types() & ngx_conf_merge_path_value()
return either NGX_CONF_OK aka NULL aka ((void *)0) (probably) or
NGX_CONF_ERROR aka ((void *)-1).

They don't return an integer constant which is what NGX_OK aka (0) is.

Lets use the right thing in the function return check.

This was found with -Wzero-as-null-pointer-constant which was enabled
for C in GCC 15 (not enabled with Wall or Wextra... yet).

Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117059>

6 months agoHTTP/3: indexed field line encoding for "103 Early Hints".
Sergey Kandaurov [Fri, 20 Jun 2025 14:46:17 +0000 (18:46 +0400)]
HTTP/3: indexed field line encoding for "103 Early Hints".

6 months agoUpstream: early hints support.
Roman Arutyunyan [Fri, 15 Nov 2024 04:23:53 +0000 (08:23 +0400)]
Upstream: early hints support.

The change implements processing upstream early hints response in
ngx_http_proxy_module and ngx_http_grpc_module.  A new directive
"early_hints" enables sending early hints to the client.  By default,
sending early hints is disabled.

Example:

    map $http_sec_fetch_mode $early_hints {
        navigate $http2$http3;
    }

    early_hints $early_hints;

    proxy_pass http://example.com;

6 months agoHTTP/2: added function declaration.
Roman Arutyunyan [Wed, 18 Jun 2025 15:48:19 +0000 (19:48 +0400)]
HTTP/2: added function declaration.

7 months agoCore: added support for TCP keepalive parameters on macOS.
Sergey Kandaurov [Mon, 26 May 2025 12:11:36 +0000 (16:11 +0400)]
Core: added support for TCP keepalive parameters on macOS.

The support first appeared in OS X Mavericks 10.9 and documented since
OS X Yosemite 10.10.

It has a subtle implementation difference from other operating systems
in that the TCP_KEEPALIVE socket option (used in place of TCP_KEEPIDLE)
isn't inherited from a listening socket to an accepted socket.

An apparent reason for this behaviour is that it might be preserved for
the sake of backward compatibility.  The TCP_KEEPALIVE socket option is
not inherited since appearance in OS X Panther 10.3, which long predates
two other TCP_KEEPINTVL and TCP_KEEPCNT socket options.

Thanks to Andy Pan for initial work.

7 months agoSSL: disabled UI console prompts from worker processes.
Aleksei Bavshin [Fri, 17 Jan 2025 20:24:08 +0000 (12:24 -0800)]
SSL: disabled UI console prompts from worker processes.

Certain providers may attempt to reload the key on the first use after a
fork.  Such attempt would require re-prompting the pin, and this time we
are not able to pass the password callback.

While it is addressable with configuration for a specific provider, it would
be prudent to ensure that no such prompts could block worker processes by
setting the default UI method.

UI_null() first appeared in 1.1.1 along with the OSSL_STORE, so it is safe
to assume the same set of guards.

7 months agoSSL: support loading keys via OSSL_STORE.
Aleksei Bavshin [Tue, 17 Dec 2024 01:56:45 +0000 (17:56 -0800)]
SSL: support loading keys via OSSL_STORE.

A new "store:..." prefix for the "ssl_certificate_key" directive allows
loading keys via the OSSL_STORE API.

The change is required to support hardware backed keys in OpenSSL 3.x using
the new "provider(7ossl)" modules, such as "pkcs11-provider".  While the
engine API is present in 3.x, some operating systems (notably, RHEL10)
have already disabled it in their builds of OpenSSL.

Related: https://trac.nginx.org/nginx/ticket/2449

7 months agoQUIC: using QUIC API introduced in OpenSSL 3.5.
Sergey Kandaurov [Thu, 13 Feb 2025 13:00:56 +0000 (17:00 +0400)]
QUIC: using QUIC API introduced in OpenSSL 3.5.

Similarly to the QUIC API originated in BoringSSL, this API allows
to register custom TLS callbacks for an external QUIC implementation.
See the SSL_set_quic_tls_cbs manual page for details.

Due to a different approach used in OpenSSL 3.5, handling of CRYPTO
frames was streamlined to always write an incoming CRYPTO buffer to
the crypto context.  Using SSL_provide_quic_data(), this results in
transient allocation of chain links and buffers for CRYPTO frames
received in order.  Testing didn't reveal performance degradation of
QUIC handshakes, https://github.com/nginx/nginx/pull/646 provides
specific results.

7 months agoQUIC: better approach for premature handshake completion.
Sergey Kandaurov [Thu, 15 May 2025 21:10:11 +0000 (01:10 +0400)]
QUIC: better approach for premature handshake completion.

Using SSL_in_init() to inspect a handshake state was replaced with
SSL_is_init_finished().  This represents a more complete fix to the
BoringSSL issue addressed in 22671b37e.

This provides awareness of the early data handshake state when using
OpenSSL 3.5 TLS callbacks in 0-RTT enabled configurations, which, in
particular, is used to avoid premature completion of the initial TLS
handshake, before required client handshake messages are received.

This is a non-functional change when using BoringSSL.  It supersedes
testing non-positive SSL_do_handshake() results in all supported SSL
libraries, hence simplified.

In preparation for using OpenSSL 3.5 TLS callbacks.

7 months agoQUIC: ssl_encryption_level_t abstraction layer.
Sergey Kandaurov [Tue, 6 May 2025 11:58:17 +0000 (15:58 +0400)]
QUIC: ssl_encryption_level_t abstraction layer.

Encryption level values are decoupled from ssl_encryption_level_t,
which is now limited to BoringSSL QUIC callbacks, with mappings
provided.  Although the values match, this provides a technically
safe approach, in particular, to access protection level sized arrays.

In preparation for using OpenSSL 3.5 TLS callbacks.

7 months agoQUIC: factored out SSL_provide_quic_data() to the helper function.
Sergey Kandaurov [Wed, 21 May 2025 16:32:48 +0000 (20:32 +0400)]
QUIC: factored out SSL_provide_quic_data() to the helper function.

It is now called from ngx_quic_handle_crypto_frame(), prior to proceeding
with the handshake.  With this logic removed, the handshake function is
renamed to ngx_quic_handshake() to better match ngx_ssl_handshake().

7 months agoQUIC: defined SSL API macros in a single place.
Sergey Kandaurov [Tue, 20 May 2025 23:54:45 +0000 (03:54 +0400)]
QUIC: defined SSL API macros in a single place.

All definitions now set in ngx_event_quic.h, this includes moving
NGX_QUIC_OPENSSL_COMPAT from autotests to compile time.  Further,
to improve code readability, a new NGX_QUIC_QUICTLS_API macro is
used for QuicTLS that provides old BoringSSL QUIC API.

7 months agoQUIC: logging missing mandatory TLS extensions only once.
Sergey Kandaurov [Tue, 6 May 2025 14:57:01 +0000 (18:57 +0400)]
QUIC: logging missing mandatory TLS extensions only once.

Previously, they might be logged on every add_handshake_data
callback invocation when using OpenSSL compat layer and processing
coalesced handshake messages.

Further, the ALPN error message is adjusted to signal the missing
extension.  Possible reasons were previously narrowed down with
ebb6f7d65 changes in the ALPN callback that is invoked earlier in
the handshake.

7 months agoQUIC: reset qc->error to zero again.
Sergey Kandaurov [Wed, 14 May 2025 19:33:00 +0000 (23:33 +0400)]
QUIC: reset qc->error to zero again.

Following the previous change that removed posting a close event
in OpenSSL compat layer, now ngx_quic_close_connection() is always
called on error path with either NGX_ERROR or qc->error set.

This allows to remove a special value -1 served as a missing error,
which simplifies the code.  Partially reverts d3fb12d77.

Also, this improves handling of the draining connection state, which
consists of posting a close event with NGX_OK and no qc->error set,
where it was previously converted to NGX_QUIC_ERR_INTERNAL_ERROR.
Notably, this is rather a cosmetic fix, because drained connections
do not send any packets including CONNECTION_CLOSE, and qc->error
is not otherwise used.

7 months agoQUIC: adjusted handling of callback errors.
Sergey Kandaurov [Tue, 13 May 2025 16:12:10 +0000 (20:12 +0400)]
QUIC: adjusted handling of callback errors.

Changed handshake callbacks to always return success.  This allows to avoid
logging SSL_do_handshake() errors with empty or cryptic "internal error"
OpenSSL error messages at the inappropriate "crit" log level.

Further, connections with failed callbacks are closed now right away when
using OpenSSL compat layer.  This change supersedes and reverts c37fdcdd1,
with the conditions to check callbacks invocation kept to slightly improve
code readability of control flow; they are optimized out in the resulting
assembly code.

7 months agoQUIC: logging of SSL library errors.
Sergey Kandaurov [Wed, 21 May 2025 15:55:31 +0000 (19:55 +0400)]
QUIC: logging of SSL library errors.

Logging level for such errors, which should not normally happen,
is changed to NGX_LOG_ALERT, and ngx_log_error() is replaced with
ngx_ssl_error() for consistency with the rest of the code.

7 months agoQUIC: logging level of handshake errors.
Sergey Kandaurov [Tue, 6 May 2025 11:09:28 +0000 (15:09 +0400)]
QUIC: logging level of handshake errors.

Various errors reported by SSL_do_handshake() are now logged at the
"info" or "crit" level, akin to handshakes on regular TCP connections.

7 months agoQUIC: removed ALPN feature test.
Sergey Kandaurov [Tue, 6 May 2025 11:17:44 +0000 (15:17 +0400)]
QUIC: removed ALPN feature test.

ALPN support is present in all libraries that have QUIC support,
it is safe to compile it unconditionally.

7 months agoQUIC: removed excessive casts for ngx_ssl_get_connection().
Sergey Kandaurov [Tue, 6 May 2025 11:53:49 +0000 (15:53 +0400)]
QUIC: removed excessive casts for ngx_ssl_get_connection().

They were blindly copied from ngx_ssl_info_callback(), where
the ngx_ssl_conn_t pointer is passed with const qualifier.

7 months agoQUIC: removed level field from ngx_quic_compat_record_t.
Sergey Kandaurov [Tue, 6 May 2025 15:57:44 +0000 (19:57 +0400)]
QUIC: removed level field from ngx_quic_compat_record_t.

It was made unused in d15f8f2 after introducing reusable crypto contexts.

7 months agoQUIC: do not block ACKs by congestion control.
Sergey Kandaurov [Fri, 25 Apr 2025 19:32:24 +0000 (23:32 +0400)]
QUIC: do not block ACKs by congestion control.

Previously, it was not possible to send acknowledgments if the
congestion window was limited or temporarily exceeded, such as
after sending a large response or MTU probe.  If ACKs were not
received from the peer for some reason to update the in-flight
bytes counter below the congestion window, this might result in
a stalled connection.

The fix is to send ACKs regardless of congestion control.  This
meets RFC 9002, Section 7:
: Similar to TCP, packets containing only ACK frames do not count
: toward bytes in flight and are not congestion controlled.

This is a simplified implementation to send ACK frames from the
head of the queue.  This was made possible after 6f5f17358.

Reported in trac ticket #2621 and subsequently by Vladimir Homutov:
https://mailman.nginx.org/pipermail/nginx-devel/2025-April/ZKBAWRJVQXSZ2ISG3YJAF3EWMDRDHCMO.html

8 months agoSSL: fixed build with OPENSSL_NO_DH.
Sergey Kandaurov [Wed, 16 Apr 2025 16:58:57 +0000 (20:58 +0400)]
SSL: fixed build with OPENSSL_NO_DH.

8 months agoSSL: fixed build with OPENSSL_NO_DEPRECATED.
Sergey Kandaurov [Wed, 16 Apr 2025 16:50:29 +0000 (20:50 +0400)]
SSL: fixed build with OPENSSL_NO_DEPRECATED.

8 months agoQUIC: fixed a typo.
nandsky [Fri, 18 Apr 2025 03:45:12 +0000 (11:45 +0800)]
QUIC: fixed a typo.

8 months agoWin32: added detection of ARM64 target.
Aleksei Bavshin [Tue, 14 Jan 2025 19:11:28 +0000 (11:11 -0800)]
Win32: added detection of ARM64 target.

This extends the target selection implemented in dad6ec3aa63f to support
Windows ARM64 platforms.  OpenSSL support for VC-WIN64-ARM target first
appeared in 1.1.1 and is present in all currently supported (3.x)
branches.

As a side effect, ARM64 Windows builds will get 16-byte alignment along
with the rest of non-x86 platforms.  This is safe, as malloc on 64-bit
Windows guarantees the fundamental alignment of allocations, 16 bytes.

8 months agoCore: improved NGX_ALIGNMENT detection on some x86_64 platforms.
Aleksei Bavshin [Tue, 14 Jan 2025 18:32:24 +0000 (10:32 -0800)]
Core: improved NGX_ALIGNMENT detection on some x86_64 platforms.

Previously, the default pool alignment used sizeof(unsigned long), with
the expectation that this would match to a platform word size.  Certain
64-bit platforms prove this assumption wrong by keeping the 32-bit long
type, which is fully compliant with the C standard.

This introduces a possibility of suboptimal misaligned access to the
data allocated with ngx_palloc() on the affected platforms, which is
addressed here by changing the default NGX_ALIGNMENT to a pointer size.

As we override the detection in auto/os/conf for all the machine types
except x86, and Unix-like 64-bit systems prefer the 64-bit long, the
impact of the change should be limited to Win64 x64.