Prevent hotlinking w/ nginx support
Posted: Mon Jun 15, 2015 4:12 pm
Sorry guys, Im a newbie on this kind of customization.
I'm trying to prevent hotlinking with nginx support simply addin this to my conf file. (/home/$user/conf/web/nginx.conf):
location ~ \.(jpe?g|png|gif)$ {
valid_referers none blocked mydomain.com *.mydomain.com;
if ($invalid_referer) {
return 403;
}
}
adding this in here:
server {
listen 104.236.196.70:80;
server_name mydomain.com http://www.mydomain.com;
error_log /var/log/apache2/domains/mydomain.com.error.log error;
location ~ \.(jpe?g|png|gif)$ {
valid_referers none blocked mydomain.com *.mydomain.com;
if ($invalid_referer) {
return 403;
}
}
location / {
proxy_pass http://104.236.196.70:8080;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx$
root /home/vitorsemc/web/mydomain.com/public_html;
access_log /var/log/apache2/domains/mydomain.com.log combined;
access_log /var/log/apache2/domains/mydomain.com.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
Does anyone know what am I doing wrong?
Thanks a bunch.
I'm trying to prevent hotlinking with nginx support simply addin this to my conf file. (/home/$user/conf/web/nginx.conf):
location ~ \.(jpe?g|png|gif)$ {
valid_referers none blocked mydomain.com *.mydomain.com;
if ($invalid_referer) {
return 403;
}
}
adding this in here:
server {
listen 104.236.196.70:80;
server_name mydomain.com http://www.mydomain.com;
error_log /var/log/apache2/domains/mydomain.com.error.log error;
location ~ \.(jpe?g|png|gif)$ {
valid_referers none blocked mydomain.com *.mydomain.com;
if ($invalid_referer) {
return 403;
}
}
location / {
proxy_pass http://104.236.196.70:8080;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx$
root /home/vitorsemc/web/mydomain.com/public_html;
access_log /var/log/apache2/domains/mydomain.com.log combined;
access_log /var/log/apache2/domains/mydomain.com.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
Does anyone know what am I doing wrong?
Thanks a bunch.