Displaying real IP in Apache logs

In some cases, when working with the control panel, the following problem may arise: instead of the user's IP addresses, the Nginx address (127.0.0.1) is written to the web server log, which proxies requests to Apache.

To fix the problem, follow these steps:

1. Open the config file /etc/httpd/conf/httpd.conf:

vim /etc/httpd/conf/httpd.conf

2. Find the following lines:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%h %l %u %t \"%r\" %>s %b" common

3. Replace %h in these lines with %{X-Forwarded-For}i. The result should be the following lines:

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common

4. Save changes and exit the editor:

:wq

BitrixVM uses vi editor by default.

You can also install the nano editor:

yum install -y nano

If you have any questions, please create a ticket to technical support.