我需要在lighttpd上设置代理/重写!
我有server1,它通过http 2不同的网络应用程序路径提供服务:
* http://server1/path1
* http://server1/path2
另外,我在server1前面有lighttpd服务器
我想在lighttpd上设置重写和/或代理,以便2条路径中的每条路径都可以作为不同域上的根路径:
* requests to http://server2.com/* are proxied/rewrited to http://server1/path1/*
* requests to http://server3.com/* are proxied/rewrited to http://server1/path2/*
重要的是:
有可能吗?
答案 0 :(得分:4)
几年来,lighttpd开发人员已经了解您的需求。
可以通过变通方法或新功能来解决,具体取决于版本。
Lighttpd 1.4
bugtracker中解释了一种解决方法:bug #164
$HTTP["url"] =~ "(^/path1/)" { proxy.server = ( "" => ("" => ( "host" => "127.0.0.1", "port" => 81 ))) } $SERVER["socket"] == ":81" { url.rewrite-once = ( "^/path1/(.*)$" => "/$1" ) proxy.server = ( "" => ( "" => ( "host" => "server2.com", "port" => 80 ))) }
Lighttpd 1.5
他们使用此命令(official documentation)添加了此功能:
proxy-core.rewrite-request :重写请求标头或请求uri。
$HTTP["url"] =~ "^/path1" { proxy-co... proxy-core.rewrite-request = ( "_uri" => ( "^/path1/?(.*)" => "/$1" ), "Host" => ( ".*" => "server2.com" ), ) }