Welcome! Log In Create A New Profile

Advanced

Re: Question on Rewrite / If statements

Resicow
September 18, 2009 11:38AM
Hi Igor,

Thanks for your response.

We have lots of virtual hosting domains setup, using $host to point to
the correct root directory. This way we can add / subtract domains
without touching the nginx config.

Similar to the "Wildcard Subdomains in a Parent Folder" at
http://wiki.nginx.org/NginxVirtualHostExample

This has been working perfectly for us, however we want to stop leeching
by checking the HTTP Referer.

Since the configuration is "virtual", only the $host variable actually
"knows" the name of the vhost.

So we want to test to ensure that either $http_referer contains $host
(using an if statement), or using the HTTP Referer module with something
like this:

valid_referers none blocked $host;

Can you think of anyway to have nginx test two variables in this
fashion? Because of our setup, it is not possible to manually enter
these values in the config file, or manually setup a vhost for each domain.

Thanks,

John





Igor Sysoev wrote:
> On Wed, Sep 16, 2009 at 08:03:26PM -0500, Resicow wrote:
>
>
>> Hello,
>>
>> I have learned that the http_referer module does *not* support variables.
>>
>> I am trying to work around this with if / rewrite statements, but may
>> have run into the same issue.
>>
>> How can I make this work?
>>
>> set $myvar mydomain.com;
>> if ($http_referer ~* $myvar) {
>> do something
>> }
>>
>> When I run that, it always returns false. However this works:
>>
>> if ($http_referer ~* mydomain.com) {
>> do something
>> }
>>
>> It appears that the if statement doesn't evaluate the variable. Is there
>> anyway around this?
>>
>
> Yes, "if" is ugly hack and it does not evaluate a right part of expression.
>
> What task do you want to resolve using $http_referer ?
>
>
>
Subject Author Posted

Question on Rewrite / If statements

Resicow September 16, 2009 09:12PM

Re: Question on Rewrite / If statements

Igor Sysoev September 18, 2009 07:38AM

Re: Question on Rewrite / If statements

Resicow September 18, 2009 11:38AM

Re: Question on Rewrite / If statements

Maxim Dounin September 18, 2009 11:50AM

Re: Question on Rewrite / If statements

Resicow September 18, 2009 01:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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