• I know there is an entry for this on the trac, but I thought posting here might generate some feedback, as well.
    And all the other posts I found relating to proxy servers were about blocking spammers or modding specific plugins.

    Has anyone had any luck installing wordpress (2.3) behind a proxy? 2.2 had a patch that worked, but the patch doesn’t work in 2.3 (and I don’t have enough PHP behind me to revise it).

    Basically I want Internet connectivity (for bringing in external RSS feeds) with the proxy settings defined in the WordPress install (wp-config or elsewhere).

Viewing 2 replies - 1 through 2 (of 2 total)
  • I successfully installed WordPress 2.6.2 behind a firewall and was able to modify some core WordPress code to enable proxy functionality. This fixed the dashboard page panels so they load immediately now. However, the plugins.php page still takes about 30 seconds to load. I don’t know if that’s a function of how many plugins we have installed or whether there is a place I missed in the code.

    Note the last file patched in the code below is your wp-config.php file in WordPress’ root folder. Edit this file after you install the patch to add your proxy settings toward the bottom.

    Here’s my patch. I hope it helps.

    --- wp-includes/update.php.orig	2008-10-18 11:09:35.000000000 -0700
    +++ wp-includes/update.php	2008-10-18 11:39:12.000000000 -0700
    @@ -46,7 +46,12 @@
     	$http_request .= "\r\n";
    
     	$response = '';
    -	if ( false !== ( $fs = @fsockopen( 'api.www.ads-software.com', 80, $errno, $errstr, 3 ) ) && is_resource($fs) ) {
    +	if(PROXY_HOST) {
    +		$fs = @fsockopen( PROXY_HOST, PROXY_PORT, $errno, $errstr, 3);
    +	} else {
    +		$fs = @fsockopen( 'api.www.ads-software.com', 80, $errno, $errstr, 3 );
    +	}
    +	if ( false !== $fs && is_resource($fs) ) {
     		fwrite( $fs, $http_request );
     		while ( !feof( $fs ) )
     			$response .= fgets( $fs, 1160 ); // One TCP-IP packet
    @@ -139,7 +144,12 @@
     	$http_request .= $request;
    
     	$response = '';
    -	if( false != ( $fs = @fsockopen( 'api.www.ads-software.com', 80, $errno, $errstr, 3) ) && is_resource($fs) ) {
    +	if(PROXY_HOST) {
    +		$fs = @fsockopen( PROXY_HOST, PROXY_PORT, $errno, $errstr, 3);
    +	} else {
    +		$fs = @fsockopen( 'api.www.ads-software.com', 80, $errno, $errstr, 3 );
    +	}
    +	if ( false !== $fs && is_resource($fs) ) {
     		fwrite($fs, $http_request);
    
     		while ( !feof($fs) )
    --- wp-includes/functions.php.orig	2008-10-18 11:33:05.000000000 -0700
    +++ wp-includes/functions.php	2008-10-18 12:43:27.000000000 -0700
    @@ -834,9 +834,14 @@
     	else
     		$request_type = 'HEAD';
    
    -	$head = "$request_type $file HTTP/1.1\r\nHOST: $host\r\nUser-Agent: WordPress/" . $wp_version . "\r\n\r\n";
    +	$head = "$request_type $file HTTP/1.1\r\nHOST: $host\r\nPORT: {$parts['port']}\r\nUser-Agent: WordPress/" . $wp_version . "\r\n\r\n";
    
    -	$fp = @fsockopen( $host, $parts['port'], $err_num, $err_msg, 3 );
    +	if(PROXY_HOST) {
    +		$fp = @fsockopen( PROXY_HOST, PROXY_PORT, $err_num, $err_msg, 3);
    +	} else {
    +		$fp = @fsockopen( $host, $parts['port'], $err_num, $err_msg, 3 );
    +	}
    +	//$fp = @fsockopen( $host, $parts['port'], $err_num, $err_msg, 3 );
     	if ( !$fp )
     		return false;
    
    @@ -1097,6 +1102,10 @@
     		curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 );
     		curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 );
     		curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout );
    +		if(PROXY_HOST) {
    +			$proxy_host = PROXY_HOST . ( (PROXY_PORT) ? ':'.PROXY_PORT:'' );
    +			curl_setopt( $handle, CURLOPT_PROXY, $proxy_host );
    +		}
     		$buffer = curl_exec( $handle );
     		curl_close( $handle );
     		return $buffer;
    --- wp-config.php.orig	2008-10-18 12:47:28.000000000 -0700
    +++ wp-config.php	2008-10-18 12:51:57.000000000 -0700
    @@ -22,5 +22,8 @@
     /* That's all, stop editing! Happy blogging. */
    
     define('ABSPATH', dirname(__FILE__).'/');
    +/* define proxy settings here */
    +define('PROXY_HOST', 'myproxy.server.com'); // replace with your proxy server.
    +define('PROXY_PORT', '8080'); // replace with your proxy port number
     require_once(ABSPATH.'wp-settings.php');
     ?>

    Note: You may want to update wp-includes/class-snoopy.php to enable proxy support also. To do this, you would need to change the following lines to include your proxy settings.

    var $proxy_host	= ""; // proxy host to use
    var $proxy_port = ""; // proxy port to use

    These lines are found in my 2.6.2 install on lines 54 and 55.

    did you find the function, responsible for 20/30 sec of waiting at each page loaded?

    each page of my blog and each page of admin has a 20sec delay.
    no, the server is not slow.

    i tried many patches. i dont even believe it is in the update.php.
    i tried a complete new install without plugins/widgets … slow.

    just confused with my WP 2.6.3. in the intranet behind a firewall with no acess to the internet (and a loading time for each page > 20 secs)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Install Behind Proxy’ is closed to new replies.