Configure nginx to log the virtual host
By : Josh -
Nginx does not have the concept of virtual host like Apache does — nginx refers to the apache virtual host as the server.
To log the requested host with each request, which makes troubleshooting when multiple sites are hosted on the same instance much easier, use the following format:
log_format main '$remote_addr $host $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$request_body"' ;
Note the addition of $host and the removal of the ‘-‘ in the first line.
The next step is to tell nginx to use this for the access_log (or any log) with something like the following:
access_log logs/access.log main;
Once that is complete, send a HUP signal to nginx and it will begin logging the virtual host/server name to the access log(s).