开发者

Apache proxy to Lighttpd: changing $_SERVER['HTTP_HOST'] in php

开发者 https://www.devze.com 2022-12-29 14:00 出处:网络
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

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://b开发者_如何学Pythonlog.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.


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

Namely:

  • WP_SITEURL
  • WP_HOME
  • WP_CONTENT_URL
0

精彩评论

暂无评论...
验证码 换一张
取 消