]> git.kaiwu.me - nginx.git/log
nginx.git
7 weeks agoMp4: avoid zero size buffers in output.
Roman Arutyunyan [Sat, 21 Feb 2026 08:04:36 +0000 (12:04 +0400)]
Mp4: avoid zero size buffers in output.

Previously, data validation checks did not cover the cases when the output
contained empty buffers.  Such buffers are considered illegal and produce
"zero size buf in output" alerts.  The change rejects the mp4 files which
produce such alerts.

Also, the change fixes possible buffer overread and overwrite that could
happen while processing empty stco and co64 atoms, as reported by
Pavel Kohout (Aisle Research) and Tim Becker.

7 weeks agoUpstream keepalive: fixed parameter parsing.
Roman Arutyunyan [Tue, 24 Mar 2026 11:12:05 +0000 (15:12 +0400)]
Upstream keepalive: fixed parameter parsing.

7 weeks agoProxy: enabled HTTP/1.1 by default for upstream connections.
Roman Semenov [Tue, 27 Jan 2026 20:37:11 +0000 (12:37 -0800)]
Proxy: enabled HTTP/1.1 by default for upstream connections.

Updates the proxy module to use HTTP/1.1 as the default protocol when
communicating with upstream servers. This change unlocks features
such as persistent connections and chunked transfer encoding. Configurations
that require HTTP/1.0 can still override the protocol explicitly.

7 weeks agoUpstream: enabled keepalive by default for explicit upstreams.
Roman Semenov [Mon, 23 Mar 2026 18:03:26 +0000 (11:03 -0700)]
Upstream: enabled keepalive by default for explicit upstreams.

Keepalive is now automatically enabled in the "local" mode for upstreams
defined in configuration files. Cached keepalive connections are no longer
shared between different locations referencing the same explicit upstream
unless keepalive is explicitly configured without the "local" parameter.

To disable keepalive entirely, use keepalive 0; inside the upstream block.
To allow sharing cached connections between locations, configure
keepalive <max_cached>; without the "local" parameter.

7 weeks agoUpstream keepalive: distinguish cached connections by location.
Roman Semenov [Thu, 19 Mar 2026 19:47:14 +0000 (12:47 -0700)]
Upstream keepalive: distinguish cached connections by location.

The new "local" parameter prevents sharing cached keepalive connections
between location blocks. Connections are now reused only within the same
location.

7 weeks agoAdded COMPAT section to ngx_log_t.
Dmitry Plotnikov [Thu, 19 Mar 2026 21:20:50 +0000 (21:20 +0000)]
Added COMPAT section to ngx_log_t.

7 weeks agoThe "multipath" parameter of the "listen" directive.
Sergey Kandaurov [Thu, 16 Oct 2025 15:22:56 +0000 (15:22 +0000)]
The "multipath" parameter of the "listen" directive.

When configured, it enables Multipath TCP support on a listen socket.
As of now it works on Linux starting with Linux 5.6 and glibc 2.32,
where it is enabled with an IPPROTO_MPTCP socket(2) protocol.

To avoid EADDRINUSE errors in bind() and listen() when transitioning
between sockets with different protocols, SO_REUSEPORT is set on both
sockets.  See f7f1607bf for potential implications.

Based on previous work by Maxime Dourov and Anthony Doeraene.

8 weeks agogRPC: reset buffer chains on upstream reinit.
David Carlier [Fri, 20 Feb 2026 05:08:09 +0000 (05:08 +0000)]
gRPC: reset buffer chains on upstream reinit.

Previously, ctx->out was not cleared in ngx_http_grpc_reinit_request(),
which could cause queued HTTP/2 control frames (SETTINGS ACK, PING ACK,
WINDOW_UPDATE) to be sent on next upstream.

Additionally, ctx->in and ctx->busy needs to be cleared to avoid similar
problems with buffered request body fixed in cd12dc4f1.

8 weeks agoProxy: reset pending control frames on HTTP/2 upstream reinit.
David Carlier [Thu, 19 Feb 2026 07:26:42 +0000 (07:26 +0000)]
Proxy: reset pending control frames on HTTP/2 upstream reinit.

Previously, ctx->out was not cleared in ngx_http_proxy_v2_reinit_request(),
which could cause stale HTTP/2 control frames (SETTINGS ACK, PING ACK,
WINDOW_UPDATE) queued for the old upstream connection to be sent to a new
upstream connection during a retry.

2 months agoProxy authentication definitions.
Roman Arutyunyan [Tue, 10 Mar 2026 12:43:41 +0000 (16:43 +0400)]
Proxy authentication definitions.

2 months agoVersion bump.
Roman Arutyunyan [Wed, 11 Mar 2026 15:28:31 +0000 (19:28 +0400)]
Version bump.

2 months agonginx-1.29.6-RELEASE release-1.29.6
Sergey Kandaurov [Tue, 10 Mar 2026 01:44:53 +0000 (05:44 +0400)]
nginx-1.29.6-RELEASE

2 months agoFixed typos.
Sergey Kandaurov [Tue, 10 Mar 2026 01:48:10 +0000 (05:48 +0400)]
Fixed typos.

2 months agoUpdated zlib used for win32 builds.
Sergey Kandaurov [Tue, 10 Mar 2026 13:06:35 +0000 (17:06 +0400)]
Updated zlib used for win32 builds.

2 months agoSticky: fixed expiration of learned sessions after reload.
Aleksei Bavshin [Tue, 17 Feb 2026 20:02:59 +0000 (12:02 -0800)]
Sticky: fixed expiration of learned sessions after reload.

Previously, the expiration timer for learned session was not started
until a new session is created.  This could lead to the sessions being
active past the expiration time.

2 months agoSticky: samesite=<strict|lax|none> cookie flags.
Vladimir Kokshenev [Sun, 1 Nov 2020 23:03:08 +0000 (15:03 -0800)]
Sticky: samesite=<strict|lax|none> cookie flags.

Adds new options for the "sticky cookie" directive to set
samesite=<strict|lax|none> cookie flags.

2 months agoSticky: added the "header" parameter in the learn mode.
Vladimir Homutov [Thu, 8 Jun 2017 12:39:06 +0000 (15:39 +0300)]
Sticky: added the "header" parameter in the learn mode.

With this parameter set, sessions are learned after receiving upstream headers.

2 months agoSticky: added the "max-age" attribute to cookie.
Vladimir Homutov [Fri, 7 Apr 2017 13:28:15 +0000 (16:28 +0300)]
Sticky: added the "max-age" attribute to cookie.

RFC 6265 defines "Max-Age" cookie attribute in section 5.2.2.

If the "expires" option is passed to the "sticky" directive, "max-age"
attribute will appear in cookies set by the module with corresponding
value in seconds.

For the special "max" value of the "expires" option, corresponding "max-age"
attribute value will be set to 315360000 seconds (10 years, similar to
how its done in headers_filter module for the "Cache-Control" header).

2 months agoSticky: added variables support to cookie domain.
Vladimir Homutov [Wed, 28 Sep 2016 07:55:58 +0000 (10:55 +0300)]
Sticky: added variables support to cookie domain.

2 months agoSticky: added "httponly" and "secure" attributes.
Vladimir Homutov [Tue, 17 Mar 2015 15:46:15 +0000 (18:46 +0300)]
Sticky: added "httponly" and "secure" attributes.

The attributes are described in RFC6265, sections 4.1.2.5 and 4.1.2.6
respectively.

2 months agoSticky: added "draining" peer state.
Vladimir Homutov [Thu, 28 Aug 2014 07:53:49 +0000 (11:53 +0400)]
Sticky: added "draining" peer state.

While peer is draining, only sticky requests are served and the peer is never
selected to process new requests.

Co-authored-by: Ruslan Ermilov <ru@nginx.com>
2 months agoUpstream: introduced a new macro for down value.
Aleksei Bavshin [Wed, 4 Mar 2026 19:35:41 +0000 (11:35 -0800)]
Upstream: introduced a new macro for down value.

2 months agoSticky: added the "learn" mode.
Vladimir Homutov [Mon, 5 May 2014 07:53:10 +0000 (11:53 +0400)]
Sticky: added the "learn" mode.

In this mode, nginx "learns" which client uses which proxied server by
analyzing headers of client requests and proxied server responses.

For example, a proxied server may start sessions by issuing the "Set-Cookie"
header field to set cookie 'sid' and returning clients will bring the cookie
with the same name.

The following configuration may be used to handle this case:

upstream u1 {
    server 127.0.0.1:8080;
    server 127.0.0.1:8081;

    sticky learn timeout=10m zone=sess:1m
           create=$upstream_cookie_sid
           lookup=$cookie_sid;
}

Co-authored-by: Ruslan Ermilov <ru@nginx.com>
Co-authored-by: Maxim Dounin <mdounin@mdounin.ru>
2 months agoUpstream: added sticky sessions support for upstreams.
Vladimir Homutov [Tue, 2 Apr 2013 21:44:36 +0000 (01:44 +0400)]
Upstream: added sticky sessions support for upstreams.

Sticky sessions allow to route the same client to the same upstream server.

- upstream structures are extended to keep session-related information

- existing balancing modules are updated to provide an id of the selected
  server (SID) in pc->sid, and to select the server, given it's SID.

- other balancing modules are allowed to set the pc->hint value to choose
  the desired peer.  The sticky module will not change the hint if it's
  already set.

- the feature is enabled by default and can be disabled with the
  "--without-http_upstream_sticky" switch of the configure script.

The following configuration can be used to enable sticky sessions for
supported balancing modules:

    upstream u1 {
        server 127.0.0.1:8080;
        server 127.0.0.1:8081;

        sticky cookie server_id expires=1h domain=.example.com path=/;
    }

Co-authored-by: Ruslan Ermilov <ru@nginx.com>
Co-authored-by: Roman Arutyunyan <arut@nginx.com>
Co-authored-by: Maxim Dounin <mdounin@mdounin.ru>
2 months agoMail: fixed type overflow in IMAP literal length parser.
Sergey Kandaurov [Fri, 27 Feb 2026 17:46:04 +0000 (21:46 +0400)]
Mail: fixed type overflow in IMAP literal length parser.

The overflow is safe, because the maximum length of literals
is limited with the "imap_client_buffer" directive.

Reported by BartÅ‚omiej Dmitruk.

2 months agoMail: stricter IMAP literals validation.
Sergey Kandaurov [Fri, 27 Feb 2026 17:18:16 +0000 (21:18 +0400)]
Mail: stricter IMAP literals validation.

As clarified in RFC 3501, Section 7.5, literals are followed
either by SP, for additional command arguments, or CRLF.

2 months agoAdded an option to skip the F5 CLA workflow.
Alessandro Fael Garcia [Mon, 23 Feb 2026 23:40:37 +0000 (23:40 +0000)]
Added an option to skip the F5 CLA workflow.

There are some scenarios where the F5 CLA workflow should not run. This commit adds the ability to skip the F5 CLA by using the "skip-cla" label.

2 months agoQUIC: improved error handling in OpenSSL compat layer.
user.email [Tue, 24 Feb 2026 01:33:57 +0000 (19:33 -0600)]
QUIC: improved error handling in OpenSSL compat layer.

Previously ngx_quic_compat_create_record() could try to encrypt a TLS
record even if encryption context was missing, which resulted in a NULL
pointer dereference.

The context is created by ngx_quic_compat_set_encryption_secret() called
from the OpenSSL keylog callback.  If an error occurred in that function,
the context could remain missing.  This could happen under memory pressure,
if an allocation failed inside this function.

The fix is to handle errors from ngx_quic_compat_set_encryption_secret()
and set qc->error to trigger an error after SSL_do_handshake() return.
Also, a check for context is added to ngx_quic_compat_create_record()
to avoid other similar issues.

2 months agoQUIC: worker-bound stateless reset tokens.
Roman Arutyunyan [Thu, 26 Feb 2026 14:36:52 +0000 (18:36 +0400)]
QUIC: worker-bound stateless reset tokens.

Previously, it was possible to obtain a stateless reset token for a
connection by routing its packet to a wrong worker.  This allowed to
terminate the connection.

The fix is to bind stateless reset token to the worker number.

2 months agoUpdating welcome page with links and more details.
buulam [Fri, 20 Feb 2026 15:25:53 +0000 (07:25 -0800)]
Updating welcome page with links and more details.

2 months agoQUIC: fixed bpf compilation with newer Linux kernels.
Roman Arutyunyan [Tue, 24 Sep 2024 10:53:45 +0000 (14:53 +0400)]
QUIC: fixed bpf compilation with newer Linux kernels.

QUIC bpf program previously used struct bpf_map_def which was
deprecated in [1] (kernel version 5.18) and removed in [2] (kernel 6.1).
New-style BTF map definitions were added in [3] (linux kernel 5.3).

Switching the program to BTF is however not necessary since nginx has
its own relocation procedure which allows referencing the real map
structure by its file descriptor allocated earlier.  In particular,
bpf instruction BPF_LD_IMM64 (0x18/0x0) is substituted with instruction
BPF_LD_MAP_FD (0x18/0x1) and map_fd is stored in the imm field, see [4]
and [5] for details.

To fix compilation, struct bpf_map_def is changed to a known type (int)
and "extern" is added to indicate external linkage and reduce object
file size.

[1] https://github.com/torvalds/linux/commit/93b8952d223af03c51fba0c6258173d2ffbd2cb7
[2] https://github.com/torvalds/linux/commit/dc567045f1590f6460d3e9a6ea6ad5e600b58b84
[3] https://github.com/torvalds/linux/commit/abd29c9314595b1ee5ec6c61d7c49a497ffb30a3
[4] https://github.com/torvalds/linux/blob/master/include/linux/filter.h
[5] https://datatracker.ietf.org/doc/rfc9669/

2 months agoQUIC: Stateless Reset rate limiting.
Sergey Kandaurov [Wed, 25 Feb 2026 17:09:21 +0000 (21:09 +0400)]
QUIC: Stateless Reset rate limiting.

It uses a bloom filter to limit sending Stateless Reset packets no more
than once per second in average for the given address.  This allows to
address resource asymmetry from precomputed packets, as well as to limit
potential Stateless Reset exchange.

2 months agoQUIC: refactored ngx_quic_address_hash().
Sergey Kandaurov [Wed, 25 Feb 2026 17:07:01 +0000 (21:07 +0400)]
QUIC: refactored ngx_quic_address_hash().

Now it accepts an optional salt, to be used in a subsequent change.

2 months agoQUIC: moved ngx_quic_address_hash().
Sergey Kandaurov [Fri, 20 Feb 2026 15:01:20 +0000 (19:01 +0400)]
QUIC: moved ngx_quic_address_hash().

2 months agoQUIC: limited size of generated Stateless Reset packets.
Sergey Kandaurov [Fri, 20 Feb 2026 14:52:56 +0000 (18:52 +0400)]
QUIC: limited size of generated Stateless Reset packets.

Made sure to send packets smaller than the triggering packet,
following RFC 9000, Section 10.3.3.

Reported-by: cyberspace61
2 months agoQUIC: adjusted minimum packet size to send Stateless Reset.
Sergey Kandaurov [Fri, 20 Feb 2026 14:59:06 +0000 (18:59 +0400)]
QUIC: adjusted minimum packet size to send Stateless Reset.

Now to be valid, it also assumes the Connection ID we require from a client.

2 months agoResolver: fixed off-by-one read in ngx_resolver_copy().
Roman Arutyunyan [Mon, 23 Feb 2026 14:29:16 +0000 (18:29 +0400)]
Resolver: fixed off-by-one read in ngx_resolver_copy().

It is believed to be harmless, see a similar change 077a890a76ff.

Reported-by: geeknik <geeknik@protonmail.ch>
2 months agoMp4: validate sync sample values in stss atom.
CodeByMoriarty [Mon, 23 Feb 2026 00:45:47 +0000 (16:45 -0800)]
Mp4: validate sync sample values in stss atom.

Per ISO 14496-12 Section 8.6.2, sync sample numbers must be 1-based.
A zero-valued stss entry caused ngx_http_mp4_seek_key_frame() to
return a key_prefix exceeding the samples consumed in the forward
stts pass, which led the backward loop in ngx_http_mp4_crop_stts_data()
to walk past the beginning of the stts data buffer.

The fix validates each stss entry in ngx_http_mp4_seek_key_frame()
and returns an error if a zero sync sample is encountered.  The
function signature is changed to return ngx_int_t so it can signal
errors to the caller.

2 months agoSCGI: fixed passing CONTENT_LENGTH in unbuffered mode.
Sergey Kandaurov [Fri, 30 Jan 2026 13:06:38 +0000 (17:06 +0400)]
SCGI: fixed passing CONTENT_LENGTH in unbuffered mode.

Passing requests to SCGI uses a recalculated size of a request body
as per changes made in d60b8d10f (1.3.9) to support CONTENT_LENGTH
with chunked body requests.  This, however, is not compatible with
unbuffered mode introduced later in 7ec559df5 (1.7.11), where such
an approach may not always represent complete request body.

The fix is to use r->headers_in.content_length_n representing either
original Content-Length, if any, or a recalculated value from request
body filters, such as chunked body filter.

Reported by Mufeed VH.

2 months agoImproved $cookie_ evaluation.
Vadim Zhestikov [Fri, 19 Dec 2025 00:45:21 +0000 (16:45 -0800)]
Improved $cookie_ evaluation.

In case "Cookie" header is sent by client, multiple cookie pairs were
incorrectly split by a semicolon and comma.

Now they are split by a semicolon only.

For example, next variables will be found for "Cookie: a=b, c=d; e=f":
- $cookie_a: "b, c=d"
- $cookie_e: "f"

Closes #1042 on GitHub.

2 months agoProxy: fixed HTTP/2 upstream with caching enabled.
Roman Arutyunyan [Wed, 11 Feb 2026 12:29:37 +0000 (12:29 +0000)]
Proxy: fixed HTTP/2 upstream with caching enabled.

Previously, when proxy_cache and keepalive were both enabled with an
HTTP/2 upstream, the second request for a cached resource could fail with
"upstream sent frame for unknown stream" error followed by "cache file
contains invalid header".

This happened because ctx->id was set to 1 in the case when no upstream
connection exists (e.g. cache hit), making the stream id check fail when
the cached response contained frames from a different stream.

The fix is to set ctx->id to 0 when there is no upstream connection,
indicating that no real stream exists, and skip the stream id validation
in this case.  Also, ctx->id = 1 is now set only for new connections,
not in the shared done label.

Closes: https://github.com/nginx/nginx/issues/1101
2 months agoVersion bump.
Roman Arutyunyan [Wed, 11 Feb 2026 14:54:35 +0000 (18:54 +0400)]
Version bump.

3 months agonginx-1.29.5-RELEASE release-1.29.5
Roman Arutyunyan [Wed, 4 Feb 2026 13:43:03 +0000 (17:43 +0400)]
nginx-1.29.5-RELEASE

3 months agoUpstream: reinit upstream after reading bad response.
Roman Arutyunyan [Wed, 28 Jan 2026 16:38:38 +0000 (20:38 +0400)]
Upstream: reinit upstream after reading bad response.

Previously, when connecting to a backend, if the read event handler was
called before the write event handler, and the received response triggered
a next upstream condition, then ngx_http_upstream_reinit() was not called
to clean up the old upstream context.  This had multiple implications.

For all proxy modules, since the last upstream response was not cleaned up,
it was mixed with the next upstream response.  This could result in ignoring
the second response status code, duplicate response headers or reporting
old upstream header errors.

With ngx_http_grpc_module and ngx_http_proxy_v2_module, ctx->connection
was left dangling since the object it referenced was allocated from the
last upstream connection pool, which was deleted when freeing last upstream.
This lead to use-after-free when trying to reuse this object for the next
upstream.

3 months agoUpstream: detect premature plain text response from SSL backend.
Roman Arutyunyan [Thu, 29 Jan 2026 09:27:32 +0000 (13:27 +0400)]
Upstream: detect premature plain text response from SSL backend.

When connecting to a backend, the connection write event is triggered
first in most cases.  However if a response arrives quickly enough, both
read and write events can be triggered together within the same event loop
iteration.  In this case the read event handler is called first and the
write event handler is called after it.

SSL initialization for backend connections happens only in the write event
handler since SSL handshake starts with sending Client Hello.  Previously,
if a backend sent a quick plain text response, it could be parsed by the
read event handler prior to starting SSL handshake on the connection.
The change adds protection against parsing such responses on SSL-enabled
connections.

3 months agoUpdated OpenSSL and PCRE used for win32 builds.
Roman Arutyunyan [Tue, 3 Feb 2026 14:29:43 +0000 (18:29 +0400)]
Updated OpenSSL and PCRE used for win32 builds.

3 months agoOutput chain: clear the last_buf flag unless inherited.
Sergey Kandaurov [Wed, 24 Dec 2025 21:21:52 +0000 (01:21 +0400)]
Output chain: clear the last_buf flag unless inherited.

For instance, the last_buf flag is used in the http proxy module when
creating HTTP/2 requests to indicate the output is closed.  The flag
is inherited in ngx_output_chain() to a destination buffer when reading
the buffered request body.  Then it is used in the proxy output filter
to mark the last HTTP/2 DATA frame with END_STREAM.

The problem happens when reusing the destination buffer, such as to
re-read the buffered request body on next upstream, because this buffer
may contain a dirty last_buf value, which breaks sending HTTP/2 request
body in multiple output filter calls.

The flush and last_in_chain flags are cleared for consistency.

3 months agoProxy: fixed sending HTTP/2 buffered request body on next upstream.
Sergey Kandaurov [Wed, 24 Dec 2025 18:59:40 +0000 (22:59 +0400)]
Proxy: fixed sending HTTP/2 buffered request body on next upstream.

If a buffered request body wasn't fully sent, such as on early upstream
response or limited by flow control, unsent buffers could remain in the
input or busy chains when switching to the next upstream server.  This
resulted either in the invalid request sent or a stalled connection.

The fix is to reset chains similar to ngx_http_upstream_reinit().

3 months agoClarify binding behavior of -t option.
Luboš Uhliarik [Tue, 20 Jan 2026 18:27:05 +0000 (19:27 +0100)]
Clarify binding behavior of -t option.

Configuration testing includes binding to configured listen addresses
when opening referenced files.

3 months agoMisc: revised GitHub documentation in generated ZIP archive.
Sergey Kandaurov [Thu, 15 Jan 2026 12:19:29 +0000 (16:19 +0400)]
Misc: revised GitHub documentation in generated ZIP archive.

Now all GitHub .md files will reside in the docs directory.
While expicitly listing all files might be better for clarity,
this eliminates the need to touch "zip" target every such time.
This includes a recently added SUPPORT.md in 367113670.

3 months agoRange filter: reasonable limit on multiple ranges.
Sergey Kandaurov [Tue, 13 Jan 2026 12:51:07 +0000 (16:51 +0400)]
Range filter: reasonable limit on multiple ranges.

A total response length with multiple ranges can be larger than the
source response size due to multipart boundary headers.  This change
extends max ranges limit imposed in c2c3e3105 (1.1.2) by accounting
boundary headers.  Notably, this covers suspicious requests with a
lot of small ranges that have an increased processing overhead and
are susceptible to range based amplification attacks.

The limit disables ranges as long as a total response length comes
close to the source size, additionally penalizing small size ranges
on a large source size where a processing overhead prevails, while
leaving a room for more ranges on a small source size, such that it
should not affect well-behaving applications.  The limit can be
altered with the "max_ranges" directive.

Closes #988 on GitHub.

3 months agoYear 2026.
Sergey Kandaurov [Thu, 15 Jan 2026 11:54:11 +0000 (15:54 +0400)]
Year 2026.

3 months agoUwsgi: ensure HTTP_HOST is set to the requested target host.
Andrew Clayton [Sat, 13 Dec 2025 07:05:27 +0000 (07:05 +0000)]
Uwsgi: ensure HTTP_HOST is set to the requested target host.

Previously, the HTTP_HOST environment variable was constructed from the
Host request header field, which doesn't work well with HTTP/2 and
HTTP/3 where Host may be supplanted by the ":authority" pseudo-header
field per RFC 9110, section 7.2. Also, it might give an incorrect
HTTP_HOST value from HTTP/1.x requests given in the absolute form, in
which case the Host header must be ignored by the server, per RFC 9112,
section 3.2.2.

The fix is to redefine the HTTP_HOST default from a protocol-specific
value given in the $host variable. This will now use the Host request
header field, ":authority" pseudo-header field, or request line target
URI depending on request HTTP version.

Also the CGI specification (RFC 3875, 4.1.18) notes

  The server SHOULD set meta-variables specific to the protocol and
  scheme for the request. Interpretation of protocol-specific
  variables depends on the protocol version in SERVER_PROTOCOL.

3 months agoSCGI: ensure HTTP_HOST is set to the requested target host.
Andrew Clayton [Sat, 13 Dec 2025 07:05:27 +0000 (07:05 +0000)]
SCGI: ensure HTTP_HOST is set to the requested target host.

Previously, the HTTP_HOST environment variable was constructed from the
Host request header field, which doesn't work well with HTTP/2 and
HTTP/3 where Host may be supplanted by the ":authority" pseudo-header
field per RFC 9110, section 7.2. Also, it might give an incorrect
HTTP_HOST value from HTTP/1.x requests given in the absolute form, in
which case the Host header must be ignored by the server, per RFC 9112,
section 3.2.2.

The fix is to redefine the HTTP_HOST default from a protocol-specific
value given in the $host variable. This will now use the Host request
header field, ":authority" pseudo-header field, or request line target
URI depending on request HTTP version.

Also the CGI specification (RFC 3875, 4.1.18) notes

  The server SHOULD set meta-variables specific to the protocol and
  scheme for the request. Interpretation of protocol-specific
  variables depends on the protocol version in SERVER_PROTOCOL.

3 months agoFastCGI: ensure HTTP_HOST is set to the requested target host.
Andrew Clayton [Sat, 13 Dec 2025 07:05:27 +0000 (07:05 +0000)]
FastCGI: ensure HTTP_HOST is set to the requested target host.

Previously, the HTTP_HOST environment variable was constructed from the
Host request header field, which doesn't work well with HTTP/2 and
HTTP/3 where Host may be supplanted by the ":authority" pseudo-header
field per RFC 9110, section 7.2. Also, it might give an incorrect
HTTP_HOST value from HTTP/1.x requests given in the absolute form, in
which case the Host header must be ignored by the server, per RFC 9112,
section 3.2.2.

The fix is to redefine the HTTP_HOST default from a protocol-specific
value given in the $host variable. This will now use the Host request
header field, ":authority" pseudo-header field, or request line target
URI depending on request HTTP version.

Also the CGI specification (RFC 3875, 4.1.18) notes

  The server SHOULD set meta-variables specific to the protocol and
  scheme for the request. Interpretation of protocol-specific
  variables depends on the protocol version in SERVER_PROTOCOL.

Closes: https://github.com/nginx/nginx/issues/256
Closes: https://github.com/nginx/nginx/issues/455
Closes: https://github.com/nginx/nginx/issues/912
4 months agoWin32: fixed C4319 warning with MSVC 2022 x86.
Aleksei Bavshin [Tue, 23 Dec 2025 18:44:13 +0000 (10:44 -0800)]
Win32: fixed C4319 warning with MSVC 2022 x86.

The warning started to appear in Visual Studio 2022 version 17.14.21,
which corresponds to the C/C++ compiler version 19.44.35221.

The appropriate fix is to avoid mixing uint64_t and ngx_uint_t in an
expression with bitwise operations.  We can do that here because both
the original shm->size value and the result of the expression are 32-bit
platform words.

4 months agoSSL: logging level of the "ech_required" TLS alert.
Roman Arutyunyan [Tue, 16 Dec 2025 13:53:12 +0000 (17:53 +0400)]
SSL: logging level of the "ech_required" TLS alert.

The alert is send by a client after its ECH configuration was rejected by
a server.

4 months agoFixed duplicate ids in the bug report template.
Aleksei Bavshin [Mon, 15 Dec 2025 20:49:37 +0000 (12:49 -0800)]
Fixed duplicate ids in the bug report template.

4 months agoVersion bump.
Aleksei Bavshin [Tue, 16 Dec 2025 21:18:30 +0000 (13:18 -0800)]
Version bump.

5 months agonginx-1.29.4-RELEASE release-1.29.4
Sergey Kandaurov [Tue, 9 Dec 2025 15:12:35 +0000 (19:12 +0400)]
nginx-1.29.4-RELEASE

5 months agoQUIC: fixed possible segfault on handshake failures.
Jan Svojanovsky [Tue, 9 Dec 2025 11:27:02 +0000 (12:27 +0100)]
QUIC: fixed possible segfault on handshake failures.

When using OpenSSL 3.5, the crypto_release_rcd QUIC callback can be
called late, after the QUIC connection was already closed on handshake
failure, resulting in a segmentation fault.  For instance, it happened
if a client Finished message didn't align with a record boundary.

5 months agoProxy: cache support for HTTP/2.
Zhidao HONG [Sun, 30 Nov 2025 16:35:31 +0000 (16:35 +0000)]
Proxy: cache support for HTTP/2.

5 months agoProxy: buffering support for HTTP/2.
Zhidao HONG [Sun, 30 Nov 2025 16:32:15 +0000 (16:32 +0000)]
Proxy: buffering support for HTTP/2.

5 months agoProxy: extracted control frame and skip functions for HTTP/2.
Zhidao HONG [Sun, 30 Nov 2025 16:27:26 +0000 (16:27 +0000)]
Proxy: extracted control frame and skip functions for HTTP/2.

5 months agoProxy: extracted ngx_http_proxy_v2_process_frames() function.
Zhidao HONG [Sun, 30 Nov 2025 16:24:24 +0000 (16:24 +0000)]
Proxy: extracted ngx_http_proxy_v2_process_frames() function.

5 months agoProxy: added HTTP/2 proxy module.
Zhidao HONG [Tue, 15 Jul 2025 15:35:39 +0000 (15:35 +0000)]
Proxy: added HTTP/2 proxy module.

The module allows to use HTTP/2 protocol for proxying.
HTTP/2 proxying is enabled by specifying "proxy_http_version 2".

Example:

    server {
        listen 8000;

        location / {
            proxy_http_version 2;
            proxy_pass https://127.0.0.1:8443;
        }
    }

    server {
        listen 8443 ssl;
        http2 on;

        ssl_certificate certs/example.com.crt;
        ssl_certificate_key certs/example.com.key;

        location / {
            return 200 foo;
        }
    }

5 months agoProxy: refactored for HTTP/2 support.
Roman Arutyunyan [Tue, 15 Jul 2025 15:03:39 +0000 (15:03 +0000)]
Proxy: refactored for HTTP/2 support.

5 months agoUpstream: add support for connection level ALPN protocol negotiation.
Zhidao HONG [Tue, 15 Jul 2025 14:54:21 +0000 (14:54 +0000)]
Upstream: add support for connection level ALPN protocol negotiation.

This commit is prepared for HTTP/2 and HTTP/3 support.

The ALPN protocol is now set per-connection in
ngx_http_upstream_ssl_init_connection(), allowing proper protocol negotiation
for each individual upstream connection regardless of SSL context sharing.

5 months 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.

5 months 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.

5 months 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.

5 months 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.

5 months 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.

5 months 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.

5 months 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 months 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 months 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 months 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).

6 months 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.

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

6 months 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>

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

6 months 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.

6 months 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

7 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.

7 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.

7 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.

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

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

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

7 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.

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

7 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.