patkua@work

The intersection of technology and leadership

Category: Website News

TheKua@Work on Wordle

An interesting visualisation of this blog thanks to Wordle.

Wordle: TheKua @ Work

Created by Wordle under the Creative Commons licence.

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:11008/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.

New Site

I’ve decided that it’s about high time that I split my work and my life blog. Although the feeds from work related categories had been fed into various things, you really can’t stop the power of search engines from stumbling across content. Rather than confuse people with the two different sets of content, I’m splitting them out. Here’s my first post.

© 2017 patkua@work

Theme by Anders NorenUp ↑