Normally, when you setup Nginx and Passenger to serve your rails application, all static files are served by Nginx without hitting Passenger. What really happens is that all static files that do exist are served by Nginx and the rest are passed on to passenger.
will be served by Nginx, but
will continue to Passenger going all the way through the Rails stack. Instead of a simple 1ms nginx process , you get a full stack rails request with a route recognition error. Not good.
Missing or outdated images (specially if your site is big on content) or stupid robots searching for certain .php (or .js, or _vti_bin(?) or whatever) vulnerable files is common place. Why would you want those requests to pass on to Passenger?
Using an asset host
One solution is to use an asset host for all static files by using an absolute url like:
Then you can make a separate entry for nginx for assets.mydomain.com with just a root directive to your public directory. This way static files will always be served by nginx, even the missing ones.
In addition you can specify multiple asset hosts and tell Rails to cycle through them. This is especially good for splitting the load among multiple servers and bypassing the 2 requests per ip browser constraint. What I don’t like with this approach is that simple image tags have to go through the image_tag helper, causing some overhead for no good reason.