Peqi is positioned between your website's visitors and your hosting server, and because of this mediation, the IP that appears in your hosting server's network logs will be Peqi's IP, not the actual visitor's.
This can be problematic for applications that need to correctly identify the visitor's IP address, for example, to personalize content, manage user sessions, or apply geographic access restrictions.
To overcome this limitation and obtain the real IP of the visitor, a common practice is to use the HTTP X-Forwarded-For (XFF) header. This header is added by Peqi to the requests it forwards to the hosting server, however, it is necessary for your web server to be configured to trust this header in requests made from our server. In this way, in addition to X-Forwarded-For, we also send X-Peqi-Real-Ip and X-Peqi-Forwarded-For which contains the real IP of the visitor, and you can configure it at the application level.
To integrate this functionality, you will need to configure your application to extract the visitor's IP address from the headers X-Forwarded-For, X-Peqi-Real-Ip or X-Peqi-Forwarded-For. This configuration varies depending on the technology used, but generally involves modifying the server's settings or code to recognize and use the IP listed in this header as the visitor's IP address.
NGINX
The ngx_http_realip_module module must be enabled and installed on your server's NGINX. Once you have activated the mentioned module, follow the steps below:
# Define which header you want to print the real client's IP from
real_ip_header X-Forwarded-For;
# Define Peqi's IPs as trusted so that the above context is valid
set_real_ip_from 45.33.21.140/32;
set_real_ip_from 45.33.21.46/32;
set_real_ip_from 45.33.21.223/32;
set_real_ip_from 45.79.42.243/32;
Apache 2.2
Learn more in the documentation below:
mod_rpaf
Apache 2.4
Apache 2.4 and later versions generally come with the mod_remoteip module already installed; you just need to activate it. However, if mod_remoteip was not included in your Apache installation, you can download it directly here.
After installing the module, you will need to add the following lines to your configuration file. Typically, this configuration file is located at /etc/apache/conf-available/remoteip.conf.
However, if you are using cPanel/WHM, the configuration file path will be /etc/apache2/conf.modules.d/370_mod_remoteip.conf.
RemoteIPHeader X-FORWARDED-FOR
RemoteIPTrustedProxy 45.33.21.140/32
RemoteIPTrustedProxy 45.33.21.46/32
RemoteIPTrustedProxy 45.33.21.223/32
RemoteIPTrustedProxy 45.79.42.243/32
WordPress
Access the wp-config.php file and add the following lines below the opening <?php:
if ( isset( $_SERVER['HTTP_X_PEQI_REAL_IP'] ) ) {
$http_x_headers = explode( ',', $_SERVER['HTTP_X_PEQI_REAL_IP'] );
$_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
}
PHP Applications
if ( isset( $_SERVER['HTTP_X_PEQI_REAL_IP'] ) ) {
$http_x_headers = explode( ',', $_SERVER['HTTP_X_PEQI_REAL_IP'] );
$_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
}
WordPress
Access the wp-config.php file and add the following lines below the opening <?php:
if ( isset( $_SERVER['HTTP_X_PEQI_REAL_IP'] ) ) {
$http_x_headers = explode( ',', $_SERVER['HTTP_X_PEQI_REAL_IP'] );
$_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
}
Magento 1.x
Add the following code to your /app/etc/local.xml file within the <global></global> scope:
<remote_addr_headers>
<header1>HTTP_X_PEQI_REAL_IP</header1>
</remote_addr_headers>
Magento 2.x
We recommend using server-level methods: Apache, NGINX, LiteSpeed.
If this is not possible, the following article (use at your own risk) may be helpful: https://dev98.de/2017/01/02/how-to-add-alternative-http-headers-to-magento-2/
Drupal
Access the settings.php file and add the following lines:
if ( isset( $_SERVER['HTTP_X_PEQI_REAL_IP'] ) ) {
$http_x_headers = explode( ',', $_SERVER['HTTP_X_PEQI_REAL_IP'] );
$_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
}
CodeIgniter
Access the index.php file and add the following lines:
if ( isset( $_SERVER['HTTP_X_PEQI_REAL_IP'] ) ) {
$http_x_headers = explode( ',', $_SERVER['HTTP_X_PEQI_REAL_IP'] );
$_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
}