I''m looking for an easy way to have mongrel only serve dynamic railscontent, while letting Apache serve non-Rails content. Unfortunately,it seems that you have to segregate the static content in its ownfolder. That was also the case with the SCGI runner. I used thetrick outlined athttp://comments.gmane.org/gmane.comp.lang.ruby.rails/23347 to managethis. I was curious if a similar trick would be the best way tohandle this issue with Mongrel. I''m hoping that there''s a simpler wayI''ve overlooked. -- Kyle MaxwellChief TechnologistE Factor Media // FN Interactivekyle at efactormedia.com1-866-263-3261
Will_Green at URSCorp.com
2006-May-19 19:23 UTC
[Mongrel] Mongrel/Apache and static content
This can be accomplished easily with mod_proxy (assuming only one rails app per virtual host, and using Apache 2.2 with mod_proxy_balancer). ProxyPass /images ! ProxyPass /stylesheets ! ProxyPass /javascripts ! ProxyPass / balancer://myapp/ ProxyPassReverse / balancer://myapp/ =Will Green Web Developer & IT Coordinator, URS Creative Imaging http://www.urscreativeimaging.com/ 7650 West Courtney Campbell Causeway Suite 700 Tampa, FL 33607 813.675.6849 (direct) 813.286.1711 (main) This e-mail and any attachments are confidential. If you receive this message in error or are not the intended recipient, you should not retain, distribute, disclose or use any of this information and you should destroy the e-mail and any attachments or copies.
> This can be accomplished easily with mod_proxy (assuming only one rails app> per virtual host, and using Apache 2.2 with mod_proxy_balancer).I don''t think you read my post. Particularly, the part where I said:> Unfortunately, it seems that you have to segregate the static content in its own> folder.To clarify, I was wondering about mixing static and dynamic content inthe same folder or folder hierarchy. -- Kyle Maxwell
Hi Kyle, You''ll need a set of mod_rewrite rules to really get this right. I''m currently writing the apache best practice documentation, so I''ll ping the list and you specifically when that''s working right. Zed On Fri, 2006-05-19 at 14:38 -0700, Kyle Maxwell wrote:> > This can be accomplished easily with mod_proxy (assuming only one rails app> per virtual host, and using Apache 2.2 with mod_proxy_balancer). > I don''t think you read my post. Particularly, the part where I said: > > Unfortunately, it seems that you have to segregate the static content in its own> folder. > To clarify, I was wondering about mixing static and dynamic content inthe same folder or folder hierarchy. > > -- Kyle Maxwell > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users
Hey y''all... Give this a try and let me know how it works! http://fluxura.com/articles/2006/05/19/apache-for-static-and-mongrel- for-rails-with-mod_deflate-and-capistrano-support Thanks, Bradley Taylor ------ Rails Machine Simplified Ruby on Rails application deployment http://railsmachine.com On May 19, 2006, at 5:45 PM, Zed Shaw wrote:> Hi Kyle, > > You''ll need a set of mod_rewrite rules to really get this right. I''m > currently writing the apache best practice documentation, so I''ll ping > the list and you specifically when that''s working right. > > Zed > > On Fri, 2006-05-19 at 14:38 -0700, Kyle Maxwell wrote: >>> This can be accomplished easily with mod_proxy (assuming only one >>> rails app> per virtual host, and using Apache 2.2 with >>> mod_proxy_balancer). >> I don''t think you read my post. Particularly, the part where I said: >>> Unfortunately, it seems that you have to segregate the static >>> content in its own> folder. >> To clarify, I was wondering about mixing static and dynamic >> content inthe same folder or folder hierarchy. >> >> -- Kyle Maxwell >> _______________________________________________ >> Mongrel-users mailing list >> Mongrel-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/mongrel-users > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users
> http://fluxura.com/articles/2006/05/19/apache-for-static-and-mongrel-> for-rails-with-mod_deflate-and-capistrano-supportThat''s a mouthful, but it sounds promising :)
On May 19, 2006, at 4:02 PM, Kyle Maxwell wrote:>> http://fluxura.com/articles/2006/05/19/apache-for-static-and- >> mongrel-> for-rails-with-mod_deflate-and-capistrano-support > That''s a mouthful, but it sounds promising :) > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-usersIt''s just the # Redirect all non-static requests to cluster RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L] part for what you''re asking for and Bradley''s correct, that will work fine for you. That''s a nice elegant two line config for that (nice work bradley). We tend to stick to only proxying rather than rewriting and while you can do ProxyPass /favicon.ico ! There isn''t any respect for a wildcard there in the proxy pass directive. Regards, J ???????????????????????????????????????????????????????????? Jason A. Hoffman, PhD | Founder, CTO, Joyent Inc. Email: jason at joyent.com or jason at textdrive.com ????????????????????????????????????????????????????????????
Hi Jason, On May 19, 2006, at 7:21 PM, Jason Hoffman wrote:> > # Redirect all non-static requests to cluster > RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f > RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} > [P,QSA,L] > part for what you''re asking for and Bradley''s correct, that will work > fine for you.I should have highlighted that part! Thanks for pointing it out.> That''s a nice elegant two line config for that (nice > work bradley).Thanks!> > We tend to stick to only proxying rather than rewriting and while you > can do > > ProxyPass /favicon.ico ! > > There isn''t any respect for a wildcard there in the proxy pass > directive.There''s definitely a trade off of performance for configuration simplicity/maintainability. The rewrites certainly have a negative impact on performance, but the ability to "config and forget" is pretty appealing for a lot of deployments. If you don''t use Rails page caching and you don''t mind occasionally adding additional ProxyPass directives for application specific assets, then proxying is the way to go. Modifying the Apache conf to add a file_column or reloading a new conf to support Capistrano''s disable_web is kind of a drag (and an annoyance for automated deployment/configuration). I''m hoping to find a better balance between the two approaches than what I wrote up, but need to spend more time with httperf (and a big jug of corn whiskey). I imagine the answer is dependent on the maturity of one''s application, comfort level with sysadmin stuff, and need to support 2000 requests/sec or 2000 requests/week! It would be nice to have some good benchmarks on various deployments and graph the relationship between simplicity, features, and performance. Unfortunately, I tend to quickly loose productive development hours when I get sucked into the parallel universe that is httperf and Apache configuration tweaking. What we, the Mongrel Nation, need is a front-end with the simplicity of Pound combined with Lighty''s static performance, good caching support, and select Apache features . Seems like quite an opportunity for an enterprising C/C++ developer... Regards, Bradley Taylor ------ Rails Machine Simplified Ruby on Rails application deployment http://railsmachine.com
Bradley, I tried this apache config and it worked fien. Only issue I found: After uncommenting all logfile lines, I got an error at: logs/your_app_deflate_log I replaced with: logs/your_app_deflate_log deflate and it worked, but (so far) only compressed HTML files and no javascript or CSS files (Browser: Firefox 1.5.3) But considering that is took a couple of minutes to get and compile form source apache 2.2.2 and make it work with mongrel, I am more than satisfied with the result. (With my lighty-mongrel setup I didn''t get compressing to work at all) regards Roberto On 5/19/06, bradley taylor <bradley at railsmachine.com> wrote:> > Hey y''all... > > Give this a try and let me know how it works! > > http://fluxura.com/articles/2006/05/19/apache-for-static-and-mongrel- > for-rails-with-mod_deflate-and-capistrano-support > > Thanks, > Bradley Taylor > > ------ > Rails Machine > Simplified Ruby on Rails application deployment > http://railsmachine.com > > On May 19, 2006, at 5:45 PM, Zed Shaw wrote: > > > Hi Kyle, > > > > You''ll need a set of mod_rewrite rules to really get this right. I''m > > currently writing the apache best practice documentation, so I''ll ping > > the list and you specifically when that''s working right. > > > > Zed > > > > On Fri, 2006-05-19 at 14:38 -0700, Kyle Maxwell wrote: > >>> This can be accomplished easily with mod_proxy (assuming only one > >>> rails app> per virtual host, and using Apache 2.2 with > >>> mod_proxy_balancer). > >> I don''t think you read my post. Particularly, the part where I said: > >>> Unfortunately, it seems that you have to segregate the static > >>> content in its own> folder. > >> To clarify, I was wondering about mixing static and dynamic > >> content inthe same folder or folder hierarchy. > >> > >> -- Kyle Maxwell > >> _______________________________________________ > >> Mongrel-users mailing list > >> Mongrel-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/mongrel-users > > > > _______________________________________________ > > Mongrel-users mailing list > > Mongrel-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/mongrel-users > > > > > > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-- Roberto Saccon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20060520/e870ce4f/attachment.htm
On May 20, 2006, at 10:04 AM, Roberto Saccon wrote:> and it worked, but (so far) only compressed HTML files and no > javascript or CSS files (Browser: Firefox 1.5.3)So that''s because of # Deflate AddOutputFilterByType DEFLATE text/html text/plain text/xml With mod_deflate you have two options: compress everything by default and exclude what you don''t want to run through (like .gif), or compress nothing by default and include the mime types you want to compress. I call this implicit (these are the "Set" commands) or explicit (these are the "Add" commands) compression. Bradley''s config is explicit because it lists the mime-types. I put a complete config example at http://textsnippets.com/posts/show/ 486 - J
On May 19, 2006, at 6:02 PM, bradley taylor wrote:> There''s definitely a trade off of performance for configuration > simplicity/maintainability. The rewrites certainly have a negative > impact on performance, but the ability to "config and forget" is > pretty appealing for a lot of deployments.Yes, agreed.> If you don''t use Rails page cachingOne question here is where one does the caching. On web servers? In a cache module in your switches/routers? Dedicated edge of network caches? RAM caches on dedicated load-balancers (this is generally where we let caching happen)? When it comes to caching on web servers I think the issue really of cached versus dynamic is speed of ramp-up to a steady state. When you get a big enough bump of traffic, can you respond without getting so far behind that you can''t recover? The usual question I ask is whether the application and web is already up and humming, and if so, can it saturate the network connection?> and you don''t mind occasionally adding additional > ProxyPass directives for application specific assets, then proxying > is the way to go. Modifying the Apache conf to add a file_column or > reloading a new conf to support Capistrano''s disable_web is kind of a > drag (and an annoyance for automated deployment/configuration).Yes, luckily rails applications are pretty standard, a single ProxyPass /images ! is sufficient for all sites. And while mod_rewrite versus mod_proxy to do the proxying itself are mutually exclusive, I thought you could combine other aspects/functions. I forget (because I typically don''t combine them) is it really the case the a series of mod_rewrite rules are ignored when followed by proxy pass directives?> It would be nice to have some good benchmarks on various > deployments and > graph the relationship between simplicity, features, and performance. > Unfortunately, I tend to quickly loose productive development hours > when I get sucked into the parallel universe that is httperf and > Apache configuration tweaking.It probably wouldn''t be much different. We''ve been doing quite of a bit of tracing through the stack with dtrace (dtrace in Kernel SSL, mod_dtrace in apache2, dtrace providers in ruby, dtrace providers in postgresql etc) and the rewriting process in apache isn''t too heavy for most common rewrites (mod_security is a heavier module).> What we, the Mongrel Nation, need is a front-end with the simplicity > of Pound combined with Lighty''s static performance, good caching > support, and select Apache features . Seems like quite an opportunity > for an enterprising C/C++ developer...If someone has specific ideas about this (I do) and would interested in being employed doing it, let me know. - J
On Sat, 2006-05-20 at 11:48 -0700, Jason Hoffman wrote:> > What we, the Mongrel Nation, need is a front-end with the simplicity > > of Pound combined with Lighty''s static performance, good caching > > support, and select Apache features . Seems like quite an opportunity > > for an enterprising C/C++ developer... > > If someone has specific ideas about this (I do) and would interested > in being employed doing it, let me know.Well, I guess it''s time to just let everyone know that I''m working on a "super secret" proxy server to go along with Mongrel that would basically do all the stuff Bradley is talking about (which Bradley knows so I''m curious why he''s jamming my game! :-). It''s only secret because I''m still rolling the code around in my head and trying out alternative designs between Mongrel stints and Adult Swim viewings. There''s also a few other folks working on something similar, but I''ll let them tell everyone. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/
On May 20, 2006, at 3:51 PM, Zed Shaw wrote:> > Well, I guess it''s time to just let everyone know that I''m working > on a > "super secret" proxy server to go along with Mongrel that would > basically do all the stuff Bradley is talking about (which Bradley > knows > so I''m curious why he''s jamming my game! :-).It''s job security. If I can secretly promote the creation of 5 different proxy servers with 86.7% functional overlap, then Rails deployment will remain a complex, mystical endeavor. Come on, if this stuff was actually straightforward, how am I supposed to retire to a Georgia barrier island next year? My life of mint juleps and long walks on the beach awaits! :-) :bradley ------ Rails Machine Simplified Ruby on Rails application deployment http://railsmachine.com