Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Aug 26, 2010 12:35 am 
Offline
Newbie

Joined: Sun Aug 08, 2010 8:31 pm
Posts: 3
Website: http://www.619cloud.com
Location: San Diego, CA.
We are using Lighttpd web server along with mod_proxy to push requests to a mongrel cluster. Our configuration is:

Code:
proxy.balance = "fair"

$HTTP["host"] == "www.mydomain.com" {
  proxy.server  = ("/" => (
                              ("host" => "127.0.0.1", "port" => 3001),
                                ("host" => "127.0.0.1", "port" => 3002),
                                ("host" => "127.0.0.1", "port" => 3003),
                                ("host" => "127.0.0.1", "port" => 3004)
                          ))
}


The problem is that ALL request are forwarded to mongrel, even static content, css, js, and images. If I try replacing proxy.server = "/" with proxy.server = ".fcgi" the rails application does not work. Any ideas on how we can serve static html, images, js, css from Lighttpd, but push ruby on rails requests to the mongrel cluster?


Top
   
 Post subject:
PostPosted: Sun Aug 29, 2010 12:30 pm 
Offline
Senior Newbie

Joined: Wed Aug 18, 2010 1:31 am
Posts: 13
I must admit I've never used Lighttpd but I often do the same thing with nginx (You might want to look at it if you haven't had specific reasons for lighttpd?) and it seems the config is much the same. Basically you can:

    - Set up a specific directory or subdomain and have it serve that as static
    (eg. Make a folder "static", then use "/static/" in place of "/" and put all images, etc. in there)

    - Match patterns on a URL
    (eg. "Only proxy *.html" or "proxy everything but *.jpg and *.png" for images):
    http://redmine.lighttpd.net/boards/2/topics/3520

    - Tell it to check for a file on disk that matches the URL and only ask the proxy if you can't find one.
    (Sorry, couldn't find an example of this for Lighttpd)

All are safe options, which one is best will depend on your specific setup, you can probably see the pros and cons for your scenario already.


Top
   
 Post subject:
PostPosted: Sun Aug 29, 2010 4:57 pm 
Offline
Newbie

Joined: Sun Aug 08, 2010 8:31 pm
Posts: 3
Website: http://www.619cloud.com
Location: San Diego, CA.
jlynch,

Thanks fort the reply. Somebody actually gave me the solution in the lighttpd forums. I will post it here, hopefully it helps somebody else one day.

Code:
$HTTP["host"] == "www.mydomain.com" {
        $HTTP["url"] !~ "\.(css|js|html|png|jpg|gif|ico|swf)$" {
                proxy.server  = ("" => (
                                        ("host" => "127.0.0.1", "port" => 3002),
                                        ("host" => "127.0.0.1", "port" => 3003),
                                        ("host" => "127.0.0.1", "port" => 3004),
                                        ("host" => "127.0.0.1", "port" => 3005)
                                ))
        }
}
[/b]


Top
   
 Post subject:
PostPosted: Tue Aug 31, 2010 10:10 am 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
Strictly speaking, that's still not correct. What you're doing is telling lighttpd to forward all requests except for those that end in a few static extensions. That doesn't handle unexpected cases; for example, that would redirect for a file called "index.htm" since "htm" isn't in your list of extensions.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group