Lighttpd load balancing configuration
Asked Answered
S

1

7

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.

Surpassing answered 10/1, 2013 at 11:20 Comment(1)
possible duplicate of Lighttpd Reverse Proxy SettingsWagshul
C
3

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 )
        ) 
    )
}
Colour answered 16/12, 2015 at 10:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.