dgaudet 98/03/05 23:51:00
Modified: src CHANGES src/include httpd.h src/modules/proxy mod_proxy.c Log: Fix a bug pointed out by Lars on new-httpd in message-id <[EMAIL PROTECTED]>. I'm not sure how this ever worked before. Luck I guess. If a request matches the vhost of a proxy then it's quite possible that various other modules such as mod_alias will get their grubby hands on the uri and play games like Alias or ScriptAlias and then short-circuit the translate_names phase before mod_proxy gets to handle "ProxyRequests on". So instead mod_proxy handles "ProxyRequests on" in the post_read_request phase... which can't be short-circuited. Revision Changes Path 1.689 +5 -1 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.688 retrieving revision 1.689 diff -u -r1.688 -r1.689 --- CHANGES 1998/03/05 18:58:30 1.688 +++ CHANGES 1998/03/06 07:50:55 1.689 @@ -62,9 +62,13 @@ In order to achieve this change subtle changes were made to the API. In a request_rec, r->hostlen has been removed. r->unparsed_uri now exists so that the unmodified uri can be retrieved easily. r->proxyreq is not set - until the translate_names phase. + by the core, modules must set it during the post_read_request or + translate_names phase. Plus changes to the virtualhost test suite for absoluteURI testing. + + This fixes several bugs with the proxy proxying requests to vhosts + managed by the same httpd. [Dean Gaudet] *) Cleanup of code in http_vhost.c, and remove vhost matching code from 1.193 +2 -1 apache-1.3/src/include/httpd.h Index: httpd.h =================================================================== RCS file: /export/home/cvs/apache-1.3/src/include/httpd.h,v retrieving revision 1.192 retrieving revision 1.193 diff -u -r1.192 -r1.193 --- httpd.h 1998/03/05 13:27:14 1.192 +++ httpd.h 1998/03/06 07:50:58 1.193 @@ -564,7 +564,8 @@ char *the_request; /* First line of request, so we can log it */ int assbackwards; /* HTTP/0.9, "simple" request */ - int proxyreq; /* A proxy request (calculated during translate_name) */ + int proxyreq; /* A proxy request (calculated during + * post_read_request or translate_name) */ int header_only; /* HEAD request, as opposed to GET */ char *protocol; /* Protocol, as given to us, or HTTP/0.9 */ int proto_num; /* Number version of protocol; 1.1 = 1001 */ 1.45 +37 -11 apache-1.3/src/modules/proxy/mod_proxy.c Index: mod_proxy.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/mod_proxy.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- mod_proxy.c 1998/03/04 10:50:30 1.44 +++ mod_proxy.c 1998/03/06 07:50:59 1.45 @@ -121,13 +121,23 @@ return urip - uri; } -static int proxy_trans(request_rec *r) +/* Detect if an absoluteURI should be proxied or not. Note that we + * have to do this during this phase because later phases are + * "short-circuiting"... i.e. translate_names will end when the first + * module returns OK. So for example, if the request is something like: + * + * GET http://othervhost/cgi-bin/printenv HTTP/1.0 + * + * mod_alias will notice the /cgi-bin part and ScriptAlias it and + * short-circuit the proxy... just because of the ordering in the + * configuration file. + */ +static int proxy_detect(request_rec *r) { void *sconf = r->server->module_config; - proxy_server_conf *conf = - (proxy_server_conf *) get_module_config(sconf, &proxy_module); - int i, len; - struct proxy_alias *ent = (struct proxy_alias *) conf->aliases->elts; + proxy_server_conf *conf; + + conf = (proxy_server_conf *) get_module_config(sconf, &proxy_module); if (conf->req && r->parsed_uri.scheme) { /* but it might be something vhosted */ @@ -135,13 +145,29 @@ && !strcasecmp(r->parsed_uri.scheme, http_method(r)) && matches_request_vhost(r, r->parsed_uri.hostname, r->parsed_uri.port_str ? r->parsed_uri.port : default_port(r)))) { - r->proxyreq = 1; - r->uri = r->unparsed_uri; - r->filename = pstrcat(r->pool, "proxy:", r->uri, NULL); - r->handler = "proxy-server"; - return OK; + r->proxyreq = 1; + r->uri = r->unparsed_uri; + r->filename = pstrcat(r->pool, "proxy:", r->uri, NULL); + r->handler = "proxy-server"; } } + return DECLINED; +} + +static int proxy_trans(request_rec *r) +{ + void *sconf = r->server->module_config; + proxy_server_conf *conf = + (proxy_server_conf *) get_module_config(sconf, &proxy_module); + int i, len; + struct proxy_alias *ent = (struct proxy_alias *) conf->aliases->elts; + + if (r->proxyreq) { + /* someone has already set up the proxy, it was possibly ourselves + * in proxy_detect + */ + return OK; + } /* XXX: since r->uri has been manipulated already we're not really * compliant with RFC1945 at this point. But this probably isn't @@ -774,5 +800,5 @@ NULL, /* header parser */ NULL, /* child_init */ NULL, /* child_exit */ - NULL /* post read-request */ + proxy_detect /* post read-request */ };