help-header

How to Log Visitors’ Actual IP Addresses in Webservers

As ArvanCloud’s network uses the reverse proxy method, when you check the visitors’ IP addresses, you will see ArvanCloud’s IP address. ArvanCloud keeps the actual IP addresses of the visitors in a specific field of the HTTP headers. In this article, we will discuss the way to log these actual IP addresses in Apache, Nginx, and IIS.

How to Log Visitors’ Actual IP Addresses in Nginx

 

To find the actual IP addresses, add headers with the following format to Nginx:

log_format test1 ‘… $http_x_real_ip $http_ar_real_ip $http_x_real_ip…’

And then use the log format:

access_log test1

As an instance:

log_format test1 '$http_x_real_ip - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent'
'"$http_referer" "$http_user_agent "$http_ar_real_ip" "$http_x_real_ip"';

How to Log Visitors’ Actual IP Addresses in Apache


In Apache, you need to add the following values to your log format:

"%{X-Forwarded-For} %{X-Real-Ip} %{ar-real-ip}i"


A simple log format in Apache looks like the following:


LogFormat " %h %l %u %t "%r" %>s %b %{X-Forwarded-For} %{X-Real-Ip} %{ar-real-ip}i" test1

How to Log Visitors’ Actual IP Addresses in IIS


Follow this instruction to log the actual IP addresses in IIS:
Go to: IIS Config > Logging
Choose Select Fields
Click on Add Field
Add the following headers:
Ar-real-ip
X-Real-Ip
X-Forwarded-For