2

I have a Lighttpd server as a front end for Ruby on rails.

Some subdomains (server1.domain.com, server2.domain.com) are configured with proxy.

But also have a standard static web server at www.domain.com.

It works, but the call without subdomain (domain.com) does not work.

How could I configure Lighttpd for it?

Configuration for proxy:

$HTTP["host"] =~ "www.domain." {
    alias.url = ( "/system/" => "/var/www/system/" )
        proxy.balance = "fair"
        proxy.server  = ( "" => (
            ( "host" => "127.0.0.1", "port" => 5750)
             )
        )
}

Configuration for server1 and server2:



$HTTP["host"] =~ "server1.domain." {
    alias.url = ( "/system/" => "/var/www/system/" )
        proxy.balance = "fair"
        proxy.server  = ( "" => (
        ( "host" => "127.0.0.1", "port" => 7757 ) ,
                ( "host" => "127.0.0.1", "port" => 5222),
                ( "host" => "127.0.0.1", "port" => 5223)
                )
    )
}

$HTTP["host"] =~ "server2.domain." {
    alias.url = ( "/system/" => "/var/www/system/" )
        proxy.balance = "fair"
        proxy.server  = ( "" => (
        ( "host" => "127.0.0.1", "port" => 7787 ) ,
                ( "host" => "127.0.0.1", "port" => 5282),
                ( "host" => "127.0.0.1", "port" => 5283)
                )
    )
}

Juanin
  • 123

1 Answers1

2

You have two solutions.

First one

Redirect traffic to the www if the domain is domain.com:

$HTTP["host"] =~ "^domain\.com" {
        url.redirect = (
                "^/(.*)" => "http://www.domain.com/$1",
                ""       => "http://www.domain.com/"
        )
}

Second one

Handle traffic for both www.domain. and domain. (be careful about the duplicate content then). Replace the old rule for www.domain. by:

$HTTP["host"] =~ "(^domain.)|(^www.domain.)" {
    alias.url = ( "/system/" => "/var/www/system/" )
        proxy.balance = "fair"
        proxy.server  = ( "" => (
            ( "host" => "127.0.0.1", "port" => 5750)
             )
        )
}
j0k
  • 148