Lighttpd负载均衡配置

use*_*976 5 port configuration load-balancing lighttpd localhost

我正在使用Lighttpd 1.4.30在Play Framework中配置负载均衡器.

我在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 ) ) 
    )
}
Run Code Online (Sandbox Code Playgroud)

我的播放应用程序在端口9020,9030上正常运行.

但是,当我尝试http://localhost:80我的负载均衡器时,应将请求转移到任何未发生的端口.我只获得了Lighttpd测试页面.

Kin*_*tic 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 )
        ) 
    )
}
Run Code Online (Sandbox Code Playgroud)