I have a cluster of nginx web servers and a separate syslog server running rsyslog. The nginx vhost looks like this:
access_log syslog:server=10.0.0.51,facility=local1,severity=info combined;
error_log syslog:server=10.0.0.51,facility=local2 debug;
And the custom rsyslog config like this:
$template access_log,"/var/syslog/%HOSTNAME%/%PROGRAMNAME%/access.log"
$template error_log,"/var/syslog/%HOSTNAME%/%PROGRAMNAME%/error.log"
local1.* -?access_log
local2.* -?error_log
It works great but I would like to create separate log files on rsyslog for the different vhosts, so, e.g.,
/var/syslog/my-hostname/nginx/example.org-access.log
/var/syslog/my-hostname/nginx/somedomain.com-access.log
And so on. How can I pass the host from nginx to rsyslog?