Apache Lounge



Forum Index Downloads Search Register Log in  RSS Apache Lounge

Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.



A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.

Apache 2.4.26 isn't understanding my RegEx match properly

Post new topic   Reply to topic    Apache Forum Index -> Apache

View previous topic :: View next topic  
Author Message

Joined: 07 Feb 2017
Posts: 7
Location: San Diego, CA

PostPosted: Thu 03 Aug '17 19:11    Post subject: Apache 2.4.26 isn't understanding my RegEx match properly Reply with quote

On Linux x64
This is for filtering out specific Remote_Addr connections from my access_log (specifically my F5 load balancer's health check (which is every 5 seconds, and annoying to see in the logs).

My F5's always end in .2 or .3 and are on the 172.[16-19].255.[2-3]
and 10.x.x.[2-3]

SetEnvIf Remote_Addr "(172\.(1[6-9]|2[0-9]|3[0-1])\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.[2-3]$)|10\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.[2-3]$" F5_HEALTH_CHECK

CustomLog "||${APACHE_HOME}/bin/rotatelogs -f ${HTTP_WEBSERVER_HOME}/logs/access_log.%Y%m%d0000 86400 -420" combined env=!F5_HEALTH_CHECK

Testing this on multiple regex testers online, it looks perfect, but maybe it isn't.

Using this regex, and are not being matched (filtered).

It'd be easy to fix (IMHO) if any of the Online Regex Testers would fail matching but they all match it.

Back to top
James Blond

Joined: 19 Jan 2006
Posts: 6352
Location: Germany, Next to Hamburg

PostPosted: Thu 03 Aug '17 19:23    Post subject: Reply with quote

My guess is you need SetEnvIfExpr [1]

See the second example. I think that is what you want. since your regex is a bit complex Very Happy [2]

[1] https://httpd.apache.org/docs/2.4/mod/mod_setenvif.html#setenvifexpr
[2] https://regexper.com/#(172%5C.(1%5B6-9%5D%7C2%5B0-9%5D%7C3%5B0-1%5D)%5C.(1%3F%5B0-9%5D%7B1%2C2%7D%7C2%5B0-4%5D%5B0-9%5D%7C25%5B0-5%5D)%5C.%5B2-3%5D%24)%7C10%5C.(1%3F%5B0-9%5D%7B1%2C2%7D%7C2%5B0-4%5D%5B0-9%5D%7C25%5B0-5%5D)%5C.(1%3F%5B0-9%5D%7B1%2C2%7D%7C2%5B0-4%5D%5B0-9%5D%7C25%5B0-5%5D)%5C.%5B2-3%5D%24
Back to top

Post new topic   Reply to topic    Apache Forum Index -> Apache
Page 1 of 1