I setup Nginx to server multiple websites from a single virtual host by doing this (A Default Catchall Virtual Host):

server {  
    listen   80 default;
    server_name  _;

However, my access logs are recording "_" instead of the site's domain name. How can I configure Nginx to record the host?

129.221.111.22 - - [31/Aug/2011:01:32:17 +0000] "GET /?p=12 HTTP/1.1" 200 2820 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"
link|improve this question

64% accept rate
feedback

1 Answer

up vote 3 down vote accepted

After reading the docs a second time I realized that the "_" is the referer.

I ended up going with:

log_format timed_combined '$remote_addr - $remote_user [$time_local]  '
                '"$request" $status $body_bytes_sent '
                '"$http_referer" "$http_user_agent" "$host" $request_time';

Which appends the host and the time the request took to process to the end of the log.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.