Apache 代理到 Lighttpd:在 php 中更改 $_SERVER['HTTP_HOST']
我有一个在lighttpd-1.4.19上运行的WordPress博客,监听www00:81。在同一主机上,apache-2.2.11 侦听端口 80,这会创建从 http://blog.mydomain.org:80
到 http://blog.mydomain 的代理连接.org:81(两者都是同一台物理机)。
Apache 虚拟主机如下所示:
<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>
使用 debug.log-request-handling = "enable"
,当我浏览 http://blog.mydomain.org:80 时,我会收到以下日志条目
(注意 Host
标头):
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
我的问题:据我所知,PHP 环境变量 $_SERVER['HTTP_HOST']
设置为 < code>Host 标头变量。不幸的是,WordPress 在其系统中使用该变量来创建博客上图片的 URL。当然,在防火墙后面无法访问这些 URL。如何强制主机标头分别为 blog.mydomain.org
而不是 blog.mydomain.org:81
和 www00:81
?我已经将 set server.name = "blog.mydomain.org"
添加到我的 lighttpd.conf
中,但这不起作用。
任何建议表示赞赏,谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过编辑
wp-config.php
?应该可以覆盖自动主机检测。即:
Have you tried editing your
wp-config.php
? It should be possible to override the automatic host detection.Namely: