patkua@work

WordPress 2.6.2 interoperability with Apache 2 Mod Proxy

I’ve had some issues upgrading to WordPress 2.6.2. Until recently I had been running 2.5 because I continuously received the error message, “Firefox has detected that the server is redirecting the request for this address in a way that will never complete.” I tried all the suggestions on the forums, yet nothing seemed to help with that. Both WordPress 2.6 and 2.6.1 exhibited this behaviour. Fortunately 2.6.2 never gave me this problem, instead giving me other problems. Looking at the source code, I was suspicious when the install.php had references to localhost:11008 when I viewed the source.

<link rel="stylesheet" 
href="http://localhost/trial/wp-admin/css/install.css?ver=20080708" 
type="text/css" media="all"/>

When I ran the installer, it also put that value in for the siteurl option. I looked at the source code and became suspicious of the code putting it in there, specifically in the function wp_guess_url():

$_SERVER["HTTP_HOST"]

I ran a test php page, and found that it was returning the localhost reference. I did some more searching, and found the following comments,

I believe my server is running Apache Mod Proxy, where my virtual host is forwarded on from the main apache server. I asked my system administrator to play around with the ProxyPreserveHost configuration described here but unfortunately it didn’t seem to have much effect on the $_SERVER['HTT_HOST'] value.

I did a little bit more reading, and tried using a total wide fix described here, effectively executing some code to reset the HTTP_HOST to the HTTP_X_FORWARDED_HOST value yet that also didn’t seem to work.

In my .htaccess file, I had added a line:

php_value auto_prepend_file wordpress_fixes.php

and in a wordpress_fixes.php file, I had:

<?php
if(isset($_SERVER["HTTP_X_FORWARDED_HOST"]))
        $_SERVER["HTTP_HOST"] = $_SERVER["HTTP_X_FORWARDED_HOST"];
?>

yet it didn’t seem to do anything. Instead, I reverted back to changing all the $_SERVER['HTTP_HOST'] values into $_SERVER['HTTP_X_FORWARDED_HOST']

For everyone’s reference, here are all the files and the line numbers I had to change:

It also looks like it fixed the cron issue of publishing future posts, and trackbacks, so apologies if anyone got flooded with those recently.

Exit mobile version