对于相同的主机名,我想做如下的映射
/subdirectory/_different_end_points_.json map to 127.0.0.1:9001
/_different_end_points_.json map to 127.0.0.1:9002
怎么做?根据文档,要求else子句也必须在条件上匹配,这使我疯狂(作为正则表达式的初学者)
答案 0 :(得分:1)
你有没有尝试过类似的东西:
$HTTP["url"] =~ "^/subdirectory/_different_end_points_.json" {
proxy.server = (
"/" => (("host" => "127.0.0.1", "port" => 9001))
)
}
else $HTTP["url"] =~ "^/_different_end_points_.json" {
proxy.server = (
"/" => (("host" => "127.0.0.1", "port" => 9002))
)
}
这样,您就可以将开始的每个网址与/subdirectory/_different_end_points_.jso
或(在其他地方)/_different_end_points_.json
匹配。
但请确保您的网址真正以正则表达式开头!我的意思是:h * tp://sample.com/subdirectory/_different_end_points_.json和h * tp://sample.com/_different_end_points_.json