Linode Forum Index Linode Forum
Linode Community Forums
 


Hotlink Protection in Nginx working too well in Firefox

Click here to go to the original topic

 
       Linode Forum Index -> Web Servers and Web App Development
Author Message
adergaard



Joined: 20 Oct 2009
Posts: 18

Posted: Sat Jan 21, 2012 8:30 am    Post subject: Hotlink Protection in Nginx working too well in Firefox  

I use hotlink protection in Nginx and it is working very well!

For some reason - and the reason for this question - it is not allowing visitors to my site using firefox to see any images, which they should. For IE, Chrome, Safari, and Opera, it works just fine. Images show up on my site but not if you try to hotlink.

I checked Firefox on Win and on Mac and it happens in both places. Headers send the same referres (as far as I can see) as does IE and the others.

The hotlink protection code looks like so

Code: location ~ \.(jpg|jpeg|png|gif|swf)$ {
    valid_referers server_names blocked *.mysite.com;
    if ($invalid_referer) {
        rewrite ^(.*)$ /nopeeking.png break;
    }
}

location =/nopeeking.png {
    root /path/to/my/site;
}   

As I said, this is working very well! Anyone trying to hotlink gets the nopeeking.png image in their face. Fine.

If it wasn't for Firefox.

Any ideas as to why this works in all browsers but not in FF which treats it like it is trying to peek?
Back to top  
obs



Joined: 07 Mar 2010
Posts: 1403
Location: Earth

Posted: Sat Jan 21, 2012 10:43 am    Post subject:  

I had an issue similar to this, for some reason some firefox browsers do not send a referrer header, add "none" to your valid_referers
Back to top  
adergaard



Joined: 20 Oct 2009
Posts: 18

Posted: Sat Jan 21, 2012 2:40 pm    Post subject:  

I'll try that as soon as the traffic is a bit easier than now.
I don't know a good way to refresh this setting in Nginx other than restarting it and I don't really want to do that now.

But thanks much. Your answer makes sense and it's probably what's gone wrong here. Thanks.
Back to top  
obs



Joined: 07 Mar 2010
Posts: 1403
Location: Earth

Posted: Sat Jan 21, 2012 2:50 pm    Post subject:  

run Code: service nginx reload that will reload the nginx configuration without restarting the server.
Back to top  
adergaard



Joined: 20 Oct 2009
Posts: 18

Posted: Sun Jan 22, 2012 10:18 am    Post subject:  

Superb!
Works very well.

Thanks for the tip on how to reload the nginx config, I guess I could've (or rather should have) found it on the nginx wiki.

Thanks just the same.
Back to top  
 
       Linode Forum Index -> Web Servers and Web App Development
Page 1 of 1