You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modproxy-dev@apache.org by Chuck Murcko <ch...@topsail.org> on 2001/03/02 09:30:40 UTC

Fwd: [PATCH] 1.3: fix PR 3489, NoProxy/mod_rewrite problem

Any thoughts on this patch? It looks OK to me, but I'd like another pair or two of eyes to see it.

Didn't get much feedback on new-httpd. Like zero.

Cuck

Begin forwarded message:

> From: Alan Post <ap...@interwoven.com> 
> Date: Thu Feb 08, 2001  04:10:59 AM US/Eastern 
> To: new-httpd@apache.org 
> Subject: [PATCH] 1.3: fix PR 3489, NoProxy/mod_rewrite problem 
> Delivered-To: topsail.org%chuck@topsail.org 
> Delivered-To: mailing list new-httpd@apache.org 
> Delivered-To: moderator for new-httpd@apache.org 
> X-Received: 8 Feb 2001 09:33:50 GMT 
> Mailing-List: contact new-httpd-help@apache.org; run by ezmlm 
> List-Help: <ma...@apache.org> 
> List-Unsubscribe: <ma...@apache.org> 
> List-Post: <ma...@apache.org> 
> Content-Disposition: inline 
> User-Agent: Mutt/1.2i 
> X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N 
> X-Uidl: OoJn-tHkID1AUAE 
>  
>  
>  
> This patch is filed as a change request, PR #7143.  I am running into this 
> problem, and would appreciate one of the mod_proxy developers taking a look at 
> the patch. 
>  
> Thanks for the great software. 
>  
>     Alan Post 
>  
> >Class:          change-request 
> >Arrival-Date:   Sun Jan 28 10:30:01 PST 2001 
> >Originator:     apost@interwoven.com 
> >Release:        apache-1.3_20010127111201 
>  
> >Environment: 
> uname -a: SunOS oiler 5.6 Generic_105181-07 sun4u sparc 
> SUNW,UltraSPARC-IIi-Engine 
>  
> gcc 2.8.1 
>  
> >Description: 
> NoProxy doesn't work properly with RewriteRule [P].  This is filed as PR 3489. 
>  
> I believe there are two problems with NoProxy and mod_rewrite: 
>  
> 1.  NoProxy looks at r->hostname, which is set from the original request, and 
>     may not be correct after the RewriteRule.  I propose fixing this by 
>     invalidating r->hostname on RewriteRule [P], and on ProxyPass (for the 
>     same reason). 
> 2.  If r->hostname is NULL, NoProxy looks at r->uri to extract the hostname 
>     of the destination of the request.  However, r->filename is what is 
>     actually used to make the proxy request, and r->filename is what 
>     RewriteRule [P] sets.  I propose changing the NoProxy logic to use 
>     r->filename instead of r->uri. 
>  
> >How-To-Repeat: 
> I used a setup very similar to the one in PR 3489. 
>  
> >Fix: 
> Here are diff -C3 outputs: 
>  
>  
>  
> *** mod_proxy.c.orig    Sun Jan 28 08:35:10 2001 
> --- mod_proxy.c Sun Jan 28 09:27:05 2001 
> *************** 
> *** 195,206 **** 
>       for (i = 0; i < conf->aliases->nelts; i++) { 
>           len = alias_match(r->uri, ent[i].fake); 
>              
> !        if (len > 0) { 
> !            r->filename = ap_pstrcat(r->pool, "proxy:", ent[i].real, 
> !                                  r->uri + len, NULL); 
> !            r->handler = "proxy-server"; 
> !            r->proxyreq = PROXY_PASS; 
> !            return OK; 
>         } 
>       } 
>       return DECLINED; 
> --- 195,207 ---- 
>       for (i = 0; i < conf->aliases->nelts; i++) { 
>           len = alias_match(r->uri, ent[i].fake); 
>              
> !         if (len > 0) { 
> !             r->filename = ap_pstrcat(r->pool, "proxy:", ent[i].real, 
> !                                      r->uri + len, NULL); 
> !             r->handler = "proxy-server"; 
> !             r->proxyreq = PROXY_PASS; 
> !             r->hostname = NULL; 
> !             return OK; 
>         } 
>       } 
>       return DECLINED; 
> *** proxy_util.c.orig   Sun Jan 28 08:35:26 2001 
> --- proxy_util.c        Sun Jan 28 08:40:56 2001 
> *************** 
> *** 906,915 **** 
>       if (r->hostname != NULL) 
>         return r->hostname; 
>    
> !     /* Set url to the first char after "scheme://" */ 
> !     if ((url = strchr(r->uri, ':')) == NULL 
> !       || url[1] != '/' || url[2] != '/') 
> !       return NULL; 
>    
>       url = ap_pstrdup(r->pool, &url[1]);       /* make it point to "//", which is what 
> proxy_canon_netloc expects */ 
>    
> --- 906,916 ---- 
>       if (r->hostname != NULL) 
>         return r->hostname; 
>    
> !     /* Set url to the first char after "proxy:scheme://" */ 
> !     if ((url = strchr(r->filename, ':')) == NULL 
> !         || (url = strchr(&url[1], ':')) == NULL 
> !         || url[1] != '/' || url[2] != '/')  
> !         return NULL;  
>    
>       url = ap_pstrdup(r->pool, &url[1]);       /* make it point to "//", which is what 
> proxy_canon_netloc expects */ 
>    
> *** mod_rewrite.c.orig  Sun Jan 28 08:35:39 2001 
> --- mod_rewrite.c       Sun Jan 28 08:38:11 2001 
> *************** 
> *** 1963,1969 **** 
>        *  URL-to-filename handler to be sure mod_proxy is triggered 
>        *  for this URL later in the Apache API. But make sure it is 
>        *  a fully-qualified URL. (If not it is qualified with 
> !      *  ourself). 
>        */ 
>       if (p->flags & RULEFLAG_PROXY) { 
>           fully_qualify_uri(r); 
> --- 1963,1970 ---- 
>        *  URL-to-filename handler to be sure mod_proxy is triggered 
>        *  for this URL later in the Apache API. But make sure it is 
>        *  a fully-qualified URL. (If not it is qualified with 
> !      *  ourself). Invalidate the hostname field of the request, 
> !      *  since we may be heading to a different host. 
>        */ 
>       if (p->flags & RULEFLAG_PROXY) { 
>           fully_qualify_uri(r); 
> *************** 
> *** 1975,1980 **** 
> --- 1976,1982 ---- 
>                          perdir, r->filename); 
>           } 
>           r->filename = ap_pstrcat(r->pool, "proxy:", r->filename, NULL); 
> +         r->hostname = NULL; 
>           return 1; 
>       } 
>    
>  
>  
> ----- End forwarded message ----- 
>  
>  

Chuck Murcko
Topsail Group
http://www.topsail.org/