Nginx, where does the host name in this error come from?

Danack asked:

I have a server setup with the name ‘api.mydomain.com’. I have an error being generated by the application, and the error text is being appropriately logged as:

[error] 9#9: *6916 FastCGI sent in stderr: “application error
removed
” while reading response header from upstream, client:
172.24.0.5, server: *.api.mydomain.com, request: “GET / HTTP/1.1”, upstream: “fastcgi://172.24.0.3:9000”, host:
“hostmaster.anotherdomain.com”

However…I am completely confused as to where the domain “hostmaster.anotherdomain.com” is coming from.

It is another domain I control, and that domain has a wildcard subdomain setup, so it resolves to the same IP address as ‘api.mydomain.com’. But I would much rather than correct host name was used.

Any ideas where that host name can be coming from? Or how to tell (presumably) Nginx to use the correct host name in the log?

My answer:


In nginx error log entries such as this:

The “server:” indicates the server_name of the server block which handled the request.

The “host:” indicates the hostname sent by the browser or user agent in the Host: request header.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.