$_SERVER['SERVER_NAME'] returns an incorrect value when using IPv6
$_SERVER['SERVER_NAME'] returns an incorrect value when using IPv6. i.e., when accessing a site at http://[2001:860:fc29:5000::1], $_SERVER['SERVER_NAME'] would contain "[2001".
Steps to Replicate:
1. Create this script:
<?php var_dump($_SERVER); ?>
2. Run the above script via IPv6.
$_SERVER['SERVER_NAME'] should contain a valid IPv6 address.
[mod_*cgi,mod_accesslog] Fix splitting :port with ipv6 (fixes #2333, thx simoncpu)
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2834 152afb58-edef-0310-8abb-c4023f1b3aa9
Updated by simoncpu almost 7 years ago
I don't have a working Apache setup right now, but it seems that they wrap IPv6 addresses in brackets too:
nginx, however, uses my machine's hostname if I don't set a server_name statement in the configuration.
Updated by stbuehler over 6 years ago
- you can cat the patches into one file next time :)
- i think these patches fail when you use dns names, like "Host: lighttpd.net:443" - lighttpd.net has an IPv6 address, so the socket type could be IPv6, but there is no [...]:443. i'd say if the first (non white-space?) char is '[' then search for ']:', otherwise for ':'. (this also means we can test it easier, as this doesn't depend on the socket type, just on the Host: header)
- it would be very nice if you could add some test-cases for this, probably in the mod_fastcgi part.
Updated by simoncpu over 6 years ago
lighttpd patch, take 5 hehehe:
This has been tested with:
- example.org (both IPv4 and IPv6)
- example.org:8080 (both IPv4 and IPv6)
- with and without --disable-ipv6
Also available in: Atom