nkt
nkt

Reputation: 403

Nginx identify domain in log files

I have set up nginx for some sites. In their .conf files, there can be server_name with multiple domains. However, when checking the log file, the domain name can't be identified. Is it possible to find out which domain?

Upvotes: 0

Views: 2933

Answers (1)

Horacio
Horacio

Reputation: 2965

Yes you can!

you should add $server_name in your log_format sentence. Could looks like

log_format compression '$server_name $remote_addr - $remote_user [$time_local] '
                           '"$request" $status $body_bytes_sent '
                           '"$http_referer" "$http_user_agent" "$gzip_ratio"';

and after reload nginx you should be able to see the server name on your access log

Upvotes: 2

Related Questions