Aug 182010
how to prevent image hotlinking with nginx?
this will return 403 error when someone trying to use image directly from oursite.
location ~* (\.jpg|\.png|\.gif|\.jpeg|\.png)$ {
valid_referers none blocked www.example.com example.com;
if ($invalid_referer) {
return 403;
}
}
or we can change every images which hotlinked with our custom banner.
valid_referers none blocked www.example.com example.com;
if ($invalid_referer) {
rewrite ^/images/(.*)\.(gif|jpg|jpeg|png)$ http://www.example.com/banner.jpg last
}
You may also want to read these posts:
- Nginx Memcached Module, Caching Webiste Image Using Memcached
- Create GeoIP Badge Using PHP Image Processing And GD
- Nginx + Vlc Streaming Cheap Webcam
- Nginx Blocking Spoofed Google Bot
- How To Graph Nginx Statistics
- Nginx Memcached module And PHP
- Nginx, Strip All Newlines Using nginx-nonewlines Module
- nginx mod_strip module and textarea
- Nginx Limit Available Methods
- Nginx Configuration SyntaxHighlighting
Follow me on Twitter