$HTTP["host"] == "a.aslibra.com" {
proxy.server = ( "" =>
( (
"host" => "b.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)
"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);
?>
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
[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
) )
)
}
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
[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这样肯定对效率有很大的提高。
原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
艺术乃是人活着的目的
Linux下使用光盘和ISO文件
