Conditional rule
Vincent MAUGE
vmauge at gmail.com
Thu May 13 00:01:12 MSD 2010
2010/5/12 Igor Sysoev <igor at sysoev.ru>:
> 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 ?
>
My nginx is configure as a reverse proxy (http and https).
I want to allow some ip to access both for example 10.10.10.10.
Others are allow to access only https and get a permanent redirect on
http to https except for specific url where I allow http/https for
exemple directory /documentation.
Whar is the best way ? to configure 2 location ?
Thanks for your answer.
Vincent
More information about the nginx
mailing list