You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ni...@apache.org on 2005/08/11 01:36:43 UTC

svn commit: r231355 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy.h mod_proxy_http.c

Author: niq
Date: Wed Aug 10 16:36:39 2005
New Revision: 231355

URL: http://svn.apache.org/viewcvs?rev=231355&view=rev
Log:
Fix ProxyPassReverse & family to work correctly in <Location>

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_http.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=231355&r1=231354&r2=231355&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Wed Aug 10 16:36:39 2005
@@ -788,11 +788,6 @@
     ps->sec_proxy = apr_array_make(p, 10, sizeof(ap_conf_vector_t *));
     ps->proxies = apr_array_make(p, 10, sizeof(struct proxy_remote));
     ps->aliases = apr_array_make(p, 10, sizeof(struct proxy_alias));
-    ps->raliases = apr_array_make(p, 10, sizeof(struct proxy_alias));
-    ps->cookie_paths = apr_array_make(p, 10, sizeof(struct proxy_alias));
-    ps->cookie_domains = apr_array_make(p, 10, sizeof(struct proxy_alias));
-    ps->cookie_path_str = apr_strmatch_precompile(p, "path=", 0);
-    ps->cookie_domain_str = apr_strmatch_precompile(p, "domain=", 0);
     ps->noproxies = apr_array_make(p, 10, sizeof(struct noproxy_entry));
     ps->dirconn = apr_array_make(p, 10, sizeof(struct dirconn_entry));
     ps->allowed_connect_ports = apr_array_make(p, 10, sizeof(int));
@@ -832,13 +827,6 @@
     ps->proxies = apr_array_append(p, base->proxies, overrides->proxies);
     ps->sec_proxy = apr_array_append(p, base->sec_proxy, overrides->sec_proxy);
     ps->aliases = apr_array_append(p, base->aliases, overrides->aliases);
-    ps->raliases = apr_array_append(p, base->raliases, overrides->raliases);
-    ps->cookie_paths
-        = apr_array_append(p, base->cookie_paths, overrides->cookie_paths);
-    ps->cookie_domains
-        = apr_array_append(p, base->cookie_domains, overrides->cookie_domains);
-    ps->cookie_path_str = base->cookie_path_str;
-    ps->cookie_domain_str = base->cookie_domain_str;
     ps->noproxies = apr_array_append(p, base->noproxies, overrides->noproxies);
     ps->dirconn = apr_array_append(p, base->dirconn, overrides->dirconn);
     ps->allowed_connect_ports = apr_array_append(p, base->allowed_connect_ports, overrides->allowed_connect_ports);
@@ -869,6 +857,13 @@
 
     /* Filled in by proxysection, when applicable */
 
+    /* Put these in the dir config so they work inside <Location> */
+    new->raliases = apr_array_make(p, 10, sizeof(struct proxy_alias));
+    new->cookie_paths = apr_array_make(p, 10, sizeof(struct proxy_alias));
+    new->cookie_domains = apr_array_make(p, 10, sizeof(struct proxy_alias));
+    new->cookie_path_str = apr_strmatch_precompile(p, "path=", 0);
+    new->cookie_domain_str = apr_strmatch_precompile(p, "domain=", 0);
+
     return (void *) new;
 }
 
@@ -880,6 +875,15 @@
     new->p = add->p;
     new->p_is_fnmatch = add->p_is_fnmatch;
     new->r = add->r;
+
+    /* Put these in the dir config so they work inside <Location> */
+    new->raliases = apr_array_append(p, base->raliases, overrides->raliases);
+    new->cookie_paths
+        = apr_array_append(p, base->cookie_paths, overrides->cookie_paths);
+    new->cookie_domains
+        = apr_array_append(p, base->cookie_domains, overrides->cookie_domains);
+    new->cookie_path_str = base->cookie_path_str;
+    new->cookie_domain_str = base->cookie_domain_str;
     return new;
 }
 
@@ -1042,14 +1046,11 @@
 }
 
 static const char *
-    add_pass_reverse(cmd_parms *cmd, void *dummy, const char *f, const char *r)
+    add_pass_reverse(cmd_parms *cmd, void *dconf, const char *f, const char *r)
 {
-    server_rec *s = cmd->server;
-    proxy_server_conf *conf;
+    proxy_dir_conf *conf = dconf;
     struct proxy_alias *new;
 
-    conf = (proxy_server_conf *)ap_get_module_config(s->module_config, 
-                                                     &proxy_module);
     if (r!=NULL && cmd->path == NULL ) {
         new = apr_array_push(conf->raliases);
         new->fake = f;
@@ -1068,14 +1069,11 @@
     return NULL;
 }
 static const char*
-    cookie_path(cmd_parms *cmd, void *dummy, const char *f, const char *r)
+    cookie_path(cmd_parms *cmd, void *dconf, const char *f, const char *r)
 {
-    server_rec *s = cmd->server;
-    proxy_server_conf *conf;
+    proxy_dir_conf *conf = dconf;
     struct proxy_alias *new;
 
-    conf = (proxy_server_conf *)ap_get_module_config(s->module_config,
-                                                     &proxy_module);
     new = apr_array_push(conf->cookie_paths);
     new->fake = f;
     new->real = r;
@@ -1083,14 +1081,11 @@
     return NULL;
 }
 static const char*
-    cookie_domain(cmd_parms *cmd, void *dummy, const char *f, const char *r)
+    cookie_domain(cmd_parms *cmd, void *dconf, const char *f, const char *r)
 {
-    server_rec *s = cmd->server;
-    proxy_server_conf *conf;
+    proxy_dir_conf *conf = dconf;
     struct proxy_alias *new;
 
-    conf = (proxy_server_conf *)ap_get_module_config(s->module_config,
-                                                     &proxy_module);
     new = apr_array_push(conf->cookie_domains);
     new->fake = f;
     new->real = r;

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=231355&r1=231354&r2=231355&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Wed Aug 10 16:36:39 2005
@@ -125,7 +125,6 @@
     apr_array_header_t *proxies;
     apr_array_header_t *sec_proxy;
     apr_array_header_t *aliases;
-    apr_array_header_t *raliases;
     apr_array_header_t *noproxies;
     apr_array_header_t *dirconn;
     apr_array_header_t *allowed_connect_ports;
@@ -173,10 +172,6 @@
  * the strmatch_patterns are really a const just to have a
  * case-independent strstr.
  */
-    apr_array_header_t* cookie_paths;
-    apr_array_header_t* cookie_domains;
-    const apr_strmatch_pattern* cookie_path_str;
-    const apr_strmatch_pattern* cookie_domain_str;
     enum {
         status_off,
         status_on,
@@ -191,6 +186,19 @@
     const char *p;            /* The path */
     int         p_is_fnmatch; /* Is this path an fnmatch candidate? */
     ap_regex_t  *r;            /* Is this a regex? */
+
+/* ProxyPassReverse and friends are documented as working inside
+ * <Location>.  But in fact they never have done in the case of
+ * more than one <Location>, because the server_conf can't see it.
+ * We need to move them to the per-dir config.
+ * Discussed in February:
+ * http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=110726027118798&w=2
+ */
+    apr_array_header_t *raliases;
+    apr_array_header_t* cookie_paths;
+    apr_array_header_t* cookie_domains;
+    const apr_strmatch_pattern* cookie_path_str;
+    const apr_strmatch_pattern* cookie_domain_str;
 } proxy_dir_conf;
 
 typedef struct {

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_http.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/mod_proxy_http.c?rev=231355&r1=231354&r2=231355&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_http.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_http.c Wed Aug 10 16:36:39 2005
@@ -968,7 +968,7 @@
     return APR_SUCCESS;
 }
 
-static void process_proxy_header(request_rec* r, proxy_server_conf* c,
+static void process_proxy_header(request_rec* r, proxy_dir_conf* c,
                       const char* key, const char* value)
 {
     static const char* date_hdrs[]
@@ -1021,7 +1021,9 @@
     int saw_headers = 0;
     void *sconf = r->server->module_config;
     proxy_server_conf *psc;
+    proxy_dir_conf *dconf;
 
+    dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
     psc = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
 
     r->headers_out = apr_table_make(r->pool, 20);
@@ -1096,7 +1098,7 @@
          * Modify headers requiring canonicalisation and/or affected
          * by ProxyPassReverse and family with process_proxy_header
          */
-        process_proxy_header(r, psc, buffer, value) ;
+        process_proxy_header(r, dconf, buffer, value) ;
         saw_headers = 1;
 
         /* the header was too long; at the least we should skip extra data */



Re: svn commit: r231355 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy.h mod_proxy_http.c

Posted by Nick Kew <ni...@webthing.com>.
Joe Orton wrote:

> plus this looks equally broken:

OK, I've bitten the bullet and updated my build environment here to
to build the whole proxy in context.  Apologies for assuming this
fix was too simple to need it.

Note that the 2.0 fix is a straight diff between 2.0.54 and a fully
working fixed version.  That's basically what I was copying from, but
I hadn't appreciated how widespread *relevant* changes had become.

-- 
Nick Kew

Re: svn commit: r231355 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy.h mod_proxy_http.c

Posted by Joe Orton <jo...@redhat.com>.
On Fri, Aug 12, 2005 at 07:59:49AM +0100, Joe Orton wrote:
> On Thu, Aug 11, 2005 at 07:56:38PM +0100, Nick Kew wrote:
> > Justin Erenkrantz wrote:
> > 
> > >>Fix ProxyPassReverse & family to work correctly in <Location>
> > >
> > >
> > >This commit broke the build.
> > 
> > Aaargh!  Careless cut&paste.  Sorry.  Fixed - thanks.
> 
> proxy_util.c: In function `ap_proxy_location_reverse_map':
> proxy_util.c:1015: error: structure has no member named `raliases'
> proxy_util.c:1016: error: structure has no member named `raliases'

plus this looks equally broken:

mod_proxy_http.c: In function 'process_proxy_header':
mod_proxy_http.c:998: warning: passing argument 2 of 'transform_hdrs[i].func' from incompatible pointer type

joe

Re: svn commit: r231355 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy.h mod_proxy_http.c

Posted by Joe Orton <jo...@redhat.com>.
On Thu, Aug 11, 2005 at 07:56:38PM +0100, Nick Kew wrote:
> Justin Erenkrantz wrote:
> 
> >>Fix ProxyPassReverse & family to work correctly in <Location>
> >
> >
> >This commit broke the build.
> 
> Aaargh!  Careless cut&paste.  Sorry.  Fixed - thanks.

proxy_util.c: In function `ap_proxy_location_reverse_map':
proxy_util.c:1015: error: structure has no member named `raliases'
proxy_util.c:1016: error: structure has no member named `raliases'
proxy_util.c: In function `ap_proxy_cookie_reverse_map':
proxy_util.c:1053: error: structure has no member named `cookie_path_str'
proxy_util.c:1053: error: structure has no member named `cookie_path_str'
proxy_util.c:1053: warning: left-hand operand of comma expression has no effect
proxy_util.c:1059: error: structure has no member named `cookie_paths'
proxy_util.c:1060: error: structure has no member named `cookie_paths'
proxy_util.c:1070: error: structure has no member named `cookie_domain_str'
proxy_util.c:1070: error: structure has no member named `cookie_domain_str'
proxy_util.c:1070: warning: left-hand operand of comma expression has no effect
proxy_util.c:1076: error: structure has no member named `cookie_domains'
proxy_util.c:1077: error: structure has no member named `cookie_domains'

Re: svn commit: r231355 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy.h mod_proxy_http.c

Posted by Nick Kew <ni...@webthing.com>.
Justin Erenkrantz wrote:

>> Fix ProxyPassReverse & family to work correctly in <Location>
> 
> 
> This commit broke the build.

Aaargh!  Careless cut&paste.  Sorry.  Fixed - thanks.

> Please fix or revert.  (I have no idea what you were trying to do.)  -- 

See my posts on "Fixing ProxyPassReverse".

-- 
Nick Kew

Re: svn commit: r231355 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy.h mod_proxy_http.c

Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
--On August 10, 2005 11:36:43 PM +0000 niq@apache.org wrote:

> Author: niq
> Date: Wed Aug 10 16:36:39 2005
> New Revision: 231355
>
> URL: http://svn.apache.org/viewcvs?rev=231355&view=rev
> Log:
> Fix ProxyPassReverse & family to work correctly in <Location>

This commit broke the build.

/Users/jerenk/work/httpd-2.3/modules/proxy/mod_proxy.c: In function 
'merge_proxy_dir_config':
/Users/jerenk/work/httpd-2.3/modules/proxy/mod_proxy.c:880: error: 'base' 
undeclared (first use in this function)
/Users/jerenk/work/httpd-2.3/modules/proxy/mod_proxy.c:880: error: (Each 
undeclared identifier is reported only once
/Users/jerenk/work/httpd-2.3/modules/proxy/mod_proxy.c:880: error: for each 
function it appears in.)
/Users/jerenk/work/httpd-2.3/modules/proxy/mod_proxy.c:880: error: 'overrides' 
undeclared (first use in this function)

Please fix or revert.  (I have no idea what you were trying to do.)  -- justin