1

I use nginx and I have no access to server conf.

May be with .htaccess analogue?..

NARKOZ
  • 1,028

5 Answers5

7
location ~* (\.jpg|\.png|\.gif|\.jpeg)$ {
 valid_referers blocked www.domain.com domain.com;
 if ($invalid_referer) {
    return 403;
 }
  root   /srv/www/domain.com/public_html;
}
3

Without access to the server configuration, you cannot change any settings. There is no equivalent to Apache httpd's .htaccess in nginx.

joschi
  • 21,955
2

Just in case you HAVE access to the webserver:

location ~* (\.jpg|\.png|\.gif|\.jpeg|\.png)$ {
 valid_referers none blocked www.example.com example.com;
 if ($invalid_referer) {
    return 403;
 }
}
alfish
  • 3,217
0

joschi is right: nginx is driven by a single configuration file you can't edit. Your only possibility is to use a redirector script which says '403 Access Denied' for hotlinks and '301 Moved Permanently' for normal links.

kolypto
  • 11,588
0

One solution is to generate all your pages & content dynamically, and with different URLs every time, which expire after a while. That makes hotlinking impossible.

If that is not practical, you can also check referrer. If you cannot reconfigure nginx, you'll probably have to do it in a scripting language which generates the pages dynamically.

sleske
  • 10,234