Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using Passenger with nginx to serve my rails app on a virtual Slice host. I am considering putting a reverse proxy for serving static content as well as handling etagged actions.

  1. Can I use my existing nginx installation and just change it to a reverse proxy? Do I even need a web server? What would a typical architecture look like in this case?

    nginx rev-proxy -> nginx web server -> passenger?
    

    or

    nginx rev-proxy ->  passenger?
    
  2. Is nginx the best choice in this case?

  3. Can my reverse proxy reside on the same Slice?

Thanks

share|improve this question

migrated from superuser.com Oct 12 '10 at 9:41

This question came from our site for computer enthusiasts and power users.

1 Answer 1

  1. Yes you can use your nginx install. You don't need to proxy at all, just continue using passenger with nginx and have nginx server static content direct

  2. Popular opinion is probably, if you had Apache or Squid running you might consider using them, but since you have nginx already, nginx is a great choice. Avoiding using passenger to serve static files may offer significant performance gains - but of course you milage will vary.

  3. Same server/slice probably fine, if your traffic was so large that it had an impact, sure move it to another server, but there is no reason to proxy it, just change the urls accordingly - this is what serverfault does.

An example config file would be:

server {
listen www.example.com:80;

server_name  www.example.com;

    location ~* ^.+\.(jpg|jpeg|gif|png|css|bmp|js|ico|swf)$ {
       root  /home/static/files;
       expires 7d;
    }

    location / {
       root /home/rails_app;
       passenger_enabled on;
    }     

}

Obviously add any additional files types as necessary.

share|improve this answer
    
Thanks. couple of clarifications. Here is my current nginx.conf file. pastie.org/1216283. 1 - It seems in your example, the root for static files is different than that of the rails root, normally my static files are in public folder in rails root, public/stylesheets, public/assets folder, how do I specify that or is this /root is where it is caching them? 2 - Why no need to proxy? If the web server is good enough to handle static assets, why folks put a reverse proxy in front of apache? Isn't the RP capable of handling more requests? –  user55714 Oct 12 '10 at 18:58
    
@user55714 1) Well sure you need to change the root location to wherever your files are. 2)What are you trying to achieve with a reverse proxy? I find it hard to believe that nginx can't handle the load. –  Jon Rhoades Oct 13 '10 at 5:51
    
I am trying to cache as many requests possible, using etags in my rails app. I wasn't sure if a non-reverse proxy configuration would support etagging and also in general I hear reverse proxies are lot more scalable, but then again, I am open to suggestions. –  user55714 Oct 13 '10 at 6:57
    
I am trying to cache as many requests possible, using etags in my rails app. I wasn't sure if a non-reverse proxy configuration would support etagging and also in general I hear reverse proxies are lot more scalable, but then again, I am open to suggestions. –  user55714 Oct 13 '10 at 17:47
    
"Avoiding using passenger to serve static files may offer significant performance gains - but of course you milage will vary." -- That doesn't make sense. Phusion Passenger for Nginx serves static files using Nginx. –  Hongli Lai Oct 21 '10 at 15:37

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.