| by Scott Kilroy | No comments

Stop image hotlinking on NGINX

If you think it's possible that someone is linking to images hosted on your site add the following to you nginx config file

# Stop deep linking or hot linking 

location /images/ {   valid_referers none blocked www.linuxconsultant.org linuxconsultant.org;    
    if ($invalid_referer) {      
        return   403;    
    } 
} 


Or if you want to be a wiseguy and replace the hotlinked image with something else

# Stop deep linking or hot linking 
location /images/ {   
    valid_referers none blocked www.linuxconsultant.org linuxconsultant.org;    
    if ($invalid_referer) {      
        return 301 https://www.linuxconsultant.org/images/stopstealing.jpg;    
    } 
} 

Share Button