Skip to content

Allowed square brackets with portless IPv6 address. #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

arut
Copy link
Contributor

@arut arut commented Nov 13, 2024

In several places in nginx, when an address with an optional port is expected, IPv6 address could be specified without square brackets and without port, as well as both with the brackets and port. The change allows IPv6 in square brackets and no port, which was previously considered an error.

As a reference, this format is also allowed by RFC 9110 for the "Host" header, and by RFC 7239 for "Forwarded by/for".

The change affects headers parsing in ngx_http_realip_module, as well as proxy_bind and friends.

@arut arut requested a review from pluknet November 18, 2024 16:45
@Maryna-f5 Maryna-f5 added this to the nginx-1.27.3 milestone Nov 21, 2024
Copy link
Contributor

@pluknet pluknet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch looks good.

Allowed square brackets with portless IPv6 address.

The text is misleading, IMHO.
For me, this reads primarily as of the listen directive.

As a reference, this format is also allowed by RFC 9110 for the "Host"
header, and by RFC 7239 for "Forwarded by/for".

I would mention foremost RFC 3986, referenced in both 9110 and 7239. Something like this:

: This format conforms to the RFC 3986 format.

Strictly speaking, RFC 9110 and 7239 have indirect relationship to ngx_parse_add_port consumers, such as proxy_bind and X-Forwarded-For, so probably it makes sense to omit them for brevity.

When client address is received, IPv6 address could be specified without
square brackets and without port, as well as both with the brackets and
port.  The change allows IPv6 in square brackets and no port, which was
previously considered an error.  This format conforms to RFC 3986.

The change also affects proxy_bind and friends.
@arut arut merged commit b2a67d2 into nginx:master Nov 26, 2024
1 check passed
@arut arut deleted the realip-ipv6-addr branch November 26, 2024 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants