Welcome! Log In Create A New Profile

Advanced

Re: HTTP Referer Module Support Variables? And pcre question...

All files from this thread

File Name File Size   Posted by Date  
localhost-if_eth0-day.png 23.1 KB open | download Jim Ohlstein 07/30/2009 Read message
Maxim Dounin
August 06, 2009 06:25PM
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
Subject Author Posted

HTTP Referer Module Attachments

Jim Ohlstein July 30, 2009 09:47AM

Re: HTTP Referer Module

Igor Sysoev July 30, 2009 09:54AM

Re: HTTP Referer Module

Jim Ohlstein July 30, 2009 01:34PM

Re: HTTP Referer Module

Igor Sysoev July 30, 2009 01:42PM

HTTP Referer Module Support Variables? And pcre question...

Resicow August 03, 2009 02:45PM

Re: HTTP Referer Module Support Variables? And pcre question...

Maxim Dounin August 06, 2009 06:25PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 145
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