Apache Show Real IP Behind Reverse Proxy on CentOS

When Apache web server running behind reverse proxy or load balancer, server log and scripts show IP of reverse proxy server or load balancer as IP of visitor. To fix this, you need to configure revese proxy or load balancer to forward Real IP of visitor on Header X-Forwarded-For, this most load balacner do by default.

Edit Apache configuration file

Add

Example

Doing this will make PHP scripts show real IP of visitor. You need to restart Apache web server before the change take effect. You can verify by creating a PHP script with content

To make Apache show real IP in access log, edit

Find

Replace with

Restart Apache web server

Add a Comment

Your email address will not be published. Required fields are marked *