How to log virtual server name

Lucian D. Kafka luci at
Mon Feb 27 22:49:38 UTC 2012

Hi Igor, thank you very much for your reply.

The _problem_ is that Nginx does not behave as the documentation describes. Entering multiple server names in one server_name directive and using $http_host do not work.

When I enter more than 1 server name I get a warning message: Restarting nginx: nginx: [warn] conflicting server name "" on x.x.x.x:80, ignored (there is only one mention of this server name anywhere  - I have grepped all config files looking for a runaway).

In terms of logging, $http_host (and all other variables I tried to get a host name out of) is _empty_ unless there is a server_name match on 'certain' one name in the server_name list...

What could cause $http_host to loose its value even if the server_name does not populate correctly?

I am using nginx version: nginx/1.0.11. I will try to see if I can pinpoint the issue further...



-----Original Message-----
From: nginx-bounces at [mailto:nginx-bounces at] On Behalf Of Igor Sysoev
Sent: Monday, 27 February 2012 5:23 PM
To: nginx at
Subject: Re: How to log virtual server name

On Mon, Feb 27, 2012 at 06:18:00AM +0000, Lucian D. Kafka wrote:
> Hi All,
> We have a virtual hosting setup where multiple domains are delegated to the same server IP address, and Nginx acts as a caching proxy server in front of the  web server.
> I am encountering 2 issues:
> 1.       Cannot set more than 1 server name - Nginx is ignoring multiple server names defined on the same IP with a warning message

This may help:

> 2.       Cannot log the virtual server name (Apache %v equivalent) to the access_log. Any variable in the custom log format - ie. $server_name, $host, etc does not log the Host headers, but rather the server name string set with the server_name directive (if matched). This makes it impossible to have a combined log file for different sites set in a virtual hosting environment on the same IP address.


Igor Sysoev

nginx mailing list
nginx at

More information about the nginx mailing list