Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
1  
Could you post all configuration related to server1, server2 ? –  j0k Sep 21 '12 at 8:44
    
I've added the configuration to the main question. –  Juanin Sep 21 '12 at 9:57
add comment

1 Answer

up vote 1 down vote accepted

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)
             )
        )
}
share|improve this answer
    
I tried the First one solution and it worked fine. Thanks a lot. –  Juanin Sep 25 '12 at 8:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.