$http_host and $host not behaving as described

From http://wiki.nginx.org/NginxHttpCoreModule#.24host:


This variable is equal to line Host in the header of request or name
of the server processing the request if the Host header is not

This variable may have a different value from $http_host when the Host
input header is absent or has an empty value.

The value of the HTTP header HEADER when converted to lowercase and
with ‘dashes’ converted to ‘underscores’, e.g. $http_user_agent,

When I log $host and $http_host, I see different things, yet the Host
HTTP header is set and non-empty.

I’m running an HTTP server on port 80 and I’m logging:

log_format dummy ‘$host $http_host’;
access_log>-/tmp/dummy dummy;

When I browse to http://localhost:8989/ where I have a proxy
forwarding 8989 to 80 (e.g. 2 nc’s piped together, socat, or ssh
tunneling), I see this in the log:

$ tail -f /tmp/dummy
localhost localhost:8989

Yet if I intercept the HTTP request headers, I see:

GET / HTTP/1.1
Host: localhost:8989
Connection: keep-alive
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US)
AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4
Cache-Control: max-age=0
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

Host is set and non-empty. Anybody know what’s going on? Does the wiki
need to be updated? I’m using nginx 0.7.65 (from Jeff W.'s PPA).
Thanks in advance.

Yang Z.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs