How to permanently add custom LogFormat and CustomLog to a domain

Discussion in 'Installation/Configuration' started by spanish, Dec 6, 2023.

  1. spanish

    spanish Member HowtoForge Supporter

    What is the appropriate way to do this?
    Is there any guide or manual?
    Thanks!
    Manuel
     
  2. spanish

    spanish Member HowtoForge Supporter

    Through the web interface (domain Apache directives) I have already seen that it cannot be done (apache_directive_blocked_error) for security reasons.
    If I add LogFormat and CustomLog to vhost.conf.master it works, but for all domains.
    Is adding them to vhost.conf.master safe and permanent? (if there was no way to do it on a single domain, this option would work for me).
    Thanks!
     
  3. michelangelo

    michelangelo Active Member

    Adding it to the vhost.conf.master is the way to do it.
    Just make sure that you save your changes to the vhost.conf.master in conf-custom folder instead in the conf/ folder, otherwise your changes get overwritten by the next ISPConfig update.
     
  4. spanish

    spanish Member HowtoForge Supporter

    Would the following be the proper way to do this?

    1. Now:
    # cp -ar /usr/local/ispconfig/server/conf/vhost.conf.master /usr/local/ispconfig/server/conf-custom/vhost.conf.master
    # nano /usr/local/ispconfig/server/conf-custom/vhost.conf.master
    Add my customizations.
    # systemctl restart apache2

    2. After the next ISPConfig 3 update:
    # rm /usr/local/ispconfig/server/conf-custom/vhost.conf.master
    # cp -ar /usr/local/ispconfig/server/conf/vhost.conf.master /usr/local/ispconfig/server/conf-custom/vhost.conf.master
    # nano /usr/local/ispconfig/server/conf-custom/vhost.conf.master
    Add again my customizations.
    # systemctl restart apache2

    Thanks!
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    There is no need to re-add customizations after an update as all changes in /usr/local/ispconfig/server/conf-custom/ are update safe. So all you do is:

    cp -pf /usr/local/ispconfig/server/conf/vhost.conf.master /usr/local/ispconfig/server/conf-custom/vhost.conf.master
    nano /usr/local/ispconfig/server/conf-custom/vhost.conf.master

    That's all, no apache restart as the template gets applied on config change by ISPConfig, it has no effect on existing sites until you change them or until you use Tools > resync to force an update on existing sites.
     
  6. spanish

    spanish Member HowtoForge Supporter

    From what I have read in another thread, the sites should be resynchronized before restarting Apache (ISPConfig 3 -> Tools -> Resync):

    # rm /usr/local/ispconfig/server/conf-custom/vhost.conf.master
    # cp -ar /usr/local/ispconfig/server/conf/vhost.conf.master /usr/local/ispconfig/server/conf-custom/vhost.conf.master
    # nano /usr/local/ispconfig/server/conf-custom/vhost.conf.master
    Add again my customizations.
    Resync the sites via ISPConfig 3 (Tools -> Resync).
    # systemctl restart apache2

    Would this be the correct way?
    Thanks!
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    No. The correct way is what I described in post #5.
     
  8. spanish

    spanish Member HowtoForge Supporter

    Will the default host.conf.master file always be the same? Will I never have changes that would interfere with the copy I make today in conf-custom?
    Noted. Thank you!
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Of course, there might be changes in future that need to be incorporated into the config, but not every update changes the file. The updater will ask you what to do with your custom config during update and you have to decide then if you want your custom config or the new one from ISPConfig.
     
    spanish likes this.
  10. spanish

    spanish Member HowtoForge Supporter

    Thank you very much!
    \ ;-)
    I have a few more questions (sorry for my ignorance):

    1. About the option above (conf-custom/vhost.conf.master):
    The following is working correctly:
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{SSL_CLIENT_S_DN}x\" \"%{SSL_PROTOCOL}x\" \"%{SSL_CIPHER}x\"" ssl_custom
    CustomLog /var/log/ispconfig/httpd/{tmpl_var name='domain'}/ssl_access.log ssl_custom
    The ssl_access.log files are being created automatically: will they also rotate automatically so they don't grow too large?

    2. About the option of getting this only on one domain:

    2.1. Would it be advisable to use a script that automatically adds the LogFormat and CustomLog lines to the domain.tld.vhost file after each update of the file by ISPConfig 3?

    2.2. Would it be advisable to use a domain.tld.vhost file independent of ISPConfig 3 on a server managed with ISPConfig 3?

    Thanks!
     
    Last edited: Dec 6, 2023
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    No, you must write your own scripts for that. ISPConfig rotates only its own logs.

    Sure, you can do that if you prefer it this way.

    You can add custom apache config files as long as they are not for websites managed in ISPConfig.
     
    spanish likes this.
  12. spanish

    spanish Member HowtoForge Supporter

    1. I will look into record rotations.
    2. I like option 2.1 better than 2.2, if only for the convenience of having ISPConfig handle Let's Encrypt renewals.
    Thank you very much!
     
  13. slagroom

    slagroom Member

    Does this resync also work for changes in postfix and/or dovecot templates, or is an update --force reconfigure required?
     
  14. till

    till Super Moderator Staff Member ISPConfig Developer

    Tools > Resync is for runtime config only. For global configs like postfix config files, you must do an ISPConfig update.
     
    ahrasis likes this.

Share This Page