nginx logging and rotation by domain

a server has mulitple settings under /etc/nginx/sites-enabled. Each has a directives for having a domain specific log.

access_log  /var/log/nginx/access_domain_x.log;
error_log  /var/log/nginx/error_domain_x.log;

However, /etc/logrotate.d/nginx is presently configured to rotate all logs into a single file, via the wildcard. [various directives, such as compress removed for sake of brevity]

/var/log/nginx/*.log {
        daily
        missingok
        rotate 14
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi \
        endscript
        postrotate
                invoke-rc.d nginx rotate >/dev/null 2>&1
        endscript
}

This may be set with a block for each individual domain, as follows, but it is not evident how the rotated log should be named:

/var/log/nginx/*_domain_x.log {
        daily
        missingok
        rotate 14
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi \
        endscript
        postrotate
                invoke-rc.d nginx rotate >/dev/null 2>&1
        endscript
}

how should /etc/logrotate.d/nginx be then configured? or could/should it be the object of a different file?

Read more here: Source link