The intersection of technology and leadership

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,

  • Be careful with HTTP_HOST behind a proxy server

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:

  • wp-includes/canonical.php (line 48)
  • wp-includes/cron.php (line 103)
  • wp-includes/feed.php (line 500)
  • wp-includes/functions.php (line 2327)
  • wp-includes/pluggable.php (line 669, line 685)
  • wp-login.php (line 20, line 274, line 275)

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

2 Comments

  1. Ken Dreyer

    Looks like the number of places to fix HTTP_HOST have gone down. As of SVN r12208:

    * wp-includes/canonical.php (line 48)
    * wp-includes/functions.php (line 3141)
    * wp-includes/pluggable.php (line 751, line 765, line 781)
    * wp-login.php (line 20, line 301, line 302)

  2. Patrick

    Excellent. I managed to get my systems administrator to make some changes that fixed it.

Leave a Reply

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

© 2024 patkua@work

Theme by Anders NorenUp ↑