Howto log only ip address in access.log

Discussion in 'Installation/Configuration' started by JPFOL, Dec 29, 2021.

  1. JPFOL

    JPFOL New Member

    Hello
    I am trying to configure Apache 2.4 (on Debian Buster ISPConfig 3.2.5) to log only the IP address even if dns hostname is resolved.
    I setup following "Apache Directives" in ISP (3.2) "Site"/"Options" tab :
    HostnameLookups on (-> I need this to resolve dns names in order to manage it in htaccess)
    SetEnvIf Server_Addr "xx.xx.xx.xx" MyRem_Addr=Remote_Addr
    LogFormat "%{MyRem_Addr}e %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%{MyRem_Addr}e %l %u %t \"%r\" %>s %O" common
    LogFormat "%{MyRem_Addr}e %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
    But this donot solve my issue. Apache is still loging dns domain name if resolved.
    Thanks fir advize on how to acheive this.
    JP FOL
     
  2. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Try changing LogFormat in /etc/apache2/sites-enabled/000-ispconfig.conf. Assuming that resolves it, you'll need to make that change permanent in a conf-custom template.
     
  3. JPFOL

    JPFOL New Member

    Thanks for the suggestion.
    It donot resolve the issue.
    I also did it in /etc/apache2/apache2.conf without success...
    Which config should I modify : vhost_combined, combined, common ?
     
  4. JPFOL

    JPFOL New Member

    I did it !
    In doing following changes in /etc/apache2/sites-enabled/000-ispconfig.conf

    SetEnvIf Remote_Addr "^(\d{1,3}+\.\d{1,3}+\.\d{1,3}+\.\d{1,3}+).*" X_REAL_IP=$1
    LogFormat "%v %{X_REAL_IP}e (%h) %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined_ispconfig
    CustomLog "| /usr/local/ispconfig/server/scripts/vlogger -s access.log -t \"%Y%m%d-access.log\" /var/log/ispconfig/httpd" combined_ispconfig

    Now what do you mean by "to make that change permanent in a conf-custom template" ?
     
  5. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Copy /usr/local/ispconfig/server/conf/apache_ispconfig.conf.master to /usr/local/ispconfig/server/conf-custom/ and make your changes there (ie. to the conf-custom file), too.
     
  6. JPFOL

    JPFOL New Member

    Thanks , done.
    Why this config change cannot be done from "Apache Directives" in ISP (3.2) "Site"/"Options" tab ?
     
  7. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Well, because it wasn't working. :) It looks like you should be able to change the LogFormat for a site; maybe try changing it specifying the 'combined_ispconfig' nickname.
     
  8. JPFOL

    JPFOL New Member

    Thanks for your contued support.
    In fact it cannot work.
    Because the customlog directive cannot be moved in "Site"/"Options" tab (not accepted by ISPConfig). And thus if executed before the expertimmodelarc.fr.vhost content it is never taken into account at this step.
    Thus only place is to include the change in 000-ispconfig.conf.
    May be this could be a future feature to include in IspConfig ?
    Thanks again for your advize in solving my need.
    JP FOL
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPConfig uses a central log splitting script (vlogger), logs for all sites get piped to that script, this speeds up performance as apache does not has to keep a file handle open for each websites access.log file and it allows systems to be compatible with data protection like GDPR by e.g. anonymizing IP addresses. In such a setup as iSPConfig is using it, you can not use custom log formats per site.
     

Share This Page