You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Marco Pizzoli <ma...@gmail.com> on 2014/11/02 15:57:03 UTC

[users@httpd] How to define string list for comparison?

Hi list,
I'm using Apche 2.4.9 and I am trying to define a configuration by
leveraging the <if> constructor.

In short I would like to trigger some configuration if the client IP
matches one of a list I put up.
I think the "in" operator is what I need, but I'm just failing in
understanding how could I implement a string list.

<If "%{REMOTE_ADDR} in my_string_list">

How can I define the string list? It's just a matter of understanding the
syntax.
On this page it is referred just a "string list" but I cannot find how to
explicit that string list.
http://httpd.apache.org/docs/2.4/expr.html#other

I just need something like "1.1.1.1 2.2.2.2 3.3.3.3" and so on...
Any help?

Thanks in advance
Marco

Re: [users@httpd] How to define string list for comparison?

Posted by Marco Pizzoli <ma...@gmail.com>.
On Sun, Nov 2, 2014 at 9:55 PM, Eric Covener <co...@gmail.com> wrote:

>
> On Sun, Nov 2, 2014 at 10:22 AM, Marco Pizzoli <ma...@gmail.com>
> wrote:
>
>> Honestly I had alreaded tried that way, which I think it is the supposed
>> right way to achieve that but I can't make it working.
>
>
> ​This works:
>
> <If "%{HTTP:X-Foo} -in {'foo', 'bar'}">
>

Thanks a lot Eric, previously I didn't use the single quote surrounding
each word.

Marco

> ​
>
>
>
> --
> Eric Covener
> covener@gmail.com
>

Re: [users@httpd] How to define string list for comparison?

Posted by Eric Covener <co...@gmail.com>.
On Sun, Nov 2, 2014 at 10:22 AM, Marco Pizzoli <ma...@gmail.com>
wrote:

> Honestly I had alreaded tried that way, which I think it is the supposed
> right way to achieve that but I can't make it working.


​This works:

<If "%{HTTP:X-Foo} -in {'foo', 'bar'}">
​



-- 
Eric Covener
covener@gmail.com

Re: [users@httpd] How to define string list for comparison?

Posted by "Rainer M. Canavan" <ra...@sevenval.com>.
On Nov 2, 2014, at 16:22 , Marco Pizzoli <ma...@gmail.com> wrote:

> I mean;
> <If "%{HTTP:X-ClientIP} =~ /(1\.1\.1\.1|2\.2\.2\.2)/">

that looks somewhat dangerous. I haven't checked the Documentation for =~
but I assume that you have to anchor that expression, since you would
allow IPs like 231.1.1.145 otherwise. Something like

<If "%{HTTP:X-ClientIP} =~ /^(1\.1\.1\.1|2\.2\.2\.2)$/">

would be better.



rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] How to define string list for comparison?

Posted by Marco Pizzoli <ma...@gmail.com>.
Hi Eric,
thanks for your answer.

Honestly I had alreaded tried that way, which I think it is the supposed
right way to achieve that but I can't make it working.

If I rewrite the same If-condition by leveraging regexp matching, then it
works.

I mean;
<If "%{HTTP:X-ClientIP} =~ /(1\.1\.1\.1|2\.2\.2\.2)/">

Actually I'm leveragin a custom header sporting the IP address against
which I need the match.

Thanks again
Marco

On Sun, Nov 2, 2014 at 4:05 PM, Eric Covener <co...@gmail.com> wrote:

> Also your tested example would help for the manual
>
> On Sun, Nov 2, 2014 at 10:04 AM, Eric Covener <co...@gmail.com> wrote:
>
>>
>>
>> On Sun, Nov 2, 2014 at 9:57 AM, Marco Pizzoli <ma...@gmail.com>
>> wrote:
>>
>>> Hi list,
>>> I'm using Apche 2.4.9 and I am trying to define a configuration by
>>> leveraging the <if> constructor.
>>>
>>> In short I would like to trigger some configuration if the client IP
>>> matches one of a list I put up.
>>> I think the "in" operator is what I need, but I'm just failing in
>>> understanding how could I implement a string list.
>>>
>>> <If "%{REMOTE_ADDR} in my_string_list">
>>>
>>> How can I define the string list? It's just a matter of understanding
>>> the syntax.
>>> On this page it is referred just a "string list" but I cannot find how
>>> to explicit that string list.
>>> http://httpd.apache.org/docs/2.4/expr.html#other
>>>
>>> I just need something like "1.1.1.1 2.2.2.2 3.3.3.3" and so on...
>>> Any help?
>>>
>>> Thanks in advance
>>> Marco
>>>
>>
>>
>> ​It seems like "string list" in that page should be "wordlist". Can you
>> confirm that works?
>>
>> wordlist    ::= word
>>               | wordlist "*,*" word
>>
>> ​
>>
>>
>>
>> --
>> Eric Covener
>> covener@gmail.com
>>
>
>
>
> --
> Eric Covener
> covener@gmail.com
>

Re: [users@httpd] How to define string list for comparison?

Posted by Eric Covener <co...@gmail.com>.
Also your tested example would help for the manual

On Sun, Nov 2, 2014 at 10:04 AM, Eric Covener <co...@gmail.com> wrote:

>
>
> On Sun, Nov 2, 2014 at 9:57 AM, Marco Pizzoli <ma...@gmail.com>
> wrote:
>
>> Hi list,
>> I'm using Apche 2.4.9 and I am trying to define a configuration by
>> leveraging the <if> constructor.
>>
>> In short I would like to trigger some configuration if the client IP
>> matches one of a list I put up.
>> I think the "in" operator is what I need, but I'm just failing in
>> understanding how could I implement a string list.
>>
>> <If "%{REMOTE_ADDR} in my_string_list">
>>
>> How can I define the string list? It's just a matter of understanding the
>> syntax.
>> On this page it is referred just a "string list" but I cannot find how to
>> explicit that string list.
>> http://httpd.apache.org/docs/2.4/expr.html#other
>>
>> I just need something like "1.1.1.1 2.2.2.2 3.3.3.3" and so on...
>> Any help?
>>
>> Thanks in advance
>> Marco
>>
>
>
> ​It seems like "string list" in that page should be "wordlist". Can you
> confirm that works?
>
> wordlist    ::= word
>               | wordlist "*,*" word
>
> ​
>
>
>
> --
> Eric Covener
> covener@gmail.com
>



-- 
Eric Covener
covener@gmail.com

Re: [users@httpd] How to define string list for comparison?

Posted by Eric Covener <co...@gmail.com>.
On Sun, Nov 2, 2014 at 9:57 AM, Marco Pizzoli <ma...@gmail.com>
wrote:

> Hi list,
> I'm using Apche 2.4.9 and I am trying to define a configuration by
> leveraging the <if> constructor.
>
> In short I would like to trigger some configuration if the client IP
> matches one of a list I put up.
> I think the "in" operator is what I need, but I'm just failing in
> understanding how could I implement a string list.
>
> <If "%{REMOTE_ADDR} in my_string_list">
>
> How can I define the string list? It's just a matter of understanding the
> syntax.
> On this page it is referred just a "string list" but I cannot find how to
> explicit that string list.
> http://httpd.apache.org/docs/2.4/expr.html#other
>
> I just need something like "1.1.1.1 2.2.2.2 3.3.3.3" and so on...
> Any help?
>
> Thanks in advance
> Marco
>


​It seems like "string list" in that page should be "wordlist". Can you
confirm that works?

wordlist    ::= word
              | wordlist "*,*" word

​



-- 
Eric Covener
covener@gmail.com