Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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? - - [31/Aug/2011:01:32:17 +0000] "GET /?p=12 HTTP/1.1" 200 2820 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +"
share|improve this question
up vote 9 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.

share|improve this answer
You'd now use it like this: access_log /var/log/nginx/access.log timed_combined; – Hengjie Jan 2 '13 at 21:54
While editing my nginx.conf file, I had to ensure timed_combined was defined before using it in the 'access_log' setting. If not defined before, nginx failed to start. – Brad Goss Jun 29 at 15:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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