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)的测试服务,则一切正常。
我说设备 B、C 上的 Web 服务器应该在端口 80 收到请求时响应 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 设备B @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" )
更新
我需要在proxy.server()周围添加$HTTP["host"] == ...来重写/重定向URL吗?或者,如何定义需要被代理的内容。