1 message in ru.sysoev.nginxPrevent hotlinking (ngx_http_referer_...
FromSent OnAttachments
Igor SysoevDec 3, 2006 12:32 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Prevent hotlinking (ngx_http_referer_module)Actions...
From:Igor Sysoev (is-G@public.gmane.org)
Date:Dec 3, 2006 12:32:27 am
List:ru.sysoev.nginx

The english wiki page about ngx_http_referer_module is half-translated and I'm confused about the syntax. Can anyone help me with blocking hotlinking.

I have a /photos/ folder with .jpeg files and I want only browsers with referer set to domain.tld and www.domain.tld to be able to access them. Pretty basic stuff.

location ~* ^/photos/.+\.jpg$ {

or (better)

location /photos/ { valid_referers none blocked domain.tld www.domain.tld;

if ($invalid_referer) { return 403; } }

The "none" means the absence of "Referer" header. The "blocked" means masked "Referer" header by firewall, for example, "Referer: XXXXXXX".