httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Covener <cove...@gmail.com>
Subject Re: [users@httpd] SERVER_ADDR "does not exist"
Date Tue, 18 Feb 2014 15:19:33 GMT
Kind of makes sense -- the CGI-related environment variables are set
very late in processing -- so maybe reqenv() is not so useful for
these because it runs relatively early.

I think what you actually need is an enhancement to the expression
parser to make "SERVER_ADDR" available. Can you open an
enhancement-type bug report?

On Tue, Feb 18, 2014 at 10:15 AM, Adrian Lester <al1@ajltech.co.uk> wrote:
> Thanks for that Eric, the similarity of the expression parser's variables
> to the environment variables had caused me to see straight past the fact
> that they are two separate things - my bad.
>
> Unfortunately, I seem now to be banging my head against another brick wall...
>
> I have changed my syntax to:
>     <If "reqenv('SERVER_ADDR') =
> and have also tried with env in place of reqenv, but it seems to be
> behaving as if the environment variables are either not recognised (I get
> the same results with a non-existent one) or empty, in that:
>    <If "reqenv('SERVER_ADDR') =~ /.*/">
>        gives me the desired result, so the If statement works, but
>    <If "reqenv('SERVER_ADDR') =~ /.+/">
>        acts according to the following <Else> statement.
>
> The reqenv function is OK, because if I change reqenv to something
> non-existent, Apache complains on restart.
>
> I was concerned about processing order, so for debugging purposes I tried
> exactly the same lines with REMOTE_ADDR, given that also exists as a
> native variable of the expression parser and (as before) I can confirm
> that all works as expected with %{REMOTE_ADDR} so Apache must "know" the
> value. I got the same result as with SERVER_ADDR, though, so when I try to
> access it as an environment variable, something is clearly going wrong.
>
> I have tried applying single and double quotes in various permutations,
> but as laid out above seems to be the only one which is acceptable.
>
> I'm probably missing something blindingly obvious again, but if so is
> there any chance of another nudge in the right direction?
>
> Thanks again,
>
> Adrian
>
>
>
>
>
>> On Tue, Feb 18, 2014 at 5:55 AM, Adrian Lester <al1@ajltech.co.uk> wrote:
>>> Please accept my apologies for popping up on the list with an immediate
>>> question, and even more so if it turns out that I am being stupid, but
>>> this one really does have me confused. I have read the manuals and
>>> searched and searched, but can't seem to find any reference to anyone
>>> else
>>> having the same problem, or any related bug reports.
>>>
>>> I am using Apache 2.4.7 (full details below).
>>>
>>> The machine has two network interfaces with separate IP addresses, and I
>>> want to use a conditional statement in the conf file of the default
>>> virtual host to handle traffic coming in via the two IP's differently
>>> using SERVER_ADDR to identify them. What I expected to be the
>>> complicated
>>> bit all works fine, but this construct:
>>>      <If "%{SERVER_ADDR} == '<ip address of 2nd interface>'">
>>>            .......
>>>      </If>
>>>      <Else>
>>>            .......
>>>      </Else>
>>> results in this:
>>>
>>> root@mymachine:apache2# ./bin/apachectl restart
>>> AH00526: Syntax error on line 118 of
>>> /usr/local/apache2/conf/extra/configfile.conf:
>>> Cannot parse condition clause: Variable 'SERVER_ADDR' does not exist
>>> root@mymachine:apache2#
>>
>> That syntax is not for environment variables.  See the real variables
>> and the "reqenv" function:
>>
>> http://httpd.apache.org/docs/2.4/expr.html
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>



-- 
Eric Covener
covener@gmail.com

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


Mime
View raw message