• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Issue Add item to log_format

karyo

New Pleskian
Server operating system version
18.04.6 LTS
Plesk version and microupdate number
18.0.44
Hello
I wanted to add the following to the log_format in nginx and Apache.
But I do not know how it is possible
Can you help me?
br-real-ip X-Real-Ip X-Forwarded-For

Nginx:
log_format test1 ‘… $http_x_real_ip $http_br_real_ip $http_x_real_ip…’

Apache:
LogFormat " %h %l %u %t "%r" %>s %b %{X-Forwarded-For} %{X-Real-Ip} %{br-real-ip}i" test1
 
You can change LogFormat for Apache with the following steps
  1. Create /usr/local/psa/admin/conf/templates/custom/ custom template folder:
    Code:
    # mkdir -p /usr/local/psa/admin/conf/templates/custom/
  2. Copy /usr/local/psa/admin/conf/templates/default/server.php into custom template folder:
    Code:
    # cp -a /usr/local/psa/admin/conf/templates/default/server.php /usr/local/psa/admin/conf/templates/custom/server.php
  3. Open /usr/local/psa/admin/conf/templates/custom/server.php file using any text editor.
  4. Change log format in custom template in the following section according to Apache documentation:
    Code:
    <IfModule mod_logio.c>
    LogFormat "<?php echo $VAR->server->webserver->apache->pipelogEnabled ? '%v@@%p@@' : ''?>%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" plesklog
    </IfModule>
    <IfModule !mod_logio.c>
    LogFormat "<?php echo $VAR->server->webserver->apache->pipelogEnabled ? '%v@@%p@@' : ''?>%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" plesklog
    </IfModule>
  5. Check that the modified template is a valid PHP file:
    Code:
    # php -l /usr/local/psa/admin/conf/templates/custom/server.php
    No syntax errors detected in /usr/local/psa/admin/conf/templates/custom/server.php
  6. Regenerate server configuration based on the new template:
    Code:
    # plesk sbin httpdmng --reconfigure-server
Note: customizing Apache access log format may break webstatistics calculation as webstat tools (Webalizer and Awstats) use CLF (Common Log Format) when each line in a file stored in the Common Log Format has the strictly defined syntax.
More information can be found in Plesk and Apache documentation:
Changing Virtual Hosts Settings Using Configuration Templates
Apache Log Files
 
For nginx you may try to uncomment log_format directive in "/etc/nginx/nginx.conf" and add there your options
Code:
log_format  test1 ‘… $http_x_real_ip $http_br_real_ip $http_x_real_ip…’;
Please be aware about mentioned above consequences of changing log format.
 
You can change LogFormat for Apache with the following steps
  1. Create /usr/local/psa/admin/conf/templates/custom/ custom template folder:
    Code:
    # mkdir -p /usr/local/psa/admin/conf/templates/custom/
  2. Copy /usr/local/psa/admin/conf/templates/default/server.php into custom template folder:
    Code:
    # cp -a /usr/local/psa/admin/conf/templates/default/server.php /usr/local/psa/admin/conf/templates/custom/server.php
  3. Open /usr/local/psa/admin/conf/templates/custom/server.php file using any text editor.
  4. Change log format in custom template in the following section according to Apache documentation:
    Code:
    <IfModule mod_logio.c>
    LogFormat "<?php echo $VAR->server->webserver->apache->pipelogEnabled ? '%v@@%p@@' : ''?>%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" plesklog
    </IfModule>
    <IfModule !mod_logio.c>
    LogFormat "<?php echo $VAR->server->webserver->apache->pipelogEnabled ? '%v@@%p@@' : ''?>%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" plesklog
    </IfModule>
  5. Check that the modified template is a valid PHP file:
    Code:
    # php -l /usr/local/psa/admin/conf/templates/custom/server.php
    No syntax errors detected in /usr/local/psa/admin/conf/templates/custom/server.php
  6. Regenerate server configuration based on the new template:
    Code:
    # plesk sbin httpdmng --reconfigure-server
Note: customizing Apache access log format may break webstatistics calculation as webstat tools (Webalizer and Awstats) use CLF (Common Log Format) when each line in a file stored in the Common Log Format has the strictly defined syntax.
More information can be found in Plesk and Apache documentation:
Changing Virtual Hosts Settings Using Configuration Templates
Apache Log Files

For nginx you may try to uncomment log_format directive in "/etc/nginx/nginx.conf" and add there your options
Code:
log_format  test1 ‘… $http_x_real_ip $http_br_real_ip $http_x_real_ip…’;
Please be aware about mentioned above consequences of changing log format.


Thank you very much for your help.
Is there a way to apply this log to only one site and not the entire website?
 
Is there a way to apply this log to only one site and not the entire website?
You can try to specify it in Additional Apache/nginx directives in Apache & nginx Settings for your domain, but note that not all directives are allowed for applying there.
 
Back
Top