Rails, Nginx and blocking linked images

Hi Everyone,

Im using the standard rails/mongrel config script
(http://wiki.codemongers.com/NginxRubyonRailsMongrel) for a rails site
but Im trying to block images from being linked from other sites.

It looks like something like this is supposed to do it:

location ~* .(gif/jpg/png/swf/flv)$ {
valid_referers none blocked mydomain.coml;

if ($invalid_referer) {
return 403;

But when I insert this inside the server block (after the location
/50x.html) line all my images come up as 404 when requested via the
site…Nginx is pretty hard to work out in these cases…any ideas
why this is happening?

In fact, even if I put that location block in with nothing in it at
all it 404s my images…


Dan W.

Event Wax (http://www.eventwax.com)

Sorry, the above example should be:

location ~* .(gif|jpg|png|swf|flv)$ {
valid_referers none blocked mydomain.com;

if ($invalid_referer) {
return 403;


Maybe post this to the nginx list?