My question is about the static files in the Rails public folder. These files should be served by Apache instead of Mongrel, so do I need to upload these files to Apache''s htdoc''s or will Apache cache them the first time they are requested from Mongrel... Im not sure how this works? Many thanks.
Hi! Take a look at this document: http://mongrel.rubyforge.org/docs/ apache.html You should leave the static files in the public folder of your application, and configure Apache to use rewriting (see section "Configuring Apache2"). Regards, Hendrik Am 21.09.2006 um 16:27 schrieb Kris Leech:> My question is about the static files in the Rails public folder. > These > files should be served by Apache instead of Mongrel, so do I need to > upload these files to Apache''s htdoc''s or will Apache cache them the > first time they are requested from Mongrel... Im not sure how this > works? > > Many thanks. > > > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users
> My question is about the static files in the Rails public folder. These > files should be served by Apache instead of Mongrel, so do I need to > upload these files to Apache''s htdoc''s or will Apache cache them the > first time they are requested from Mongrel... Im not sure how this works?Apache won''t cache them unless you tell it to. I think most people point Apache to RAILS_ENV/public and configure things so that Apache only passes on requests to mongrel that it can''t find in the filesystem... http://mongrel.rubyforge.org/docs/apache.html (configuring apache2 section) -philip
On 9/21/06, Kris Leech <krisleech at interkonect.com> wrote:> My question is about the static files in the Rails public folder. These > files should be served by Apache instead of Mongrel, so do I need to > upload these files to Apache''s htdoc''s or will Apache cache them the > first time they are requested from Mongrel... Im not sure how this works? > > Many >Please search through the mailing list. Someone explained nicely, how rewrite rules that you probably copied from mongrel page...searches for the existence of a file....it it finds the requested file...well apache serves it..otherwise it assumes, a dynamic request and forwards it to mongrel. -- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary.
Thanks for the replies, I have read the apache page in the mongrel docs already, I guess I didnt explain too well, but what I do get is that if Apache and Mongrel are on the same physical machine that you can set Apache''s DocumentRoot to the public folder and it would look there for static files first. But if Apache and Mongrel are on different machines Apache does not have access to the files in public... I hope that makes my question a bit clearer? Many thanks.
Kris Leech wrote:> Thanks for the replies, I have read the apache page in the mongrel docs > already, I guess I didnt explain too well, but what I do get is that if > Apache and Mongrel are on the same physical machine that you can set > Apache''s DocumentRoot to the public folder and it would look there for > static files first. But if Apache and Mongrel are on different machines > Apache does not have access to the files in public... > > I hope that makes my question a bit clearer? >The easiest way is to define an "asset_host": config.action_controller.asset_host = "http://assets.example.com" Look at your "config/environments/production.rb" file, you should see that line in there. When rails helpers generate links to static content, the above asset_host is used in the URLs. Browsers would then go to your asset server cluster to get that static content. The "other" way to address this would be to have a "reverse proxy" tier in front of your web tier and rails tier that would use something like mod_rewrite rules to shunt content to the appropriate cluster. If the static files are more difficult to identify than simply grouping the content directories (/images/, /javascript/, /stylesheets/), that would mean adding a new RewriteRule everytime you add some static content, unless the "reverse proxy" tier has a local reference copy to use to know where to shunt the request. On the other hand, if your reverse proxy tier already has an rsynced copy of the public folder static content, and can serve that static content directly, it is arguable why you wouldn''t simply host the static content off of your reverse proxy tier directly. This is what many folks appear to be doing with apache 2.2 and mod_proxy_balancer right now. - Ian C. Blenke <ian at blenke.com> http://ian.blenke.com/