You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by gregory duchesnes <gr...@icilalune.com> on 2005/11/02 12:38:52 UTC

[users@httpd] SetEnvIf only if 2 regex match?

Hi all,

for testing purpose i would need ti allow access to a server only if the 
client confroms to 2 tests. I RTFMed, but can't find a solution.

let's say i want to allow my client only if it comes from a specific IP 
and with a specific browser.

I've tried this (and many variants) without success:

SetEnvIf Remote_Addr ^192\.168\.0\.2$ welcome
BrowserMatch !"^Mozilla" !welcome
Order Allow,Deny
Allow from env=welcome


There must be an easier but though apache doc says that a test can be 
made on a earlier SetEnvIf result, i can't figure how it work, that's 
why i tried the above method.


Thanks for your help

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] SetEnvIf only if 2 regex match?

Posted by gregory duchesnes <gr...@icilalune.com>.
that's exactly it, thanks a lot Joshua

Joshua Slive a écrit :

>On 11/2/05, gregory duchesnes <gr...@icilalune.com> wrote:
>  
>
>>thanks for your help but this is the exact opposite of what i wan't to do.
>>
>>Here you accept anyone from 192.168.0.2 except Mozilla.
>>I wan't to allow only Mozilla from this IP, and the problem is quite
>>different, since i need to deny everyone except mozilla...
>>    
>>
>
>Then you need something like
>
>SetEnvIf Remote_Addr ^192\.168\.0\.2$ welcome moz=0
>SetEnvIf User-Agent "^Mozilla" moz=1
>SetEnvIf moz 0 !welcome
>Order Allow,Deny
>Allow from env=welcome
>
>Joshua.
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org
>
>
>  
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] SetEnvIf only if 2 regex match?

Posted by Joshua Slive <js...@gmail.com>.
On 11/2/05, gregory duchesnes <gr...@icilalune.com> wrote:
> thanks for your help but this is the exact opposite of what i wan't to do.
>
> Here you accept anyone from 192.168.0.2 except Mozilla.
> I wan't to allow only Mozilla from this IP, and the problem is quite
> different, since i need to deny everyone except mozilla...

Then you need something like

SetEnvIf Remote_Addr ^192\.168\.0\.2$ welcome moz=0
SetEnvIf User-Agent "^Mozilla" moz=1
SetEnvIf moz 0 !welcome
Order Allow,Deny
Allow from env=welcome

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] SetEnvIf only if 2 regex match?

Posted by gregory duchesnes <gr...@icilalune.com>.
thanks for your help but this is the exact opposite of what i wan't to do.

Here you accept anyone from 192.168.0.2 except Mozilla.
I wan't to allow only Mozilla from this IP, and the problem is quite 
different, since i need to deny everyone except mozilla...

Joshua Slive a écrit :

>On 11/2/05, gregory duchesnes <gr...@icilalune.com> wrote:
>  
>
>>SetEnvIf Remote_Addr ^192\.168\.0\.2$ welcome
>>BrowserMatch !"^Mozilla" !welcome
>>    
>>
>
>You can't negate a regex in that way.
>
>Try this instead:
>SetEnvIf Remote_Addr ^192\.168\.0\.2$ welcome
>SetEnvIf User-Agent "^Mozilla" badbrowser=1
>SetEnvIf badbrowser 1 !welcome
>
>  
>
>>Order Allow,Deny
>>Allow from env=welcome
>>    
>>
>
>Joshua.
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org
>
>
>  
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] SetEnvIf only if 2 regex match?

Posted by Joshua Slive <js...@gmail.com>.
On 11/2/05, gregory duchesnes <gr...@icilalune.com> wrote:
> SetEnvIf Remote_Addr ^192\.168\.0\.2$ welcome
> BrowserMatch !"^Mozilla" !welcome

You can't negate a regex in that way.

Try this instead:
SetEnvIf Remote_Addr ^192\.168\.0\.2$ welcome
SetEnvIf User-Agent "^Mozilla" badbrowser=1
SetEnvIf badbrowser 1 !welcome

> Order Allow,Deny
> Allow from env=welcome

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org