Welcome! Log In Create A New Profile

Advanced

Re: Hotlink protection before proxy when using proxy_pass?

Reinis Rozitis
May 25, 2012 12:28PM
> The anti-hotlink stanza IS having an effect, just not the one I want.
> What do I need to correct?

It is because the regular expression locations are matched first ( http://wiki.nginx.org/HttpCoreModule#location ).

As in:

location ~* \.(png|gif|jpg|jpeg|swf|ico)(\?[0-9]+)?$ {
is processed first and since nginx doesn't merge/apply directives from multiple (matching) location blocks the proxy_pass defined in
'location /' is not effective.


So you either have to duplicate the proxy_* block:

location ~* \.(png|gif|jpg|jpeg|swf|ico)(\?[0-9]+)?$ {
valid_referers none blocked dev.local.lan *.dev.local.lan;

if ($invalid_referer) {
return 403;
}
proxy_pass http://PROXY;
proxy_redirect off;
.....
}


or use nested locations (I think it should work):


location / {
proxy_pass http://PROXY;
proxy_redirect off;
.....

location ~* \.(png|gif|jpg|jpeg|swf|ico)(\?[0-9]+)?$ {
valid_referers none blocked dev.local.lan *.dev.local.lan;
if ($invalid_referer) {
return 403;
}
}



rr

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Hotlink protection before proxy when using proxy_pass?

Anonymous User May 25, 2012 12:08PM

Re: Hotlink protection before proxy when using proxy_pass?

Reinis Rozitis May 25, 2012 12:28PM

Re: Hotlink protection before proxy when using proxy_pass?

Anonymous User May 25, 2012 02:52PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 60
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready