Bug 33170

Summary: ProxyRemoteMatch uses remote proxy if regex does *not* match
Product: Apache httpd-2 Reporter: Rici Lake <rici>
Component: mod_proxyAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED FIXED    
Severity: normal Keywords: PatchAvailable
Priority: P2    
Version: 2.0.52   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Rici Lake 2005-01-19 22:57:56 UTC
The ProxyRemoteMatch directive is supposed to use a regex to redirect certain proxy requests to a 
remote proxy server (as I understand the documentation). I actually needed that for a configuration (see 
below) and was puzzled to find that it doesn't work: (line numbers from APACHE_2_0_BRANCH, because 
I can't find a web interface to svn.)

389 :  p2 = ap_strchr_c(ents[i].scheme, ':');  /* is it a partial URL? */
390 :  if (strcmp(ents[i].scheme, "*") == 0 ||
391 :      (ents[i].use_regex && ap_regexec(ents[i].regexp, url, 0,NULL, 0)) ||
392 :      (p2 == NULL && strcasecmp(scheme, ents[i].scheme) == 0) ||
393 :      (p2 != NULL &&
394 :       strncasecmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) {

ap_regexec returns 0 on success, so the condition in line 391 matches if the regex didn't match, which 
is the reverse of the expected behaviour. Changing line 391 to

391 :      (ents[i].use_regex && ap_regexec(ents[i].regexp, url, 0,NULL, 0) == 0) ||

produced the expected behaviour.

This code seems to have been unchanged since the directive was introduced in 2.0.35, almost three 
years ago, and I cannot find any relevant bug reports; in fact, googling for ProxyRemoteMatch did not 
yield any indication that anyone has ever tried to use the directive, much less succeeded. This would 
seem to be a reasonable case for deleting the directive
Comment 1 Justin Erenkrantz 2005-02-04 00:19:22 UTC
Applied in r151248.  Thanks!