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.

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
user1645976
  • 91
  • 1
  • 3
  • possible duplicate of [Lighttpd Reverse Proxy Settings](http://stackoverflow.com/questions/9352283/lighttpd-reverse-proxy-settings) – Paul Sweatte Apr 16 '14 at 19:12

1 Answers1

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 )
        ) 
    )
}
Kinetic
  • 1,714
  • 1
  • 13
  • 38