How to disable valid_referers?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi guys,

Say if I have many files under / (document root), all of them need
hotlink protection, except one.

I set valid_referers for location / as default, how could I skip the
proection for the specific file?

I guess I can’t simply put “valid_referers none” here according to the
documentation at http://wiki.nginx.org/HttpRefererModule (It says
default: none, but I guess this will confuse people with the value
“none”).

Any help will be greatly appreciated.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.12 (Darwin)

iEYEARECAAYFAkzandwACgkQdcWH549oblh7+ACfRW1N/So+AEZJQGICi5LzVNMr
+SQAn2QnsZhCZSSoy4L6o04z9Ih6rgDj
=2L0L
-----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

…never mind, I can set $invalid_referer to 0 to do this.
Anyway, thanks, and sorry for the ask-n-answer. :stuck_out_tongue:

Hi guys,

Say if I have many files under / (document root), all of them need
hotlink protection, except one.
[…omitted…]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.12 (Darwin)

iEYEARECAAYFAkzan9EACgkQdcWH549oblg88wCgibcBqTLJmivwsD50+nhZwT7r
KGcAnRXAh8B2DyPNDM50E5pEZ+zqwRtH
=/aSO
-----END PGP SIGNATURE-----

On Wed, Nov 10, 2010 at 09:27:58PM +0800, Horus Lee wrote:

I guess I can’t simply put “valid_referers none” here according to the
documentation at http://wiki.nginx.org/HttpRefererModule (It says
default: none, but I guess this will confuse people with the value “none”).

valid_referers …;

root …;

location / {
if ($invalid_referer) {
return 403;
}
}

location = /some.specfic.file {
}

location = /other.specfic.file {
}


Igor S.
http://sysoev.ru/en/

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Igor,

You should not set $invalid_referer to 0.
You should use locations.

Thanks for the help!
I’ve learned a new lesson… :slight_smile:

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.12 (Darwin)

iEYEARECAAYFAkzaoYgACgkQdcWH549obljTmgCgpt6LyAXGiMmsyLJzU0foZ5pu
XN0An2PvWnifA1JQBaj6bDKJHfg+5+xj
=0mBf
-----END PGP SIGNATURE-----

On Wed, Nov 10, 2010 at 09:36:20PM +0800, Horus Lee wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

…never mind, I can set $invalid_referer to 0 to do this.
Anyway, thanks, and sorry for the ask-n-answer. :stuck_out_tongue:

You should not set $invalid_referer to 0.
You should use locations.


Igor S.
http://sysoev.ru/en/

Hello!

On Wed, Nov 10, 2010 at 09:27:58PM +0800, Horus Lee wrote:

Say if I have many files under / (document root), all of them need
hotlink protection, except one.

I set valid_referers for location / as default, how could I skip the
proection for the specific file?

location / {
valid_referers …

}

location = /some-specific-file {
# no valid_referers directive here

}

See here for details:

http://wiki.nginx.org/HttpCoreModule#location

I guess I can’t simply put “valid_referers none” here according to the
documentation at http://wiki.nginx.org/HttpRefererModule (It says
default: none, but I guess this will confuse people with the value “none”).

Yes, that’s translation artifact. Changed to “default: no”, that
should be more clear.

Maxim D.