Hi,
I have seen that this topic has been discussed on the lists earlier, but
I did not see that anyone found a good solution for it. As far as I
know, nginx does not support if-else or nested if blocks in the
configuration. Any plans on adding support for this?
Anyway, our problem is that we need to match both $request_method and
$remote_addr before doing a rewrite. Have any of you run into the same
problem and found a solution for it?
On Oct 1, 2008, at 3:34 AM, Pål-Kristian Hamre wrote:
Anyway, our problem is that we need to match both $request_method and
$remote_addr before doing a rewrite. Have any of you run into the same
problem and found a solution for it?
We have to do this in a couple places and the solution I came up with
isn’t pretty,
but it works.
Here comes the ugly:
set $conditionA 0;
set $conditionB 0;
if ( $request_method … )
{
set $conditionA 1;
}
if ( $remote_addr … )
{
set $conditionB 1;
}
set $dual_test “$conditionA:$conditionB”
if ( $dual_test = ‘1:1’ )
{
# both conditions match
}