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 Create a PHP Redirect (301, 302, and Dynamic Redirect Examples) Connect to SFTP for Shared Hosting Accounts Using FileZilla FTP Basics for Dedicated Servers How to Install Jekyll and Launch a New Site How to Host AI-Prompt Generated Websites on Shared Hosting What is your default PHP.ini file? Getting Started Guide: FTP Configuring your site in WS_FTP Schedule Social Media Posts With Buffer FTP Error – 421 Too Many Connections