views:

333

answers:

1

I have a WordPress blog running on lighttpd-1.4.19, listening at www00:81. On the same host, apache-2.2.11 listens on port 80, which creates a proxy connection from http://blog.mydomain.org:80 to http://blog.mydomain.org:81 (both being the same physical machine).

The Apache virtualhost looks as follows:

<VirtualHost *:80>
    ServerName blog.mydomain.org
    ProxyRequests Off

    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>

    ProxyPass / http://blog.mydomain.org:81/
    ProxyPassReverse / http://blog.mydomain.org:81/
</VirtualHost>

Using debug.log-request-handling = "enable", I get the following log entry when I browse http://blog.mydomain.org:80 (notice the Host headers):

2010-05-10 08:47:14: (request.c.294) fd: 6 request-len: 853 
GET / HTTP/1.1
Host: blog.mydomain.org:81
[...]

2010-05-10 08:47:15: (request.c.294) fd: 8 request-len: 754 
GET /wp-content/uploads/2010/01/image.gif?w=280 HTTP/1.1
Host: www00:81

My problem: as far as I know, the PHP environment variable $_SERVER['HTTP_HOST'] is set to that Host header variable. Unfortunately, WordPress uses that variable in their system to create URLs to pictures on the blog. These URLs won't be accessible behind a firewall of course. How can I force the host header to be blog.mydomain.org instead of blog.mydomain.org:81, respectively www00:81? I already added set server.name = "blog.mydomain.org" to my lighttpd.conf, but this didn't work.

Any suggestions are appreciated, thank you.

+2  A: 

Have you tried editing your wp-config.php? It should be possible to override the automatic host detection.

Namely:

Pekka
A `print_r` on `$_SERVER` shows `[HTTP_HOST] => blog.mydomain.org:81`, so it does contain the port number. Unfortunately I can can't move `blog.mydomain.org` to port 80 (this is a really complicated story; because of multiple reasons I want to run the blog on a separate web-service). And yes, I should've posted it on serverfault.com.
watain
@watain oh, I stand corrected re the `HTTP_HOST`, sorry. I misread you. Updated my answer.
Pekka
No, I haven't edited my `wp-config.php` yet. What would I have to change? I changed both `WordPress address (URL)` and `Blog address (URL)` in the wordpress admin panel to the correct value (`http://blog.mydomain.org`), but that didn't change much either. EDIT: Ok. I'll check out these variables.
watain
@watain it *should* be possible to change every aspect of WordPress to a certain host different from what the browser thinks is the current one. I can't say for 100% sure because I've never done it but it should work.
Pekka
It seems like all URL are ok, but not the ones used for pictures which are included in a blog post. They always start with `http://www00:81/...`.
watain
@watain yes, those are probably hard coded in your database. you would have to replace them there using `UPDATE tablename SET fieldname = REPLACE(fieldname, 'http://www00:81', 'http://blog.mydomain.org');` be sure to make a backup beforehand. I think the table name is "posts", check out which field contains the HTML.
Pekka
Alright, looks like your SQL query solved the problem :). I needed to modify `wp_content` and `guid` of the table `wp_posts`. Thank you very much!
watain