HTTP Referer Module Support Variables? And pcre question...
Maxim Dounin
mdounin at mdounin.ru
Fri Aug 7 02:25:15 MSD 2009
Hello!
On Mon, Aug 03, 2009 at 01:45:58PM -0500, Resicow wrote:
> Hello All,
>
> Is it safe to use variables with the http_referer module?
>
> I'd like to specify the valid_referers via set variables, instead of
> hard-coding them into the configuration.
>
> So something like:
> valid_referers
> <http://wiki.nginx.org/NginxHttpRefererModule#valid_referers> none
> blocked $domain1 $domain2;
No, valid_referers does not support variables.
Directives that support variables contain something like "you may
use variables" in their documentation.
> Also, is it possible to somehow get the top level folder using rewrite
> and pcre?
>
> So for example, if the URI is this:
> /folder1/folder2/lots_of_other_folders/file.txt
>
> How would it be possible to set a variable equal to "folder1"? Everytime
> I try, it never quite works.
You may either use captures in location directive:
location ^/([^/]+) {
set $folder $1;
...
}
or if:
set $folder "";
if ($uri ~ "^/([^/]+)") {
set $folder $1;
}
Note that if's are generally evil, search mailing list archives for
details.
Maxim Dounin
More information about the nginx
mailing list