Welcome! Log In Create A New Profile

Advanced

Re: Conditional rule

May 12, 2010 02:18PM
On Wed, May 12, 2010 at 07:13:00PM +0200, Vincent MAUGE wrote:

> Sorry for the previous partial email.
>
> Hey,
>
> I need to add conditional rule with more than one test.
> I need something like :
> if ($remote_addr != "aa.bb.cc.dd" && $request_uri !~ ^/XXXXX$)
> {
> rewrite ...
> }
> else{
> proxy_pass ...
> }
>
> I don't find the good nginx syntax to obtain a such behaviour.
> I try :
> if ( ) {
> if () {
> }
> }
> without success
>
> What is the proper way to do such condition ?

nginx does not support such syntax.
However, the proper way is to not use "if"s at all.
nginx should be configured using locations but not if/rewrites.

Instead of backward logic:

if ($request_uri !~ ^/XXXXX$) {
part A
}

you should use clear logic:

location / {
part A
}

location /XXXXXX {
part B
}

What do you want to configure ?


--
Igor Sysoev
http://sysoev.ru/en/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Conditional rule

Vincent MAUGE May 12, 2010 01:12PM

Re: Conditional rule

Vincent MAUGE May 12, 2010 01:16PM

Re: Conditional rule

Igor Sysoev May 12, 2010 02:18PM

Re: Conditional rule

Vincent MAUGE May 12, 2010 04:06PM

Re: Conditional rule

Igor Sysoev May 12, 2010 04:24PM

Re: Conditional rule

Vincent MAUGE May 12, 2010 04:34PM

Re: Conditional rule

Igor Sysoev May 12, 2010 04:44PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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