IPv6 addresses for host name are incorrectly trimmed by nginx
Phil Bayfield
phil at techlightenment.com
Sun Nov 28 22:19:17 MSK 2010
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20101128/61413693/attachment.html>
More information about the nginx
mailing list