Welcome! Log In Create A New Profile

Advanced

Problems with hotlink

Posted by vodoley213 
Problems with hotlink
May 16, 2012 07:05AM
While fighting with hotlink there is ONE big problem.

Nginx did not always correctly handle the allowed websites (such as feedburner images.google.com, etc.). Sometimes nginx redirects people to "nohotlinking.png" (see the code below) on the allowed websites and even on main website.

Any ideas?

The code:
location ~ \.(gif|png|jpg|jpeg)$ {
valid_referers none blocked server_names ~\.google\. ~\.bing\. ~\.yahoo\.
images.google.com ~\.feedburner.com;

expires 96h;
if ($invalid_referer) {
rewrite .* http://image-hosting.com/nohotlinking.png redirect;
}
}
Re: Problems with hotlink
August 04, 2012 02:03PM
After looking over the docs (see links below) , I would use wild cards instead of regular expressions if your needs are simple enough:

location ~ \.(gif|png|jpg|jpeg)$ {
valid_referers none blocked server_names *.google.com *.bing.com *.yahoo.com *.feedburner.com;

expires 96h;
if ($invalid_referer) {
rewrite .* http://image-hosting.com/nohotlinking.png redirect;
}
}


Based on what I read I would expect that to work fine.

http://wiki.nginx.org/HttpRefererModule
http://nginx.org/en/docs/http/ngx_http_referer_module.html#valid_referers
http://linuxsysadminblog.com/2009/08/using-wildcards-in-nginx-valid_referers/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 248
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready