Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Nginx Hotlink Protection Help Needed
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Nginx Hotlink Protection Help Needed

DudeistDudeist Member
edited March 2013 in General

Greetings!

I have a small problem which I recently discovered and need to fix, because it's draining my resources.

Currently I have the following in my server block:

location ~ .(zip|rar)$ {

valid_referers none blocked mysite.com *.mysite.com;
if ($invalid_referer) {
rewrite ^ http://www.mysite.com/ break;
}
}

to prevent hotlinkig my files, and redirect leechers to my homepage instead.

Now I discovered that some rather large and busy site is linking to my files in the following form:

which circumvents
the current protection. Does anyone know how to stop this? I would much prefer to keep the current
homepage redirect, but will consider other solutions.

Thanks

Comments

  • I think the * in *.mysite.com is the problem; maybe you can try to hardcode the subdomains?

  • Oh shoot, it appears everything is working correctly as is. Forgot to clear my cache etc.

    Case solved, thanks.

  • JanevskiJanevski Member
    edited March 2013

    What about something like:
    if ($http_referer !~ (^http://yoursite.com|^http://www.yoursite.com$) {
    return 403 No.;
    }

  • Dammit, it looks like it's only partially working. Chrome and Opera redirect properly, but firefox (and IE, but who cares?) doesn't. In this case I'm still looking for a solution.

    @Bogdacutuu Hardcoding the subdomain doesn't fix it.

Sign In or Register to comment.