Firewall problem with Akismet plugin (version pre-3.0) for Wordpress

Categories Web HostingWebsite Apps

Because our Cloud Hosting servers are protected by a firewall, WordPress users who want to use Akismet's spam protection plugin may have to make some changes to the WordPress code to allow Akismet to make outside connections.

Firstly, adjust Wordpress to use our proxy server to make outbound connections. Add the below code to the WordPress /wp-config.php file.

define('WP_PROXY_HOST', '');
define('WP_PROXY_PORT', '3128');

The code above allows WordPress to make outbound connections via a proxy server, however the Akismet plugin doesn’t currently work behind a proxy. No matter what you put in for your proxy settings you’ll be told unable to connect. The reason for this is that Akismet uses a raw socket connection to do its http requests, rather than with the new API provided within WordPress. To get around this you need to edit the /wp-content/plugins/akismet/akismet.php file. Once the file is open search for the function akismet_http_post and replace the entire function (you can just rename the old function) with the below one.

function akismet_http_post($request, $host, $path, $port = 80, $ip=null){
        global $wp_version;
    $akismet_version = constant('AKISMET_VERSION');
        $args = array(
             'user-agent'=>"User-Agent: WordPress/$wp_version | Akismet/$akismet_version",
         $url = "http://".$host.$path;

         if( !class_exists( 'WP_Http' ) )
         include_once( ABSPATH . WPINC. '/class-http.php' );
     $http_request = new WP_Http;
         $http_response = $http_request->request($url,$args);
               if( is_wp_error( $http_response ) )
         $response[0] = $http_response['headers'];
         $response[1] = $http_response['body'];    return $response;}

The above information has been taken from

Rate this article
Get more leads