Hi
I am not really a programmer or web expert. I am writing as my ISP has hit a brick wall with the implementation of some anti-hotlinking code.
I run a shared hosting plan on a web service using Nginx.
There is no decent anti-hotlinking service for Wordpress to stop people linking to my images. I asked the techs at the ISP to look into it, as teh htaccess code didn't work either.
They wrote some code:
location /wp-content/uploads/ {
location ~* \.(jpe?g|jpg|png|gif|ico|svg|swf)$ {
valid_referers mywebsite *. mywebsite facebook.com twitter.com pinterest.com printful.com *.facebook.com *.twitter.com *.pinterest.com *.printful.com *.google.com *.googleusercontent.com *.bing.com pinimg.com *.pinimg.com;
if ($invalid_referer) {
rewrite (.*) /mail/blocked-hotlinking.png redirect;
}
}
}
location = /mail/blocked-hotlinking.png { }
It works in the fact it places the image up to show the site has hot linked images, but it also does it on teh valid refers like Facebook, Pinterest, etc. I did some research and found these other examples, but the techs said they used these as well, and nothing:
———————————————————————-
location ~* \.(gif|jpg|jpeg|png)$ {
valid_referers server_names ~\.google\. ~\.yahoo\. ~\.bing\. ~\.facebook\. ~\.fbcdn\. ~\.ask\. ~\.wp\.;
if ($invalid_referer) {
return 403;
}
}
———————————————————————-
location ~ \.(jpg|jpeg|png|gif|swf)$ {
valid_referers server_names blocked *.mysite.com;
if ($invalid_referer) {
rewrite ^(.*)$ /mail/blocked-hotlinking.png break;
}
}
location =/mail/blocked-hotlinking.png {
root /path/to/my/site;
}
———————————————————————-
location /wp-content/uploads/ {
location ~* \.(jpe?g|png|gif|pdf|xls?x|doc?x|zip|jpg|jpeg|ico)$ {
valid_referers none blocked server_names;
if ($invalid_referer) {
return 403;
}
}
}
_______________________________________
Can anyone tell me why or what could be stopping the valid refers from working, so I can get this code up and running?
Thanks in advance
Rob
I am not really a programmer or web expert. I am writing as my ISP has hit a brick wall with the implementation of some anti-hotlinking code.
I run a shared hosting plan on a web service using Nginx.
There is no decent anti-hotlinking service for Wordpress to stop people linking to my images. I asked the techs at the ISP to look into it, as teh htaccess code didn't work either.
They wrote some code:
location /wp-content/uploads/ {
location ~* \.(jpe?g|jpg|png|gif|ico|svg|swf)$ {
valid_referers mywebsite *. mywebsite facebook.com twitter.com pinterest.com printful.com *.facebook.com *.twitter.com *.pinterest.com *.printful.com *.google.com *.googleusercontent.com *.bing.com pinimg.com *.pinimg.com;
if ($invalid_referer) {
rewrite (.*) /mail/blocked-hotlinking.png redirect;
}
}
}
location = /mail/blocked-hotlinking.png { }
It works in the fact it places the image up to show the site has hot linked images, but it also does it on teh valid refers like Facebook, Pinterest, etc. I did some research and found these other examples, but the techs said they used these as well, and nothing:
———————————————————————-
location ~* \.(gif|jpg|jpeg|png)$ {
valid_referers server_names ~\.google\. ~\.yahoo\. ~\.bing\. ~\.facebook\. ~\.fbcdn\. ~\.ask\. ~\.wp\.;
if ($invalid_referer) {
return 403;
}
}
———————————————————————-
location ~ \.(jpg|jpeg|png|gif|swf)$ {
valid_referers server_names blocked *.mysite.com;
if ($invalid_referer) {
rewrite ^(.*)$ /mail/blocked-hotlinking.png break;
}
}
location =/mail/blocked-hotlinking.png {
root /path/to/my/site;
}
———————————————————————-
location /wp-content/uploads/ {
location ~* \.(jpe?g|png|gif|pdf|xls?x|doc?x|zip|jpg|jpeg|ico)$ {
valid_referers none blocked server_names;
if ($invalid_referer) {
return 403;
}
}
}
_______________________________________
Can anyone tell me why or what could be stopping the valid refers from working, so I can get this code up and running?
Thanks in advance
Rob