Lighttpd With Mod_Proxy And Mongrel Problem
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?
3 Replies
* - 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):
<url url="http://redmine.lighttpd.net/boards/2/topics/3520">http://redmine.lighttpd.net/boards/2/topics/3520</url>
- 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)</list>
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.
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.
`$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)
))
}
}` [/url]