Lighttpd代理tomcatpath

我的tomcat服务2个网站

ROOT -> Main-site /mobile -> dedicated mobile website 

我已经configurationlighttpd作为代理

 $HTTP["host"] =~ "www.my-site.at" { proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => 8080 ) )) } 

我怎么能告诉lighttpd使用http://127.0.0.1:8080/mobile为m.my-site.at? 或者我必须configuration第二个tomcat并在ROOT下部署移动网站?

谢谢

可以使用url.rewrite-onceurl.rewrite-once所有请求加上/mobile

 $HTTP["host"] == "m.my-site.at" { url.rewrite-once = ( ".*" => "/mobile$0" ) proxy.server = (...) } 

你可能不得不在mod_proxy之前加载mod_rewrite来获得这个工作。

重写这样的问题是后端现在看到一个不匹配浏览器视图的path。 后端可能会尝试发送以/mobile为前缀的path,或者以相对path混淆东西。 一些代理可能会尝试修复这些path的响应,但是lighttpd不会(并且你永远不会捕获所有的path)。

真正的解决办法是让后端了解虚拟主机 – 即根据主机名处理不同的请求。 如果后端不能这样做,那么可能需要运行多个实例。