cvs commit: apachen/src/modules/proxy mod_proxy.c
dgaudet 97/11/08 13:39:13 Modified:src CHANGES src/main http_request.c src/modules/proxy mod_proxy.c Log: find_types() shouldn't be called if we just found a matching ProxyPass directive and set handler to 'proxy-server', because find_types() resets r->handler if we have an other handler (server-info, server-parsed, etc.) that will be invoked on the URI from the request. PR: 870 Submitted by: Lars Eilebrecht Reviewed by: Dean Gaudet, Martin Kraemer Revision ChangesPath 1.497 +6 -0 apachen/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apachen/src/CHANGES,v retrieving revision 1.496 retrieving revision 1.497 diff -u -r1.496 -r1.497 --- CHANGES 1997/11/08 21:33:07 1.496 +++ CHANGES 1997/11/08 21:39:07 1.497 @@ -1,5 +1,11 @@ Changes with Apache 1.3b3 + *) Preserve handler value on ProxyPass'ed requests by not + calling find_types on a proxy'd request; fixes problems + where some ProxyPass'ed URLs weren't actually passed + to the proxy. + [Lars Eilebrecht] PR#870 + *) Fix a byte ordering problem in mod_access which prevented the old-style syntax (i.e. "a.b.c." to match a class C) from working properly. [Dean Gaudet] PR#1248, 1328, 1384 1.92 +5 -4 apachen/src/main/http_request.c Index: http_request.c === RCS file: /export/home/cvs/apachen/src/main/http_request.c,v retrieving revision 1.91 retrieving revision 1.92 diff -u -r1.91 -r1.92 --- http_request.c1997/10/22 20:29:44 1.91 +++ http_request.c1997/11/08 21:39:11 1.92 @@ -1093,10 +1093,11 @@ break; } -if ((access_status = find_types(r)) != 0) { -decl_die(access_status, "find types", r); -return; -} +if (!r->proxyreq) + if ((access_status = find_types(r)) != 0) { + decl_die(access_status, "find types", r); + return; + } if ((access_status = run_fixups(r)) != 0) { die(access_status, r); 1.28 +2 -1 apachen/src/modules/proxy/mod_proxy.c Index: mod_proxy.c === RCS file: /export/home/cvs/apachen/src/modules/proxy/mod_proxy.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- mod_proxy.c 1997/10/22 20:30:04 1.27 +++ mod_proxy.c 1997/11/08 21:39:12 1.28 @@ -140,11 +140,12 @@ for (i = 0; i < conf->aliases->nelts; i++) { len = alias_match(r->uri, ent[i].fake); - + if (len > 0) { r->filename = pstrcat(r->pool, "proxy:", ent[i].real, r->uri + len, NULL); r->handler = "proxy-server"; + r->proxyreq = 1; return OK; } }
cvs commit: apachen/src/modules/proxy mod_proxy.c
dgaudet 98/01/21 14:09:58 Modified:src/modules/proxy mod_proxy.c Log: more const stuff from debugging the code Revision ChangesPath 1.31 +3 -3 apachen/src/modules/proxy/mod_proxy.c Index: mod_proxy.c === RCS file: /export/home/cvs/apachen/src/modules/proxy/mod_proxy.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- mod_proxy.c 1998/01/07 16:46:34 1.30 +++ mod_proxy.c 1998/01/21 22:09:57 1.31 @@ -82,10 +82,10 @@ /* -- */ /* Translate the URL into a 'filename' */ -static int alias_match(char *uri, char *alias_fakename) +static int alias_match(const char *uri, const char *alias_fakename) { -char *end_fakename = alias_fakename + strlen(alias_fakename); -char *aliasp = alias_fakename, *urip = uri; +const char *end_fakename = alias_fakename + strlen(alias_fakename); +const char *aliasp = alias_fakename, *urip = uri; while (aliasp < end_fakename) { if (*aliasp == '/') {
cvs commit: apachen/src/modules/proxy mod_proxy.c
dgaudet 98/01/24 12:30:08 Modified:src/modules/proxy mod_proxy.c Log: don't waste memory allocating an error message... use %s and such Revision ChangesPath 1.32 +2 -2 apachen/src/modules/proxy/mod_proxy.c Index: mod_proxy.c === RCS file: /export/home/cvs/apachen/src/modules/proxy/mod_proxy.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- mod_proxy.c 1998/01/21 22:09:57 1.31 +++ mod_proxy.c 1998/01/24 20:30:07 1.32 @@ -253,8 +253,8 @@ table_set(r->headers_out, "Location", nuri); aplog_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r->server, - pstrcat(r->pool, "Domain missing: ", r->uri, " sent to ", nuri, - ref ? " from " : NULL, ref, NULL)); + "Domain missing: %s sent to %s from %s", r->uri, nuri, + ref ? ref : "-"); return REDIRECT; }
cvs commit: apachen/src/modules/proxy mod_proxy.c mod_proxy.h
dgaudet 97/10/04 19:12:34 Modified:src/modules/proxy mod_proxy.c mod_proxy.h Log: CacheDirLevels/Length must have their product < 20. PR: 1160 Submitted by: Lars Eilebrecht Reviewed by: Dean Gaudet Revision ChangesPath 1.26 +10 -4 apachen/src/modules/proxy/mod_proxy.c Index: mod_proxy.c === RCS file: /export/home/cvs/apachen/src/modules/proxy/mod_proxy.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- mod_proxy.c 1997/09/16 00:59:38 1.25 +++ mod_proxy.c 1997/10/05 02:12:32 1.26 @@ -640,8 +640,11 @@ get_module_config(parms->server->module_config, &proxy_module); int val; -if (sscanf(arg, "%d", &val) != 1) - return "Value must be an integer"; +val = atoi(arg); +if (val < 1) + return "Value must be an integer greater than 0"; +if (val * psf->cache.dirlength > CACHEFILE_LEN) + return "CacheDirLevels*CacheDirLength value must not be higher than 20"; psf->cache.dirlevels = val; return NULL; } @@ -653,8 +656,11 @@ get_module_config(parms->server->module_config, &proxy_module); int val; -if (sscanf(arg, "%d", &val) != 1) - return "Value must be an integer"; +val = atoi(arg); +if (val < 1) + return "Value must be an integer greater than 0"; +if (val * psf->cache.dirlevels > CACHEFILE_LEN) + return "CacheDirLevels*CacheDirLength value must not be higher than 20"; psf->cache.dirlength = val; return NULL; } 1.24 +4 -0 apachen/src/modules/proxy/mod_proxy.h Index: mod_proxy.h === RCS file: /export/home/cvs/apachen/src/modules/proxy/mod_proxy.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- mod_proxy.h 1997/09/16 00:59:39 1.23 +++ mod_proxy.h 1997/10/05 02:12:32 1.24 @@ -117,6 +117,10 @@ /* number of characters in the hash */ #define HASH_LEN (22*2) +/* maximum 'CacheDirLevels*CacheDirLength' value */ +#define CACHEFILE_LEN 20 /* must be less than HASH_LEN/2 */ + + #define SEC_ONE_DAY 86400 /* one day, in seconds */ #define SEC_ONE_HR 3600/* one hour, in seconds */
cvs commit: apachen/src/modules/proxy mod_proxy.c proxy_util.c
martin 97/11/27 05:46:31 Modified:src/modules/proxy mod_proxy.c proxy_util.c Log: Modified aplog_error() calls to use APLOG_NOERRNO when no errno was set; Reviewed bDean Gaudet Revision ChangesPath 1.29 +6 -4 apachen/src/modules/proxy/mod_proxy.c Index: mod_proxy.c === RCS file: /home/cvs/apachen/src/modules/proxy/mod_proxy.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -u -r1.28 -r1.29 --- mod_proxy.c 1997/11/08 21:39:12 1.28 +++ mod_proxy.c 1997/11/27 13:46:29 1.29 @@ -225,7 +225,7 @@ err = proxy_canon_netloc(r->pool, &url_copy, &user, &password, &host, &port); if (err != NULL) { - aplog_error(APLOG_MARK, APLOG_ERR, r->server, err); + aplog_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r->server, err); return DECLINED; } @@ -252,7 +252,7 @@ NULL); table_set(r->headers_out, "Location", nuri); - aplog_error(APLOG_MARK, APLOG_ERR, r->server, + aplog_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r->server, pstrcat(r->pool, "Domain missing: ", r->uri, " sent to ", nuri, ref ? " from " : NULL, ref, NULL)); @@ -311,14 +311,16 @@ for (direct_connect = ii = 0; ii < conf->dirconn->nelts && !direct_connect; ii++) { direct_connect = list[ii].matcher(&list[ii], r); - aplog_error(APLOG_MARK, APLOG_DEBUG, r->server, +#if DEBUGGING + aplog_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r->server, "URI and NoProxy: %s: %s", r->uri, list[ii].name); +#endif } #if DEBUGGING { char msg[256]; sprintf(msg, (direct_connect) ? "NoProxy for %s" : "UseProxy for %s", r->uri); - aplog_error(APLOG_MARK, APLOG_DEBUG, r->server, msg); + aplog_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r->server, msg); } #endif } 1.37 +1 -1 apachen/src/modules/proxy/proxy_util.c Index: proxy_util.c === RCS file: /home/cvs/apachen/src/modules/proxy/proxy_util.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -u -r1.36 -r1.37 --- proxy_util.c 1997/11/14 15:59:17 1.36 +++ proxy_util.c 1997/11/27 13:46:30 1.37 @@ -856,7 +856,7 @@ err = proxy_canon_netloc(r->pool, &url, &user, &password, &host, &port); if (err != NULL) - aplog_error(APLOG_MARK, APLOG_ERR, r->server, err); + aplog_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r->server, err); r->hostname = host;
cvs commit: apachen/src/modules/proxy mod_proxy.c mod_proxy.h proxy_connect.c
marc97/09/04 17:26:34 Modified:src CHANGES src/modules/proxy mod_proxy.c mod_proxy.h proxy_connect.c Log: Fix mod_proxy to properly handle CONNECT requests when we are talking to a proxy via ProxyRemote. Some of the code in here should be better abstracted, but the current API doesn't allow for it. The CONNECT request is special and is handled seperately from the rest of the proxy. PR: 1024 Reviewed by: Martin Kraemer, Randy Terbush, Lars Eilebrecht Revision ChangesPath 1.428 +8 -0 apachen/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apachen/src/CHANGES,v retrieving revision 1.427 retrieving revision 1.428 diff -u -r1.427 -r1.428 --- CHANGES 1997/09/03 15:56:07 1.427 +++ CHANGES 1997/09/05 00:26:29 1.428 @@ -1,5 +1,13 @@ Changes with Apache 1.3a2 + *) The proxy now properly handles CONNECT requests which are sent + to proxy servers when using ProxyRemote. [Marc Slemko, PR#1024] + + *) A script called apachectl has been added to the support + directory. This script allows you to do things such as + "apachectl start" and "apachectl restart" from the command + line. [Marc Slemko] + *) Modules and core routines are now put into libraries, which simplifies the link line tremendously (among other advantages). [Paul Sutton] 1.24 +8 -2 apachen/src/modules/proxy/mod_proxy.c Index: mod_proxy.c === RCS file: /export/home/cvs/apachen/src/modules/proxy/mod_proxy.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- mod_proxy.c 1997/09/01 03:07:26 1.23 +++ mod_proxy.c 1997/09/05 00:26:32 1.24 @@ -331,8 +331,14 @@ (p != NULL && strncmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) { + /* CONNECT is a special method that bypasses the normal + * proxy code. + */ + if (r->method_number == M_CONNECT) + rc = proxy_connect_handler(r, cr, url, ents[i].hostname, + ents[i].port); /* we only know how to handle communication to a proxy via http */ - if (strcmp(ents[i].protocol, "http") == 0) + else if (strcmp(ents[i].protocol, "http") == 0) rc = proxy_http_handler(r, cr, url, ents[i].hostname, ents[i].port); else rc = DECLINED; @@ -349,7 +355,7 @@ */ /* handle the scheme */ if (r->method_number == M_CONNECT) - return proxy_connect_handler(r, cr, url); + return proxy_connect_handler(r, cr, url, NULL, 0); if (strcmp(scheme, "http") == 0) return proxy_http_handler(r, cr, url, NULL, 0); if (strcmp(scheme, "ftp") == 0) 1.20 +2 -1 apachen/src/modules/proxy/mod_proxy.h Index: mod_proxy.h === RCS file: /export/home/cvs/apachen/src/modules/proxy/mod_proxy.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- mod_proxy.h 1997/08/23 22:59:10 1.19 +++ mod_proxy.h 1997/09/05 00:26:33 1.20 @@ -237,7 +237,8 @@ /* proxy_connect.c */ -int proxy_connect_handler(request_rec *r, struct cache_req *c, char *url); +int proxy_connect_handler(request_rec *r, struct cache_req *c, char *url, +const char *proxyhost, int proxyport); /* proxy_ftp.c */ 1.15 +34 -9 apachen/src/modules/proxy/proxy_connect.c Index: proxy_connect.c === RCS file: /export/home/cvs/apachen/src/modules/proxy/proxy_connect.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- proxy_connect.c 1997/09/01 03:07:27 1.14 +++ proxy_connect.c 1997/09/05 00:26:33 1.15 @@ -71,6 +71,9 @@ * "Tunneling SSL Through a WWW Proxy" currently at * http://www.mcom.com/newsref/std/tunneling_ssl.html. * + * If proxyhost and proxyport are set, we send a CONNECT to + * the specified proxy.. + * * FIXME: this is bad, because it does its own socket I/O *instead of using the I/O in buff.c. However, *the I/O in buff.c blocks on reads, and because @@ -90,7 +93,8 @@ */ int -proxy_connect_handler(request_rec *r, struct cache_req *c, char *url) +proxy_connect_handler(request_rec *r, struct cache_req *c, char *url, +const char *proxyhost, int proxyport) { struct sockaddr_in server; struct in_addr destaddr; @@ -140,10 +144,15 @@ return HTTP_SERVICE_UNAVAILABLE; } -Explain2("CONNECT to %s on port %d", host, port); +if (proxyhost) { +
cvs commit: apachen/src/modules/proxy mod_proxy.c proxy_connect.c proxy_http.c proxy_util.c
randy 97/08/31 20:07:30 Modified:src/modules/proxy mod_proxy.c proxy_connect.c proxy_http.c proxy_util.c Log: Convert log_*() to aplog_error(). Something needs to be done with proxy_log_uerror() in here. I see no obvious reason not to replace it with aplog_error() but would like some feedback first. Revision ChangesPath 1.23 +9 -9 apachen/src/modules/proxy/mod_proxy.c Index: mod_proxy.c === RCS file: /export/home/cvs/apachen/src/modules/proxy/mod_proxy.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- mod_proxy.c 1997/08/18 13:12:06 1.22 +++ mod_proxy.c 1997/09/01 03:07:26 1.23 @@ -221,9 +221,8 @@ /* Split request into user, password, host, port */ err = proxy_canon_netloc(r->pool, &url_copy, &user, &password, &host, &port); -if (err != NULL) -{ - log_error(err, r->server); +if (err != NULL) { + aplog_error(APLOG_MARK, APLOG_ERR, r->server, err); return DECLINED; } @@ -251,8 +250,10 @@ NULL); table_set(r->headers_out, "Location", nuri); - log_error(pstrcat(r->pool, "Domain missing: ", r->uri, " sent to ", nuri, - ref ? " from " : NULL, ref, NULL), r->server); + aplog_error(APLOG_MARK, APLOG_ERR, r->server, + pstrcat(r->pool, "Domain missing: ", r->uri, " sent to ", nuri, + ref ? " from " : NULL, ref, NULL)); + return REDIRECT; } } @@ -307,15 +308,14 @@ for (direct_connect=ii=0; ii < conf->dirconn->nelts && !direct_connect; ii++) { direct_connect = list[ii].matcher (&list[ii], r); - /*log_error("URI and NoProxy:", r->server);*/ - /*log_error(r->uri, r->server);*/ - /*log_error(list[ii].name, r->server);*/ + aplog_error(APLOG_MARK, APLOG_DEBUG, r->server, + "URI and NoProxy: %s: %s", r->uri, list[ii].name); } #if DEBUGGING { char msg[256]; sprintf (msg, (direct_connect)?"NoProxy for %s":"UseProxy for %s", r->uri); - log_error(msg, r->server); + aplog_error(APLOG_MARK, APLOG_DEBUG, r->server, msg); } #endif } 1.14 +2 -1 apachen/src/modules/proxy/proxy_connect.c Index: proxy_connect.c === RCS file: /export/home/cvs/apachen/src/modules/proxy/proxy_connect.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- proxy_connect.c 1997/08/17 13:56:27 1.13 +++ proxy_connect.c 1997/09/01 03:07:27 1.14 @@ -150,7 +150,8 @@ sock = psocket(r->pool, PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock == -1) { -log_error("proxy: error creating socket", r->server); +aplog_error(APLOG_MARK, APLOG_ERR, r->server, + "proxy: error creating socket"); return SERVER_ERROR; } 1.30 +2 -1 apachen/src/modules/proxy/proxy_http.c Index: proxy_http.c === RCS file: /export/home/cvs/apachen/src/modules/proxy/proxy_http.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- proxy_http.c 1997/08/23 22:59:11 1.29 +++ proxy_http.c 1997/09/01 03:07:27 1.30 @@ -223,7 +223,8 @@ sock = psocket(pool, PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock == -1) { - log_error("proxy: error creating socket", r->server); + aplog_error(APLOG_MARK, APLOG_ERR, r->server, + "proxy: error creating socket"); return SERVER_ERROR; } 1.25 +1 -1 apachen/src/modules/proxy/proxy_util.c Index: proxy_util.c === RCS file: /export/home/cvs/apachen/src/modules/proxy/proxy_util.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- proxy_util.c 1997/08/23 22:59:11 1.24 +++ proxy_util.c 1997/09/01 03:07:28 1.25 @@ -831,7 +831,7 @@ err = proxy_canon_netloc(r->pool, &url, &user, &password, &host, &port); if (err != NULL) - log_error(err, r->server); + aplog_error(APLOG_MARK, APLOG_ERR, r->server, err); r->hostname = host;