Welcome! Log In Create A New Profile

Advanced

IPv6 addresses for host name are incorrectly trimmed by nginx

Phil Bayfield
November 28, 2010 02:28PM
I'm trying to test IPv6 on a couple of sites and I seem to have encountered
a bug with nginx.

I have 2 backend servers behind a proxy, all servers run nginx 0.8.53.

If I enter the IPv6 address into the browser, the address is trimmed when it
reaches the backend server.

Here is an example using PHP:

Direct request to backend server (works):

http://[2a02:40:40:7::3]/test.php
$_SERVER['HTTP_HOST'] = [2a02:40:40:7::3]

Via proxy:

http://[2a02:40:40:7::7]/test.php
$_SERVER['HTTP_HOST'] = [2a02:40:40:7:

It appears the last semi colon and number are trimmed off the IPv6 address,
for example if I enter the full IPv6 address I get this:

http://[2a02:40:40:7:0:0:0:7]/test.php
$_SERVER['HTTP_HOST'] = [2a02:40:40:7:0:0:0

I've spent a couple of hours trying different scenarios and added custom
logging to log the value of the $host variable and as far as I can tell
nginx seems to always incorrectly trim the value of $host for IPv6
addresses.

Here is an example log entry, with an incorrectly logged host name:

[28/Nov/2010:17:50:08 +0000] [2a02:40:40:7: "GET /test.php HTTP/1.1"

The funny thing is that the correct value is always passed to PHP (for
direct requests), but the value of $host is always trimmed incorrectly.
As the host name is passed to the backend server via a proxy_set_header
directive the incorrect value is always passed to the backend and therefore
incorrectly passed to PHP in this instance.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

IPv6 addresses for host name are incorrectly trimmed by nginx

Phil Bayfield November 28, 2010 02:28PM

Re: IPv6 addresses for host name are incorrectly trimmed by nginx

Phil Bayfield November 28, 2010 04:34PM

Re: IPv6 addresses for host name are incorrectly trimmed by nginx

Maxim Dounin November 28, 2010 08:22PM

Re: IPv6 addresses for host name are incorrectly trimmed by nginx

Phil Bayfield November 29, 2010 03:14AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 313
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready