Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lighttpd load balancing configuration

I am configuring a Load balancer in Play Framework using Lighttpd 1.4.30.

I have given entries in lighttpd-inc.conf as below.

$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 ) ) 
    )
}

My play application is running fine on ports 9020, 9030.

But when I tried http://localhost:80 my load balancer should transfer the request to any of these ports which is not happening. I am getting only Lighttpd test page.

like image 858
user1645976 Avatar asked Jan 10 '13 11:01

user1645976


1 Answers

Firstly make sure you have mod_proxy in your server.modules array.

I think using $HTTP["host"] is the problem here. You should use $SERVER["socket"] like so:

$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 )
        ) 
    )
}
like image 77
Kinetic Avatar answered Nov 15 '22 04:11

Kinetic