SERVER_ADDR env var is broken

At least in RewriteCond directives in a .htaccess context, but probably elsewhere as well, this value contains the Listener Address setting. However, under Apache, it contains the actual IP address to which the connection was made, which seems like a clear incompatibility. All the code I've seen with SERVER_ADDR expects it to be an IP address.

Tested with this in .htaccess:
Apache config:
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_ADDR} .+
RewriteRule ^dump\.php$ - [END,E=lsws_server_addr:%0]
Then in dump.php:
header('Content-Type: text/plain');
var_dump($_SERVER['SERVER_ADDR'], $_SERVER['lsws_server_addr']);
Under Apache (on a private IP) I get this:
string(9) ""
string(9) ""
Under LSWS it's like this:
string(14) ""
string(5) "*:443"
Last edited: