The real difference between $host and $http_host

speedfirst nginx-forum at
Mon Aug 15 07:30:20 UTC 2011

The wiki page of "$host" says $host and $host_addr are different only
when there is no "Host" header or the "Host" header is empty. But I
found when "Host" contains port number, $host never contains the port
number while $http_host is equal to the value of "Host" header.

That is, if "Host: foo:8080", then
$http_host = foo:8080
$host = foo

So in this case, they are different.

Tested in nginx 1.0.3

I want the official confirmation of this difference. And if it's
confirmed, could you correct the illustration in wiki page?


Posted at Nginx Forum:,213799,213799#msg-213799

More information about the nginx mailing list