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.
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 )
)
)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With