Setting Up IP Address Logging in Linux OS

The settings for logging IP address of the workstation, from which the object was accessed to access protocol depend on the presence of a balancer between the web servers cluster and the web application.

The configuration that includes the balancer located between the web servers cluster and the web application:

Determine the settings for the HAProxy balancer:

  1. Add the string in the backend bk_bi section of the /etc/haproxy/haproxy.conf file:

backend bk_bi #Name of group of BI servers.

        ...

        http-request add-header userhostaddress %[src]

        ...

Determine the settings for the nginx balancer:

  1. Comment the strings in the location directive of the balancer:

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Add the string instead of them:

proxy_set_header userhostaddress $proxy_add_x_forwarded_for;

  1. On web servers in the configuration file:

Comment the strings:

SetEnvIf REMOTE_ADDR "^(.+)$" USER_CLIENT_ADDR=$1

RequestHeader merge userhostaddress "%{USER_CLIENT_ADDR}e"

The configuration that does not include the balancer located between the web servers cluster and the web application:

On web servers in the configuration file:

Check if the following strings are present:

SetEnvIf REMOTE_ADDR "^(.+)$" USER_CLIENT_ADDR=$1

RequestHeader merge userhostaddress "%{USER_CLIENT_ADDR}e"

See also:

Advanced Web Application Settings | Creating BI Servers Cluster