I'm trying to test IPv6 on a couple of sites and I seem to have encountered a bug with nginx.
<div><br></div><div>I have 2 backend servers behind a proxy, all servers run nginx 0.8.53.</div><div><br></div><div>If I enter the IPv6 address into the browser, the address is trimmed when it reaches the backend server.</div>
<div><br></div><div>Here is an example using PHP:</div><div><br></div><div>Direct request to backend server (works):</div><div><br></div><div>http://[2a02:40:40:7::3]/test.php</div><div>$_SERVER[&#39;HTTP_HOST&#39;] = [2a02:40:40:7::3]</div>
<div><br></div><div>Via proxy:</div><div><br></div><div>http://[2a02:40:40:7::7]/test.php</div><div>$_SERVER[&#39;HTTP_HOST&#39;] = [2a02:40:40:7:</div><div><br></div><div>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:</div>
<div><br></div><div>http://[2a02:40:40:7:0:0:0:7]/test.php</div><div>$_SERVER[&#39;HTTP_HOST&#39;] = [2a02:40:40:7:0:0:0</div><div><br></div><div>I&#39;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.</div>
<div><br></div><div>Here is an example log entry, with an incorrectly logged host name:</div><div><br></div><div>[28/Nov/2010:17:50:08 +0000] [2a02:40:40:7: &quot;GET /test.php HTTP/1.1&quot;</div><div><br></div><div>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.</div>
<div>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.</div>