Forum Moderators: coopster
<if "-R '5.102.173.64/28' ">
SetEnvIfExpr "%{REMOTE_ADDR} =~ /(.+)/" ips=mojeek:$0
BrowserMatch MojeekBot mojeek bot=mojeek
Require env mojeek
</if> SetEnvIf HTTP_REFERER ".well-known/acme-challenge/" letsencrypt bot=letsencryptr
SetEnvIf REQUEST_URI ".well-known/acme-challenge/" letsencrypt bot=letsencryptu
BrowserMatch "letsencrypt.org/" letsencrypt bot=letsencryptb
Require env letsencrypt <if " -R '0.0.0.0/2' ">
SetEnvIf REQUEST_URI ".well-known/acme-challenge/" letsencrypt bot=letsencryptu0
</if>
<if " -R '64.0.0.0/2' ">
SetEnvIf REQUEST_URI ".well-known/acme-challenge/" letsencrypt bot=letsencryptu64
</if>
<if " -R '128.0.0.0/2' ">
SetEnvIf REQUEST_URI ".well-known/acme-challenge/" letsencrypt bot=letsencryptu128
</if>
<if " -R '192.0.0.0/2' ">
SetEnvIf REQUEST_URI ".well-known/acme-challenge/" letsencrypt bot=letsencryptu192
</if>
Require env letsencrypt if(!empty(apache_getenv('bot'))) { $fn="b"; }
else { $fn="h"; } SetEnvIf HTTP_REFERER ".well-known/acme-challenge/" letsencrypt bot=letsencryptr
SetEnvIf REQUEST_URI ".well-known/acme-challenge/" letsencrypt bot=letsencryptu
BrowserMatch "letsencrypt.org/" letsencrypt bot=letsencryptb
SetEnvIfExpr "%{REMOTE_ADDR} =~ /(.+)/" ips=mojeek:$0
SetEnvIf Remote_Addr "(.*)" ips=mojeek:$1
SetEnvIf HTTP_REFERER ".well-known/acme-challenge/" letsencrypt bot=letsencryptr
SetEnvIf REQUEST_URI ".well-known/acme-challenge/" letsencrypt bot=letsencryptu
BrowserMatch "letsencrypt.org/" letsencrypt bot=letsencryptb
Require env letsencrypt
<if " -R '0.0.0.0/2' ">If this directive is meant to cover the whole IPv4 spectrum--and presumably also IPv6, unless you’ve got a particular reason for treating it differently--why do you need the <If> envelopes at all? Do you actually use the various letsencryptblahblah values later on?
...
(Apache complains if I go below /2 so it has to be split up to cover the complete ipv4 range).
BrowserMatch "letsencrypt.org" letsencrypt bot=letsencryptb
SetEnvIf Referer ".well-known/acme-challenge/" letsencrypt bot=letsencryptr
SetEnvIf REQUEST_URI "^\.well-known/acme-challenge/" letsencrypt bot=letsencryptu
Require env letsencrypt
The bot IS being logged to a 403 log: the actual path does not exist during this bot's visit.
> what determines whether this code should be executed
It's always executed.
Moving BrowserMatch to the second line shows that the browser now triggers. Adding the anchor as suggested above has prevented the URI value from triggering.
SetEnvIf REQUEST_URI "^\.well-known/acme-challenge/" letsencrypt bot=letsencryptu
SetEnvIf Request_URI "^/\.well-known/acme-challenge/" letsencrypt bot=letsencryptu BrowserMatch teststring bad_agent=$0
the value will be set to the literal string $0, instead of the desired “teststring” ... unless “teststring” contains literal quotation marks. (Or certain other characters, which may have changed from one 2.4 version* to the next, because I had different results the last time I looked into this. Anchors and grouping brackets still work; periods--whether escaped or not--no longer do.) $0 only returns the hit part of a regex but generally nothing (or the literal) for a plain text.Yes, that's what changed (on my specific server) in August. Before then, any . (period) was also interpreted as a potential RegEx, so $0 returned the matched string.