How to Pass a Visitor’s IP Address from Varnish to WordPress Updated on November 19, 2021 by InMotion Hosting Contributor 1 Minutes, 0 Seconds to 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 How to Edit a Website File on Your Server How to Import a Table Using phpMyAdmin Force HTTPS with the .htaccess File The Complete Guide to cPanel Backups Schedule Social Media Posts With Buffer How to Google Analytics to WordPress Without a Plugin How to Install Jekyll and Launch a New Site FTP Basics for Dedicated Servers What is your default PHP.ini file? How to Fix the Insecure SSL Error due to SHA-1 Deprecation