
You can add as many proxy definitions as you need to the nf file in order to configure the usage of XFF headers for traffic coming from those proxies when using multiple services or load balancers.

To add a proxy with the internal IP address 192.168.1.10 in order to represent the CloudFlare server for example, you would need to add the following lines: The contents of the nf file represent your proxy servers or services such as CloudFlare. Open the file for editing in your preferred text editor, such as nano shown below: If it does not yet exist, create it in /etc/apache/conf-available/nf. Once the remoteip module has been loaded, you will need to edit the Apache remote IP configuration file. LoadModule remoteip_module modules/mod_remoteip.so Remove the first # if present from the line so it instead looks as follows. #LoadModule remoteip_module modules/mod_remoteip.so In the file, search for the following line: Open the file in a text editor such as nano after navigating to its location: Depending on your system, this file called nf will be located in /etc/httpd/conf or /usr/local/apache2/conf. Next, open the Apache server configuration file. If you are using sudo, your command will instead look like:

As root or using the command sudo with a user possessing superuser privileges, execute the following command: Instead, all you have to do is activate remoteip. Luckily, this module is built by default in your Apache server installation and should not require an Apache recompilation. This means that your Apache web server will instead override the client IP address that it receives as the original useragent, such as the CloudFlare server IP address, in order to instead prefer the new useragent address from the XFF header as given by the RemoteIPHeader directive. The remoteip module is used to treat the useragent, the identified client, initiating the request as the actual client address, and not the possible load balancer, proxy, or other front end server address that Apache may be receiving. In order to omit the IP address of the proxy service (such as CloudFlare) and instead use the real customer IP, we will need to activate a special Apache module known as remoteip when using Apache version 2.4 or higher. If you use originating IP for GeoLocalisation purposes, you will see your data as though all connections originated just from one IP, ruining the location data.ĭue to the importance of being able to correctly identify your actual originating client, CloudFlare and other such services follow industry standards to include the original visitor’s IP address in the X-Forwarded-For header. The content of your web server access logs would only contain the CloudFlare IP address listed as the $remote_addr. This means that in cases where your web application relies on the originating visitor IP, it will instead pick up only the CloudFlare IP address instead of the actual original client’s IP address, thus possibly breaking the application logic and corrupting data such as web tracking. This beneficial service however comes with the drawback that your web server will process all traffic it receives as originating from the CloudFlare server. By acting as a reverse proxy for all incoming traffic to your web server, CloudFlare sends all traffic first to its own servers for DDoS detection before they reach your server. CloudFlare is a popular protection service against Distributed Denial of Service (DDoS) attacks and essentially acts as a proxy for your web servers. We will cover setting up your back end web server to use the special X-Forwarded-For HTTP header by using the example of CloudFlare.

X-Forwarded-For, or XFF for short, is a special HTTP header field that is commonly used to identify the originating client IP address whether or not they are connecting to the server through an HTTP proxy or a load balancer.

#Xampp ssl reverse proxy how to
How to get X-Forwarded-For IP addresses in Apache Web Server
