You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Brian A. Davis" <br...@gmail.com> on 2016/08/25 19:59:06 UTC

[users@httpd] Regex fails to complie

Hello,

I'm trying to reject requests hitting my apache proxy which are NOT going
to *.foo.com, *.foo.com:443 or *.foo.com/blahblahblah. I'm trying to avoid
bogus requests like foo.com.baddomain.com.

The regex I'm using is:

\.foo.com(?:\:\d{2,5}|\/.*)?$

This is working exactly how I want on https://regex101.com/r/tE4pM2/1, but
when I put this into my apache config:

<If "%{REQUEST_URI} =~ /\.foo.com(?:\:\d{2,5}|\/.*)?$/">

I get the following error:

httpd[3704]: AH00526: Syntax error on line 179 of
/etc/httpd/conf/httpd.conf:
httpd[3704]: Cannot parse condition clause: Failed to compile regular
expression

Is apache limited in the regex support that it has?

httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov 19 2015 21:43:13

Thanks,
Brian

Re: [users@httpd] Regex fails to complie

Posted by "Brian A. Davis" <br...@live.com>.
Just to close this out, m#regex# worked perfectly, thanks for the tip.

On Thu, Aug 25, 2016 at 4:27 PM, Eric Covener <co...@gmail.com> wrote:

> On Thu, Aug 25, 2016 at 3:59 PM, Brian A. Davis <br...@gmail.com>
> wrote:
> > <If "%{REQUEST_URI} =~ /\.foo.com(?:\:\d{2,5}|\/.*)?$/">
>
> The limitation is that you cannot use the separator inside the regex,
> even when you escape it.  It's a limitation in the expression engine
> used for If, not the regex library.
>
> You can use m#...# in your case.
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Regex fails to complie

Posted by "Brian A. Davis" <br...@live.com>.
I'm not sure if that will working when using Apache for a forward proxy.

I only want to allow proxied request to *.foo.com. where foo.com is the
domain of the target of the request, not the domain of the apache server.

On Thu, Aug 25, 2016 at 4:48 PM, Daniel <df...@gmail.com> wrote:

> Why not just  use the directive "UseCanonicalName on"?
>
> El 25/8/2016 10:27 p. m., "Eric Covener" <co...@gmail.com> escribió:
>
>> On Thu, Aug 25, 2016 at 3:59 PM, Brian A. Davis <br...@gmail.com>
>> wrote:
>> > <If "%{REQUEST_URI} =~ /\.foo.com(?:\:\d{2,5}|\/.*)?$/">
>>
>> The limitation is that you cannot use the separator inside the regex,
>> even when you escape it.  It's a limitation in the expression engine
>> used for If, not the regex library.
>>
>> You can use m#...# in your case.
>>
>> --
>> Eric Covener
>> covener@gmail.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>

Re: [users@httpd] Regex fails to complie

Posted by "Brian A. Davis" <br...@live.com>.
I will investigate that.

On Thu, Aug 25, 2016 at 4:48 PM, Daniel <df...@gmail.com> wrote:

> Why not just  use the directive "UseCanonicalName on"?
>
> El 25/8/2016 10:27 p. m., "Eric Covener" <co...@gmail.com> escribió:
>
>> On Thu, Aug 25, 2016 at 3:59 PM, Brian A. Davis <br...@gmail.com>
>> wrote:
>> > <If "%{REQUEST_URI} =~ /\.foo.com(?:\:\d{2,5}|\/.*)?$/">
>>
>> The limitation is that you cannot use the separator inside the regex,
>> even when you escape it.  It's a limitation in the expression engine
>> used for If, not the regex library.
>>
>> You can use m#...# in your case.
>>
>> --
>> Eric Covener
>> covener@gmail.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>

Re: [users@httpd] Regex fails to complie

Posted by Daniel <df...@gmail.com>.
Why not just  use the directive "UseCanonicalName on"?

El 25/8/2016 10:27 p. m., "Eric Covener" <co...@gmail.com> escribió:

> On Thu, Aug 25, 2016 at 3:59 PM, Brian A. Davis <br...@gmail.com>
> wrote:
> > <If "%{REQUEST_URI} =~ /\.foo.com(?:\:\d{2,5}|\/.*)?$/">
>
> The limitation is that you cannot use the separator inside the regex,
> even when you escape it.  It's a limitation in the expression engine
> used for If, not the regex library.
>
> You can use m#...# in your case.
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Regex fails to complie

Posted by Eric Covener <co...@gmail.com>.
On Thu, Aug 25, 2016 at 3:59 PM, Brian A. Davis <br...@gmail.com> wrote:
> <If "%{REQUEST_URI} =~ /\.foo.com(?:\:\d{2,5}|\/.*)?$/">

The limitation is that you cannot use the separator inside the regex,
even when you escape it.  It's a limitation in the expression engine
used for If, not the regex library.

You can use m#...# in your case.

-- 
Eric Covener
covener@gmail.com

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