nginx and rails configuration question
sean at monkeysnatchbanana.com
Mon Apr 7 19:31:07 MSD 2008
On Apr 7, 2008, at 9:34 AM, Cathal wrote:
> I found the following post:
> http://article.gmane.org/gmane.comp.web.nginx.english/2283 which is
> very similar
> to what I am attempting. My problem is that my nginx can't resolve
> static files
> prefixed with the path matched in the location directive. All static
> requests are then proxied to the rails app. which cannot resolve
> them either.
> Can anybody provide some guidance?
you just want to remove the /app2 /app1 etc from static file checks?
am i reading all that correctly?
if yes, this was our ugly solution to the fact that we write tracking
info into the url
( not rails but same scenario )
/dir/file.html would appear as url as /s-SOMETHINGHERE/dir/file.html
set $dynamic 0;
set $real_file $request_filename;
if ( $uri ~* ^(/s-[^/]*/)(.*)$ )
set $real_file $document_root/$2;
set $has_lid 1;
# IS IT DYNAMIC?
if ( !-e $real_file )
set $dynamic 1;
# FILE DOESNT EXIST SO WE HAND OFF
if ( $dynamic )
# DO YOU DYNAMIC HANDLING HERE
# THIS REWRITES OUT THE EXTRA STUFF FOR STATIC HANDLING
if ( $has_lid )
rewrite ^(/s-[^/]*/)(.*)$ /$2;
This may not be the best way to do it. But it works.
More information about the nginx