Fix Wordpress Comments IPs using Varnish
If you are using Varnish as front cache with your Wordpress, You may have problems with Spam. This issue is because the IP of all comments is 127.0.0.1 and then Akismet is not able to check the source IP. Lets fix it! In the vcl_recv part of your varnish config add this
set req.http.X-Forwarded-For = client.ip;
Then edit your WordPress wp-includes/comment.php and replace REMOTE_ADDR with HTTP_X_FORWARDED_FOR Restart varnish
Then edit your wp-content/plugins/akismet/akismet.php and replace REMOTE_ADDR with HTTP_X_FORWARDED_FOR
/etc/init.d/varnish restart
And that’s all :) with this little trick your Akismet can clean your spam!