轻量级Web服务器Lighttpd负载均衡配置

7

我正在使用Lighttpd 1.4.30在Play框架中配置负载均衡器。

我已经在lighttpd-inc.conf中添加了以下条目。

$HTTP["host"] =~ "http://10.74.9.109:9020" {
proxy.balance = "round-robin" proxy.server = ( "/" =>
( ( "host" => "10.74.9.109", "port" => 9020 ) ) )
}

$HTTP["host"] =~ "http://10.74.9.109:80" {
    proxy.balance = "round-robin" proxy.server = ( "/" => ( 
          ( "host" => "10.74.9.109", "port" => 9020 ), 
          ( "host" => "10.74.9.109", "port" => 9030 ) ) 
    )
}

我的Play应用程序在9020和9030端口上运行良好。

但是当我尝试访问http://localhost:80时,我的负载均衡器应该将请求传输到其中任何一个端口,但这并没有发生。我只看到了Lighttpd测试页面。


可能是Lighttpd反向代理设置的重复问题。 - Paul Sweatte
你找到解决方案了吗? - aggsol
1个回答

3

首先确保您的 server.modules 数组中有 mod_proxy 模块。

我认为在这里使用 $HTTP["host"] 是问题所在。您应该像这样使用 $SERVER["socket"]

$SERVER["socket"] == ":9020" {
    proxy.server = (
        "/" => (
            (
                "host" => "10.74.9.109",
                "port" => 9020
            )
        )
    )
}

$SERVER["socket"] == ":80" {
    proxy.server = (
        "/" => ( 
              ( "host" => "10.74.9.109", "port" => 9020 ), 
              ( "host" => "10.74.9.109", "port" => 9030 )
        ) 
    )
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接