$HTTP["host"] == "a.aslibra.com" {
       proxy.server = ( "" =>
                  ( (
                      "host" => "b.aslibra.com"
                    ) )
        )
}


这样的代码在apache里面是正常的,今天使用lighttpd就发现出现 500 的内部错误。
于是查资料,看看lighttpd的官方说明:

引用
<extension>: is the file-extension or prefix (if started with "/") might empty to match all requests
"host": is ip of the proxy server ''DO not use hostnames here! only IP Addresses''
"port": is tcp-port on the "host" used by the proxy server (default: 80)


也就是不允许用域名了,不知道是否正常,可以测试一下:

做个PHP文件:

proxy.php
<?
ob_start();
print_r($_SERVER);
$a=ob_get_contents();
file_put_contents("log.txt",$a);
?>


得到代码:
wget http://127.0.0.1/proxy.php
引用
   [SERVER_NAME] => 127.0.0.1
   [GATEWAY_INTERFACE] => CGI/1.1
   [SERVER_PORT] => 80
   [SERVER_ADDR] => 127.0.0.1
   [REMOTE_PORT] => 50677
   [REMOTE_ADDR] => 127.0.0.1


指定proxy和hosts文件:
127.0.0.1 proxy.aslibra.com

$HTTP["host"] == "proxy.aslibra.com" {
       proxy.server = ( "" =>
                  ( (
                      "host" => "127.0.0.1",
                      "port" => 80
                    ) )
        )
}


引用
   [SERVER_NAME] => proxy.aslibra.com
   [GATEWAY_INTERFACE] => CGI/1.1
   [SERVER_PORT] => 80
   [SERVER_ADDR] => 127.0.0.1
   [REMOTE_PORT] => 50676
   [REMOTE_ADDR] => 127.0.0.1


也就是发送的还是当前的主机域名,所以proxy也不用担心只是按IP访问,和正常的代理一样。

但是,这样的话,如果域名指向有变化,那这里就不方便了,apache里面可以用域名的方式,那其实可以不用担心域名指向变化,但lighttpd这样肯定对效率有很大的提高。


原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
Tags: ,
发表评论
表情
emotemotemotemotemotemotemotemotemotemotemotemotemot
emotemotemotemotemotemotemotemotemotemotemotemot
打开HTML 打开UBB 打开表情 隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写
 

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐