Peakhour acts as a reverse proxy that sits between your website and end clients. After you have successfully pointed your domain to Peakhour, all visits to your website will only come from Peakhour IP addresses. To preserve the original IP addresses of visitors in your access logs, you need to configure your web server to check the X-Peakhour-IP header. This header contains the IP of the request that is coming into Peakhour.
Preserving visitor IP addresses can be important for a number of reasons, including:
Preserving visitor IP addresses can provide valuable information for fraud detection, payment processing, site diagnostics, user tracking, and compliance with regulations. By configuring your web server to check the X-Peakhour-IP header, you can preserve the original IP addresses of visitors when using Peakhour as a reverse proxy.
To set the client's IP address using the X-Peakhour-IP header in Apache, you can use the following configuration in your Apache server configuration file:
LoadModule remoteip_module modules/mod_remoteip.so
<VirtualHost *:80>
ServerName example.com
RemoteIPHeader X-Peakhour-IP
RemoteIPInternalProxy 10.0.0.1
# ...
</VirtualHost>
In Nginx, you can set the client's IP address using the X-Peakhour-IP header with the following configuration in your nginx.conf file:
# set the REMOTE_ADDR variable
set_real_ip_from 0.0.0.0/0;
real_ip_header X-Peakhour-IP;
After adding the configuration, you need to restart your Apache or Nginx server for the changes to take effect.
After these changes, in PHP, you can retrieve the client's IP address using the $_SERVER['REMOTE_ADDR'] variable.
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %{X-Peakhour-IP}i" combined
CustomLog logs/access_log combined
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_peakhour_ip"';
access_log /var/log/nginx/access.log main;
c-ip:%{X-Peakhour-IP}i
With these configurations, you can preserve the original IP addresses of visitors in your access logs when using Peakhour as a reverse proxy. Please note that the exact steps to configure X-Peakhour-IP header may vary depending on your web server version and setup.