How to Pass a Visitor’s IP Address from Varnish to WordPress InMotion Hosting ContributorUpdated on November 19, 2021 1 Minute Read Varnish caching can speed up the loading time of your website. Varnish listens on port 80 and passes data to the default HTTP application. This means that the HTTP log files will show your server’s IP instead of the actual remote IP of the visitor. This article will provide options for passing the remote IP to WordPress. Get a Visitor’s IP Address for a WordPress Site Login to cPanelOpen File ManagerOpen your wp-config.php file in the Code EditorAdd the following code as a new line after the first line: if ( isset( $_SERVER[ "HTTP_X_FORWARDED_FOR" ])){ $_SERVER[ 'REMOTE_ADDR' ] = $_SERVER[ "HTTP_X_FORWARDED_FOR" ];} Get a Visitor’s IP Address for All Sites by PHP Version Login to your server via SSH as rootCreate a PHP file at “/usr/local/php/remoteIP.php” with the following contents: <?php if ( isset( $_SERVER[ "HTTP_X_FORWARDED_FOR" ])){ $_SERVER[ 'REMOTE_ADDR' ] = $_SERVER[ "HTTP_X_FORWARDED_FOR" ]; }?>Login to WHM as rootOpen the MultiPHP INI EditorAdd the full path for your new file at the end of the line that starts with “auto_prepend_file”Finally, click Save Congratulations! You are now able to pass the correct IP address to WordPress from Varnish. Share this Article InMotion Hosting Contributor Content Writer InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals! More Articles by InMotion Hosting Related Articles Intro to Migrating your WordPress Site Data Migrating your WordPress Database Migrating WordPress Files Configuring WordPress After a Migration Testing your WordPress website after Migration How to Move WordPress from a Subfolder to the Root Directory What to expect during a mass server migration Move Your WordPress Site to a New Server Moving Websites Built with Older Technology into WordPress How to Export Your WordPress Sites