Welcome! Log In Create A New Profile

Advanced

Re: How to log virtual server name

Francis Daly
February 27, 2012 06:38PM
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@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to log virtual server name

Lucian D. Kafka February 27, 2012 01:20AM

Re: How to log virtual server name

Igor Sysoev February 27, 2012 01:24AM

RE: How to log virtual server name

Lucian D. Kafka February 27, 2012 05:50PM

Re: How to log virtual server name

Francis Daly February 27, 2012 06:38PM

RE: How to log virtual server name

Lucian D. Kafka February 27, 2012 09:30PM

Re: How to log virtual server name

Francis Daly February 28, 2012 01:54PM

Re: How to log virtual server name

Piotr Sikora February 27, 2012 01:28AM

Re: How to log virtual server name

Roger Pack August 07, 2013 03:10PM

Re: How to log virtual server name

B.R. August 07, 2013 03:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 162
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready