我正在尝试在lighttpd中设置一个反向代理,这样/ mobile / video下的所有请求(只有这些请求)才会被redirect到辅助Web服务器的/目录。 这在Apache中是相当容易的,但我不能在我的生活中弄清楚如何在lighttpd中这样做。
$HTTP["url"] =~ "^/wsmobile/video/" { url.rewrite-once = ( "^/wsmobile/video/(.+)" => "/$1" ) proxy.server = ( "" => ( ( "host" => "210.200.144.26", "port" => 9091 ) ) ) }
我已经尝试使用http [“url”]指令,但lighttpd只是忽略这些请求,并继续传递完整的URL到辅助服务器,当然扼杀和抛出404s。 但是,如果我做全局重写,那么一切都被转发到辅助服务器,这也不是我想要的。
我如何去做这个任务?
url重写将不能在$HTTP["url"] 。 但是,您应该能够以这种方式全局重写它:
url.rewrite-once = ( "^/wsmobile/video/(.*)" => "/test/" )
然后抓住它:
$HTTP["url"] =~ "^/test/" { # do proxy here }
更新:
请看这里: Lighttpd错误#164 。 具体来说, proxy-core.rewrite-request应该是你正在寻找的。