How to log virtual server name
Francis Daly
francis at daoine.org
Mon Feb 27 23:35:54 UTC 2012
On Mon, Feb 27, 2012 at 10:49:38PM +0000, Lucian D. Kafka wrote:
Hi there,
> 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.
>
The following "http" section of nginx.conf allows me to see content from
two different directories, depending on the Host: header in the request;
and includes the hostname used in the Host: header in the access_log file.
It behaves for me as the documentation describes.
What is the difference between this and the configuration file you
are using?
===
http {
log_format mine '$host $remote_addr - "$request" $status';
access_log logs/mine.log mine;
server {
server_name one two;
listen 8000;
root one;
}
server {
server_name three;
listen 8000 default_server;
root three;
}
}
===
If I use $http_host instead of $host, I see whatever the client sent --
including the :port part.
Testing using commands like
curl -i http://localhost:8000/
curl -i -H 'Host: one' http://localhost:8000/
curl -i -H 'Host: two:66' http://localhost:8000/
curl -i -H 'Host: three' http://localhost:8000/
shows me the content and the log lines that I expect, as above.
So: I'm unable to reproduce the problem you report, using a configuration
that seems to match your text. Can you provide a (minimal?) config file
that shows the problem for you?
Cheers,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list