WordPress behind proxy does not detect updates

WordPress is used for a small website in my workplace. The server must use a proxy to connect to the web, and this is necessary for many plugins and for updates.

As explained in the documentation, the proxy is declared in wp-config.php

define('WP_PROXY_HOST', 'myCache.fr');
define('WP_PROXY_PORT', '3128');

Since 3.8.1, the Dashboard does not show any update available (even if now 3.9.1 is out). No error message is displayed either.
I had to run wireshark to see what was happening :

  1. WordPress sends a POST request to https://api.wordpress.org/plugins/info/1.0
  2. Squid proxy answers Error 501 : “Unsupported Request Method and Protocol”

It seems that the proxy does not support HTTPS POST requests. So I had to find where the https URL was defined in WordPress. It turns out it is in wp-includes/update.php. But the URLs are defined as http, and the following code is used (in three different places) to convert it to https if ssl is available :

if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
                $url = set_url_scheme( $url, 'https' );

I thus commented those :

/**if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
 $url = set_url_scheme( $url, 'https' );*/

And I could update the server. Of course, I will have to do that again after each update…

This entry was posted in TechTips. Bookmark the permalink.

3 Responses to WordPress behind proxy does not detect updates

  1. Landry MINOZA says:

    As a better workaround, you can install php curl extension, libcurl will be used as the default transport handler instead “stream” and it behave correctly with https post and proxies.

  2. DG says:

    Missing the php curl extension was my problem – once that was installed, the site was able to reach out to get plugins etc via a proxy using a https url etc etc.

Leave a Reply

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