Using wordpress through a proxy server

Where the web server hosting the WordPress site is located behind a proxy server, the WordPress admin and user may experience technical problems. Symptoms include:

– very slow loading of the dashboard
– askimet not working

These can be resolved by first setting proxy credentials in wp-includes/class-snoopy.php and then editing the akismet_http_post function in wp-content/plugins/askimet/askimet.php along the lines suggested at:

Where your proxy server requires authentication you will need to provide this in askimet.php using the line:

$http_request .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode _

remembering to substitute in your actual username and password.

The new akismet_http_post function should therefore be:

function akismet_http_post($request, $host, $path, $port = 80) { _
 global $wp_version;

// $http_request  = "POST $path HTTP/1.0rn";
// $http_request .= "Host: $hostrn";
 $http_request  = "POST http://$host$path HTTP/1.0rn";
 $http_request .= "Host: http://$hostrn";

$http_request .= "Content-Type: application/x-www-form-urlencoded; _
charset=" . get_option('blog_charset') . "rn";
 $http_request .= "Content-Length: " . strlen($request) . "rn";
$http_request .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode_

 $http_request .= "User-Agent: WordPress/$wp_version | Akismet/2.0rn";
 $http_request .= "rn";
 $http_request .= $request;

 $response = '';
// if( false != ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
 if( false !== ( $fs = @fsockopen('your_proxy_address', your_proxy_port, _
$errno, $errstr, 10) ) ) {

  fwrite($fs, $http_request);

  while ( !feof($fs) )
   $response .= fgets($fs, 1160); // One TCP-IP packet
  $response = explode("rnrn", $response, 2);
 return $response;

← Previous Post

Next Post →


  1. Hi Dr Alan,

    Thank you so much for this, I was able to hack the akismet code and get it to work behind our firewall (using our proxy) thank you so much!


  2. Curtis

    Thanks for posting this code. I am running WordPress 3.0 and Akismet v2.2.9. I was curious if you may have a code update that would work with this? The server that hosts our site is not directly connected to the Internet.

  3. Thanks a lot! This helped a lot!

  4. your code is effective but if we use a configuration instead of this isn’t it good.?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.