简体   繁体   English

Apache代理Lighttpd:在PHP中更改$ _SERVER ['HTTP_HOST']

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

I have a WordPress blog running on lighttpd-1.4.19, listening at www00:81. 我有一个运行在lighttpd-1.4.19上的WordPress博客,其网址为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). 在同一主机上,apache-2.2.11侦听端口80,该端口创建从http://blog.mydomain.org:80http://blog.mydomain.org:81的代理连接(两者都是相同的物理端口)机)。

The Apache virtualhost looks as follows: 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>

Using debug.log-request-handling = "enable" , I get the following log entry when I browse http://blog.mydomain.org:80 (notice the Host headers): 使用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

My problem: as far as I know, the PHP environment variable $_SERVER['HTTP_HOST'] is set to that Host header variable. 我的问题:据我所知,PHP环境变量$_SERVER['HTTP_HOST']设置为该Host标头变量。 Unfortunately, WordPress uses that variable in their system to create URLs to pictures on the blog. 不幸的是,WordPress在其系统中使用该变量来创建指向博客上图片的URL。 These URLs won't be accessible behind a firewall of course. 当然,在防火墙后将无法访问这些URL。 How can I force the host header to be blog.mydomain.org instead of blog.mydomain.org:81 , respectively www00:81 ? 如何强制将主机标头分别为blog.mydomain.org而不是blog.mydomain.org:81www00:81 I already added set server.name = "blog.mydomain.org" to my lighttpd.conf , but this didn't work. 我已经将set server.name = "blog.mydomain.org"到了我的lighttpd.conf ,但这没有用。

Any suggestions are appreciated, thank you. 任何建议表示赞赏,谢谢。

Have you tried editing your wp-config.php ? 您是否尝试过编辑wp-config.php It should be possible to override the automatic host detection. 应该可以覆盖自动主机检测。

Namely: 即:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 安全的php主机名信息 - $ _SERVER [&#39;HTTP_HOST&#39;]替代方案 - secure php host name information - $_SERVER['HTTP_HOST'] alternative $ _SERVER [&#39;HTTP_HOST&#39;]无法识别 - $_SERVER['HTTP_HOST'] not recognized $ _SERVER [&#39;HTTP_HOST&#39;]未设置 - $_SERVER['HTTP_HOST'] not set 无法在php mail()中使用变量$ _SERVER [&#39;HTTP_HOST&#39;] - Cannot use variable $_SERVER['HTTP_HOST'] in php mail() 在PHP中,$ _ SERVER [&#39;HTTP_HOST&#39;]的Perl等价于什么? - What is the Perl equivalent of $_SERVER['HTTP_HOST'] in PHP? PHP中的HTTP_HOST和SERVER_NAME有什么区别? - What is the difference between HTTP_HOST and SERVER_NAME in PHP? 在Chrome中,基于$ _SERVER [&#39;HTTP_HOST&#39;]的PHP加载CSS失败 - PHP load CSS based on $_SERVER['HTTP_HOST'] fails in Chrome JSP或JavaScript等效于PHP的$ _SERVER [“HTTP_HOST”]? - JSP or JavaScript equivalent to PHP's $_SERVER[“HTTP_HOST”]? PHP $ _SERVER ['HTTP_HOST']转义,这看起来可以接受吗? - PHP $_SERVER['HTTP_HOST'] escaping, does this look acceptable? 还有PHP的$ _SERVER [&#39;HTTP_HOST&#39;])的替代方法吗? 适用于不需要完整的编程语言(例如SSI)的Apache - Is there an alternative to PHP's $_SERVER['HTTP_HOST']); for apache that does not require a full blown programming language (e.g. SSI)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM