Skip to main content

Log User IP in High Availability Setup

This appendix describes the configurations required to log the IP address of the connecting user in Nginx logs in a High Availability setup. Normally User Portal will list the IP address of the load balancer through which the user is connecting.

In your User Portal server, edit the /etc/nginx/nginx.conf file. In the http block, comment out the access_log line, and add the following configuration snippet:

http {
...
# Logging Settings
client_body_in_file_only on;
log_format loadbalancer '$http_x_forwarded_for via:$remote_addr\
- $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
access_log /var/log/nginx/access.log loadbalancer;
...
}

Note that the logging of the IP addresses will only work correctly if the load balancer relays X-Forwarded- For header in the HTTP request.