futtta's blog

Frank Goossens' Twitterless twaddle

WordPress 2.8 loves your proxy

with 7 comments

Up until version 2.7.1, running WordPress on an intranet was a real pain in the ass. It connects to the outside world to look for updates, to check comments for spam (using Akismet) or to fetch RSS-feeds for widgets if you configured those on your blog, … But as you typically don’t have direct internet-access on an intranet and as there was no way of letting WordPress know about a proxy, your blog timed out while it was trying to fsockopen those external sites.

chet bakerBut that was yesterday, because the recently released WordPress 2.8 “Baker” (which is chock-full of new features) has support for internet-connections through a proxy, thanks to its great HTTP API. Don’t bother looking for it in the admin-screens, you’ll need to configure the proxy-settings in your wp-config.php.

Here’s what you’ll have to add (values are examples which you’ll have to replace with settings for your environment off course):

define('WP_PROXY_HOST', '192.168.22.1');
define('WP_PROXY_PORT', '9099');

If you need to authenticate to access the proxy you can add your credentials this way:

define('WP_PROXY_USERNAME', 'frank');
define('WP_PROXY_PASSWORD', 's3cr3t');

You can also exclude requests for specific hosts from going through the proxy:

define('WP_PROXY_BYPASS_HOSTS', 'localhost, blog2.corpintranet');

And finally you can block all outgoing requests by default and add domains to a whitelist to only allow those to connect:

define ('WP_HTTP_BLOCK_EXTERNAL', 'true');
define ('WP_ACCESSIBLE_HOSTS', 'api.wordpress.org, akismet.com');

Off course some WordPress-plugins do not use the HTTP API yet (e.g. Lifestream and wp-security-scan rely on Simplepie, which does not use the proxy-aware wp_remote_get-function), so you might have to be careful when installing plugins that need internet-access.

Written by frank

June 18th, 2009 at 10:22 am

7 Responses to “WordPress 2.8 loves your proxy”

  1. Hpatoio

    23 Feb 10 at 18:07

    I don’t this Akismet takes care of these settings.

    Looking at the code you can see a “raw” fsockopen to the domain rest.akismet.com

    But tell me if I’m wrong.

  2. PaulB

    10 May 10 at 14:55

    I’ve rewritten the function in the akismet plugin which deals with http requests to use the HTTP Api, so it now works behind a proxy.

    http://tall-paul.co.uk/wp-akismet-plugin-behind-proxy/

  3. Ged

    31 Aug 10 at 07:21

    Brilliant! I’ve been struggling with this as a newbie hiding behind a big organisation’s proxy server. SOLVED and DONE! Thanks

Leave a Reply