DeviceA 用作反向代理,应该按如下方式转发请求:
192.168.1.10/DeviceB ==> 192.168.1.20/index.html
192.168.1.10/DeviceC ==> 192.168.1.30/index.html
两个索引文件都位于 /var/www 下,并且是静态的“Hello world!” 页。问题是我无法通过 DeviceA 访问这些文件,但如果我调用也在 DeviceC 上运行的测试服务(侦听端口 12345)一切正常。
如果请求来自端口 80,我是否说 DeviceB 上的 Web 服务器,DeviceC 应该以 index.html 响应?
lighttpd.conf DeviceA @192.168.1.10 server.modules = ( "mod_proxy" )
proxy.server = (
"/DeviceB" => ( "" => ( "host" => "192.168.1.20", "port" => 80 )),
"/DeviceC" => ( "" => ( "host" => "192.168.1.30", "port" => 80 )),
"/TestService" => ( "" => ( "host" => "192.168.1.30", "port" => 12345 ))
)
lighttpd.conf DeviceB @192.168.1.20
server.document-root = "/var/www"
server.port = 80
index-file.names = ( "index.html" )
lighttpd.conf DeviceC @192.168.1.30
server.document-root = "/var/www"
server.port = 80
index-file.names = ( "index.html" )
更新
我是否需要 $HTTP["host"] == ... 围绕 proxy.server() 来重写/重定向 URL?或者,如何定义代理(ed)