You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1998/02/27 06:05:23 UTC
[PATCH] fix absoluteURI support and other things
[This patch will include a mmn bump when committed.]
Presently apache 1.2 and 1.3 don't handle absoluteURIs in the same manner
that they handle name or ip virtual hosts. There is code duplication
(with bugs), and there is a mixture of proxy specific code in the core. In
particular the check_fulluri() function is wrong, and contains a DoS
attack.
If you ignore absoluteURIs our configuration language takes the approach
that no run-time DNS should be necessary. This is a good approach... and
so I'm extending it to absoluteURIs as well. We now treat an absoluteURI
that is not a proxy request as equivalent to a "Host:" header with the
same contents.
To do this a few changes were made to request_rec. r->hostlen was removed
-- it was replaced by r->absolute_uri which is the functionality that is
really needed. r->absolute_uri is the complete, unmodified absoluteURI
from the request if one was present; it is NULL otherwise. We need the
unmodified uri for proxying and we had kludges elsewhere to protect r->uri
if r->proxyreq was set. Adding r->absolute_uri removes those kludges.
That lets us delay setting r->proxyreq until the translate_names phase.
Which is when a proxy gets its hands on the request and declares if the
request is actually a proxy request or not.
While hacking on this I fixed a bunch of other related things. In
particular I added matches_request_vhost() which is used to remove code
from mod_rewrite which did vhost matching (including another DoS because
it would use DNS). I merged in a memory/time saving patch for ServerAlias
from Chia-liang Kao. I made a few small tweaks to http_vhost.c.
I may have to tweak TRACE a bit more before I commit, but the rest of this
I'm solid with. It passes the newly enhanced vhost test suite. The proxy
still seems to work, and mod_rewrite seems to still work where I had to
tweak it.
I don't know why someone would want to... but with this patch you can
run a proxy inside a name-virtual host. I'm not kidding. I don't think
we want to advertise that as a supported configuration...
I mentioned that I doing this work a few times in the past few weeks... I
hope folks like the way I did it. I'm closer to thinking that vhosts
are done done done for good ;)
Dean
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.669
diff -u -r1.669 CHANGES
--- CHANGES 1998/02/26 11:04:01 1.669
+++ CHANGES 1998/02/27 04:49:15
@@ -1,5 +1,29 @@
Changes with Apache 1.3b6
+ *) Rewrite of absoluteURI handling, and in particular how absoluteURIs
+ match vhosts. Unless a request is a proxy request, a "http://host"
+ url is treated as if a similar "Host:" header had been supplied.
+ This change was made to support future HTTP/1.x protocols which
+ may require clients to send absoluteURIs for all requests.
+
+ In order to achieve this change subtle changes were made to the API.
+ In a request_rec, r->hostlen has been removed. r->absolute_uri now
+ exists, and if the URI was an absoluteURI then its value *prior to
+ any modification* is copied here. r->proxyreq is not set until the
+ translate_names phase.
+
+ Plus changes to the virtualhost test suite for absoluteURI testing.
+ [Dean Gaudet]
+
+ *) Cleanup of code in http_vhost.c, and remove vhost matching code from
+ mod_rewrite. The vhost matching is now performed by a globally
+ available function matches_request_vhost(). [Dean Gaudet]
+
+ *) Reduce memory usage, and speed up ServerAlias support. As a
+ side-effect users can list multiple ServerAlias directives
+ and they're all considered.
+ [Chia-liang Kao <cl...@cirx.org>] PR#1531
+
*) Fix initialization of RewriteLogLevel (default now is 0 as documented
and not 1) and the per-virtual-server merging of directives. Now all
directives except `RewriteEngine' and `RewriteOption' are either
Index: include/http_vhost.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/http_vhost.h,v
retrieving revision 1.5
diff -u -r1.5 http_vhost.h
--- http_vhost.h 1998/01/21 19:17:40 1.5
+++ http_vhost.h 1998/02/27 04:49:16
@@ -74,4 +74,10 @@
*/
void update_vhost_from_headers(request_rec *r);
+/* return 1 if the host:port matches any of the aliases of r->server
+ * return 0 otherwise
+ */
+API_EXPORT(int) matches_request_vhost(request_rec *r, const char *host,
+ unsigned port);
+
#endif /* !APACHE_HTTP_VHOST_H */
Index: include/httpd.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/httpd.h,v
retrieving revision 1.187
diff -u -r1.187 httpd.h
--- httpd.h 1998/02/18 08:39:21 1.187
+++ httpd.h 1998/02/27 04:49:17
@@ -560,12 +560,11 @@
char *the_request; /* First line of request, so we can log it */
int assbackwards; /* HTTP/0.9, "simple" request */
- int proxyreq; /* A proxy request */
+ int proxyreq; /* A proxy request (calculated during 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 */
char *hostname; /* Host, as set by full URI or Host: */
- int hostlen; /* Length of http://host:port in full URI */
time_t request_time; /* When the request started */
@@ -650,8 +649,12 @@
* or content-negotiation mapping).
*/
- char *uri; /* complete URI for a proxy req, or
- URL path for a non-proxy req */
+ char *absolute_uri; /* if an absoluteURI was given, it is here in
+ its original unmodified form,
+ NULL otherwise */
+ char *uri; /* the URI after possibly stripping one
+ http://hostname:port from it, and possibly
+ doing other munching on it */
char *filename;
char *path_info;
char *args; /* QUERY_ARGS, if any */
@@ -775,7 +778,8 @@
char *path; /* Pathname for ServerPath */
int pathlen; /* Length of path */
- char *names; /* Wildcarded names for ServerAlias servers */
+ array_header *names; /* Normal names for ServerAlias servers */
+ array_header *wild_names; /* Wildcarded names for ServerAlias servers */
uid_t server_uid; /* effective user id when calling exec wrapper */
gid_t server_gid; /* effective group id when calling exec wrapper */
Index: main/http_config.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_config.c,v
retrieving revision 1.99
diff -u -r1.99 http_config.c
--- http_config.c 1998/02/25 09:36:12 1.99
+++ http_config.c 1998/02/27 04:49:19
@@ -1175,7 +1175,8 @@
s->next = NULL;
s->is_virtual = 1;
- s->names = NULL;
+ s->names = make_array(p, 4, sizeof(char **));
+ s->wild_names = make_array(p, 4, sizeof(char **));
s->module_config = create_empty_config(p);
s->lookup_defaults = create_per_dir_config(p);
@@ -1284,6 +1285,7 @@
/* NOT virtual host; don't match any real network interface */
s->addrs->host_addr.s_addr = htonl(INADDR_ANY);
s->addrs->host_port = 0; /* matches any port */
+ s->names = s->wild_names = NULL;
s->module_config = create_server_config(p, s);
s->lookup_defaults = create_default_per_dir_config(p);
Index: main/http_core.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
retrieving revision 1.164
diff -u -r1.164 http_core.c
--- http_core.c 1998/02/23 00:05:38 1.164
+++ http_core.c 1998/02/27 04:49:21
@@ -1222,6 +1222,21 @@
return errmsg;
}
+const char *set_server_alias(cmd_parms *cmd, void *dummy, const char *arg)
+{
+ if (!cmd->server->names)
+ return "ServerAlias only used in <VirtualHost>";
+ while (*arg) {
+ char **item, *name = getword_conf(cmd->pool, &arg);
+ if (is_matchexp(name))
+ item = (char **) push_array(cmd->server->wild_names);
+ else
+ item = (char **) push_array(cmd->server->names);
+ *item = name;
+ }
+ return NULL;
+}
+
const char *add_module_command (cmd_parms *cmd, void *dummy, char *arg)
{
const char *err = check_cmd_context(cmd, GLOBAL_ONLY);
@@ -1872,9 +1887,8 @@
{ "ResourceConfig", set_server_string_slot,
(void *)XtOffsetOf (server_rec, srm_confname), RSRC_CONF, TAKE1,
"The filename of the resource config file" },
-{ "ServerAlias", set_server_string_slot,
- (void *)XtOffsetOf (server_rec, names), RSRC_CONF, RAW_ARGS,
- "A name or names alternately used to access the server" },
+{ "ServerAlias", set_server_alias, NULL, RSRC_CONF, RAW_ARGS,
+ "A name or names alternately used to access the server" },
{ "ServerPath", set_serverpath, NULL, RSRC_CONF, TAKE1,
"The pathname the server can be reached at" },
{ "Timeout", set_timeout, NULL, RSRC_CONF, TAKE1, "Timeout duration (sec)"},
Index: main/http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_protocol.c,v
retrieving revision 1.191
diff -u -r1.191 http_protocol.c
--- http_protocol.c 1998/02/22 21:37:47 1.191
+++ http_protocol.c 1998/02/27 04:49:22
@@ -570,33 +570,122 @@
return total;
}
-void parse_uri(request_rec *r, const char *uri)
+
+/*
+ * If the URI is an absoluteURI then set r->absolute_uri appropriately
+ * and if it's for one of the protocols we support, then break out
+ * r->hostname (in prep for parsing it as a vhost).
+ *
+ * XXX: no way to report an error for a malformed uri such as
+ * "http://", or "http:///", or "http://:/" or...
+ *
+ * Expects the caller to check that uri[0] != '/'.
+ */
+static const char *parse_absoluteuri(request_rec *r, const char *uri)
{
- const char *s;
+ char *host, *proto;
+ const char *tmp;
+ const char *end_host;
+ int plen;
+
+ /* look for a scheme */
+ tmp = uri;
+ while (isalnum(*tmp) || *tmp == '+' || *tmp == '-' || *tmp == '.') {
+ ++tmp;
+ }
+
+ if (tmp == uri || *tmp != ':') {
+ /* this is a bogus uri */
+ return uri;
+ }
+
+ /* we've got an absoluteURI, so tuck it away for the proxy */
+ r->absolute_uri = pstrdup(r->pool, uri);
+
+ /* now, is it an absoluteURI in the protocol we handle? if so we prep
+ * for vhost matching
+ */
+ proto = http_method(r);
+ plen = strlen(proto);
+
+ if (tmp - uri != plen
+ || strncasecmp(uri, proto, plen)
+ || tmp[1] != '/' || tmp[2] != '/') {
+ return uri;
+ }
+ /* find the end of the hostname */
+ tmp += 3;
+ end_host = tmp;
+ while (*end_host && *end_host != '/' && *end_host != ':') {
+ ++end_host;
+ }
+
+ /* is there a non-zerolength hostname? */
+ if (end_host - tmp <= 1) {
+ /* whatever, this is bogus, don't touch it */
+ return uri;
+ }
+
+ /* and copy it (note we totally ignore the port... see
+ * http_vhost for why) */
+ host = palloc(r->pool, end_host - tmp + 1);
+ memcpy(host, tmp, end_host - tmp);
+ host[end_host - tmp] = '\0';
+ r->hostname = host;
+
+ /* Figure out if there's a path after the hostname... we have to pretend
+ * there was a lone "/" if no path was given.
+ */
+ if (*end_host == ':') {
+ tmp = strchr(end_host, '/');
+ if (tmp) {
+ return tmp;
+ }
+ return "/";
+ }
+ else if (*end_host == '\0') {
+ return "/";
+ }
+ return end_host;
+}
+
+/*
+ * Given a uri break it out into several fields:
+ *
+ * If uri is an absoluteURI then:
+ * r->absolute_uri is set to an exact copy, for passing to proxies without
+ * munging.
+ *
+ * If the protocol matches, then break out r->hostname for further vhost
+ * processing.
+ *
+ * trim the absolute portion of the uri and proceed:
+ *
+ * regardless we set:
+ *
+ * r->uri
+ * r->args
+ *
+ * And we may start munching on r->uri, we definately will later on
+ * (things like unescape_url and getparents in process_request).
+ */
+void parse_uri(request_rec *r, const char *uri)
+{
#if defined(__EMX__) || defined(WIN32)
/* Variable for OS/2 fix below. */
size_t loop, uri_len;
#endif
- /* A proxy request contains a ':' early on, but not as first character */
-
- for (s = uri; s != '\0'; s++)
- if (!isalnum(*s) && *s != '+' && *s != '-' && *s != '.')
- break;
-
- if (*s == ':' && s != uri) {
- r->proxyreq = 1;
- r->uri = pstrdup(r->pool, uri);
- r->args = NULL;
+ /* deal with absoluteURIs */
+ if (uri[0] != '/') {
+ uri = parse_absoluteuri(r, uri);
}
- else if (r->method && !strcmp(r->method, "TRACE")) {
- r->proxyreq = 0;
+ if (r->method && !strcmp(r->method, "TRACE")) {
r->uri = pstrdup(r->pool, uri);
r->args = NULL;
}
else {
- r->proxyreq = 0;
r->uri = getword(r->pool, &uri, '?');
#if defined(__EMX__) || defined(WIN32)
@@ -623,82 +712,6 @@
}
}
-const char *check_fulluri(request_rec *r, const char *uri)
-{
- char *host, *proto, *slash, *colon;
- int plen;
- unsigned port;
- const char *res_uri;
-
- /* This routine parses full URLs, if they match the server */
- proto = http_method(r);
- plen = strlen(proto);
-
- if (strncasecmp(uri, proto, plen) || strncasecmp(uri + plen, "://", 3))
- return uri;
- host = pstrdup(r->pool, uri + plen + 3);
-
- /* Find the hostname, assuming a valid request */
- slash = strchr(host, '/');
- if (slash) {
- *slash = 0;
- }
- else {
- slash = host + strlen(host);
- }
-
- /* Find the port */
- colon = strchr(host, ':');
- if (colon) {
- *colon = '\0';
- port = atoi(colon+1);
- if (port == 0) {
- return uri;
- }
- }
- else {
- port = default_port(r);
- }
-
- /* Make sure ports match */
- if (port != r->server->port)
- return uri;
-
- /* Save it for later use */
- r->hostname = host;
- r->hostlen = plen + 3 + slash - host;
- res_uri = uri + r->hostlen;
- /* deal with "http://host" */
- if (*res_uri == '\0') {
- res_uri = "/";
- }
-
- /* The easy cases first */
- if (!strcasecmp(host, r->server->server_hostname)) {
- return res_uri;
- }
- else if (!strcmp(host, inet_ntoa(r->connection->local_addr.sin_addr))) {
- return res_uri;
- }
- else {
- /* Now things get a bit trickier - check the IP address(es) of
- * the host they gave, see if it matches ours.
- */
- struct hostent *hp;
- int n;
-
- if ((hp = gethostbyname(host))) {
- for (n = 0; hp->h_addr_list[n] != NULL; n++) {
- if (r->connection->local_addr.sin_addr.s_addr ==
- (((struct in_addr *) (hp->h_addr_list[n]))->s_addr)) {
- return res_uri;
- }
- }
- }
- }
-
- return uri;
-}
int read_request_line(request_rec *r)
{
@@ -746,7 +759,6 @@
r->the_request = pstrdup(r->pool, l);
r->method = getword_white(r->pool, &ll);
uri = getword_white(r->pool, &ll);
- uri = check_fulluri(r, uri);
parse_uri(r, uri);
r->assbackwards = (ll[0] == '\0');
Index: main/http_request.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_request.c,v
retrieving revision 1.107
diff -u -r1.107 http_request.c
--- http_request.c 1998/02/18 10:01:14 1.107
+++ http_request.c 1998/02/27 04:49:23
@@ -1010,28 +1010,14 @@
return;
}
- if (!r->proxyreq) {
- /*
- * We don't want TRACE to run through the normal handler set, we
- * handle it specially.
- */
- if (r->method_number == M_TRACE) {
- if ((access_status = send_http_trace(r)))
- die(access_status, r);
- else
- finalize_request_protocol(r);
- return;
- }
-
- access_status = unescape_url(r->uri);
- if (access_status) {
- die(access_status, r);
- return;
- }
-
- getparents(r->uri); /* OK --- shrinking transformations... */
+ access_status = unescape_url(r->uri);
+ if (access_status) {
+ die(access_status, r);
+ return;
}
+ getparents(r->uri); /* OK --- shrinking transformations... */
+
if ((access_status = location_walk(r))) {
die(access_status, r);
return;
@@ -1042,6 +1028,20 @@
return;
}
+ if (!r->proxyreq) {
+ /*
+ * We don't want TRACE to run through the normal handler set, we
+ * handle it specially.
+ */
+ if (r->method_number == M_TRACE) {
+ if ((access_status = send_http_trace(r)))
+ die(access_status, r);
+ else
+ finalize_request_protocol(r);
+ return;
+ }
+ }
+
if (r->proto_num > HTTP_VERSION(1,0) && table_get(r->subprocess_env, "downgrade-1.0")) {
r->proto_num = HTTP_VERSION(1,0);
}
@@ -1222,7 +1222,6 @@
new->protocol = r->protocol;
new->proto_num = r->proto_num;
new->hostname = r->hostname;
- new->hostlen = r->hostlen;
new->request_time = r->request_time;
new->main = r->main;
Index: main/http_vhost.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_vhost.c,v
retrieving revision 1.6
diff -u -r1.6 http_vhost.c
--- http_vhost.c 1998/02/01 21:19:30 1.6
+++ http_vhost.c 1998/02/27 04:49:23
@@ -365,17 +365,19 @@
}
-static ap_inline ipaddr_chain *find_ipaddr(struct in_addr server_ip,
+static ap_inline ipaddr_chain *find_ipaddr(struct in_addr *server_ip,
unsigned port)
{
unsigned bucket;
ipaddr_chain *trav;
+ unsigned s_addr;
/* scan the hash table for an exact match first */
- bucket = hash_inaddr(server_ip.s_addr);
+ s_addr = server_ip->s_addr;
+ bucket = hash_inaddr(s_addr);
for (trav = iphash_table[bucket]; trav; trav = trav->next) {
server_addr_rec *sar = trav->sar;
- if ((sar->host_addr.s_addr == server_ip.s_addr)
+ if ((sar->host_addr.s_addr == s_addr)
&& (sar->host_port == 0 || sar->host_port == port
|| port == 0)) {
return trav;
@@ -472,7 +474,7 @@
}
else {
/* see if it matches something we've already got */
- ic = find_ipaddr(sar->host_addr, sar->host_port);
+ ic = find_ipaddr(&sar->host_addr, sar->host_port);
/* the first time we encounter a NameVirtualHost address
* ic->server will be NULL, on subsequent encounters
@@ -605,6 +607,89 @@
r->hostname = host;
}
+
+/* return 1 if host matches ServerName or ServerAliases */
+static int matches_aliases(server_rec *s, const char *host)
+{
+ int i;
+ array_header *names;
+
+ /* match ServerName */
+ if (!strcasecmp(host, s->server_hostname)) {
+ return 1;
+ }
+
+ /* search all the aliases from ServerAlias directive */
+ names = s->names;
+ if (names) {
+ char **name = (char **) names->elts;
+ for (i = 0; i < names->nelts; ++i) {
+ if(!name[i]) continue;
+ if (!strcasecmp(host, name[i]))
+ return 1;
+ }
+ }
+ names = s->wild_names;
+ if (names) {
+ char **name = (char **) names->elts;
+ for (i = 0; i < names->nelts; ++i) {
+ if(!name[i]) continue;
+ if (!strcasecmp_match(host, name[i]))
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+/* Suppose a request came in on the same socket as this r, and included
+ * a header "Host: host:port", would it map to r->server? It's more
+ * than just that though. When we do the normal matches for each request
+ * we don't even bother considering Host: etc on non-namevirtualhosts,
+ * we just call it a match. But here we require the host:port to match
+ * the ServerName and/or ServerAliases.
+ */
+API_EXPORT(int) matches_request_vhost(request_rec *r, const char *host,
+ unsigned port)
+{
+ server_rec *s;
+ server_addr_rec *sar;
+
+ s = r->server;
+
+ /* search all the <VirtualHost> values */
+ /* XXX: If this is a NameVirtualHost then we may not be doing the Right Thing
+ * consider:
+ *
+ * NameVirtualHost 10.1.1.1
+ * <VirtualHost 10.1.1.1>
+ * ServerName v1
+ * </VirtualHost>
+ * <VirtualHost 10.1.1.1>
+ * ServerName v2
+ * </VirtualHost>
+ *
+ * Suppose r->server is v2, and we're asked to match "10.1.1.1". We'll say
+ * "yup it's v2", when really it isn't... if a request came in for 10.1.1.1
+ * it would really go to v1.
+ */
+ for (sar = s->addrs; sar; sar = sar->next) {
+ if ((sar->host_port == 0 || port == sar->host_port)
+ && !strcasecmp(host, sar->virthost)) {
+ return 1;
+ }
+ }
+
+ /* the Port has to match now, because the rest don't have ports associated
+ * with them. */
+ if (port != s->port) {
+ return 0;
+ }
+
+ return matches_aliases(s, host);
+}
+
+
static void check_hostalias(request_rec *r)
{
/*
@@ -638,7 +723,6 @@
*/
for (src = r->connection->vhost_lookup_data; src; src = src->next) {
- const char *names;
server_addr_rec *sar;
/* We only consider addresses on the name_chain which have a matching
@@ -664,33 +748,15 @@
}
last_s = s;
- /* match ServerName */
- if (!strcasecmp(host, s->server_hostname)) {
+ if (matches_aliases(s, host)) {
goto found;
- }
-
- /* search all the aliases from ServerAlias directive */
- names = s->names;
- if (names) {
- while (*names) {
- char *name = getword_conf(r->pool, &names);
-
- if ((is_matchexp(name) && !strcasecmp_match(host, name)) ||
- (!strcasecmp(host, name))) {
- goto found;
- }
- }
- }
+ }
}
return;
found:
/* s is the first matching server, we're done */
r->server = r->connection->server = s;
- if (r->hostlen && !strncasecmp(r->uri, "http://", 7)) {
- r->uri += r->hostlen;
- parse_uri(r, r->uri);
- }
}
@@ -705,7 +771,7 @@
* This is in conjunction with the ServerPath code in http_core, so we
* get the right host attached to a non- Host-sending request.
*
- * See the comment in check_hostaliases about how each vhost can be
+ * See the comment in check_hostalias about how each vhost can be
* listed multiple times.
*/
@@ -756,24 +822,16 @@
*/
void update_vhost_given_ip(conn_rec *conn)
{
- server_addr_rec *sar;
ipaddr_chain *trav;
- unsigned bucket;
- struct in_addr server_ip = conn->local_addr.sin_addr;
unsigned port = ntohs(conn->local_addr.sin_port);
/* scan the hash table for an exact match first */
- bucket = hash_inaddr(server_ip.s_addr);
- for (trav = iphash_table[bucket]; trav; trav = trav->next) {
- sar = trav->sar;
- if ((sar->host_addr.s_addr == server_ip.s_addr)
- && (sar->host_port == 0 || sar->host_port == port)) {
-
- /* save the name_chain for later in case this is a name-vhost */
- conn->vhost_lookup_data = trav->names;
- conn->server = trav->server;
- return;
- }
+ trav = find_ipaddr(&conn->local_addr.sin_addr, port);
+ if (trav) {
+ /* save the name_chain for later in case this is a name-vhost */
+ conn->vhost_lookup_data = trav->names;
+ conn->server = trav->server;
+ return;
}
/* There's certainly no name-vhosts with this address, they would have
Index: modules/proxy/mod_proxy.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/mod_proxy.c,v
retrieving revision 1.38
diff -u -r1.38 mod_proxy.c
--- mod_proxy.c 1998/02/23 08:04:10 1.38
+++ mod_proxy.c 1998/02/27 04:49:24
@@ -126,15 +126,25 @@
proxy_server_conf *conf =
(proxy_server_conf *) get_module_config(sconf, &proxy_module);
- if (r->proxyreq) {
- if (!conf->req)
- return DECLINED;
-
- r->filename = pstrcat(r->pool, "proxy:", r->uri, NULL);
+ if (conf->req) {
+ r->proxyreq = 1;
+ /* XXX: if no absoluteURI was given we should issue an error,
+ * but RFC1945 doesn't define any error... we will end up using
+ * r->uri which has been munged beyond recognition here, violating
+ * another part of the RFC.
+ */
+ if (r->absolute_uri) {
+ r->uri = r->absolute_uri;
+ }
+ r->filename = pstrcat(r->pool, "proxy:", r->absolute_uri, NULL);
r->handler = "proxy-server";
return OK;
}
else {
+ /* XXX: since r->uri has been manipulated already we're not really
+ * compliant with RFC1945 at this point. But this probably isn't
+ * an issue because this is a hybrid proxy/origin server.
+ */
int i, len;
struct proxy_alias *ent = (struct proxy_alias *) conf->aliases->elts;
Index: modules/standard/mod_rewrite.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v
retrieving revision 1.75
diff -u -r1.75 mod_rewrite.c
--- mod_rewrite.c 1998/02/26 11:13:40 1.75
+++ mod_rewrite.c 1998/02/27 04:49:26
@@ -109,6 +109,7 @@
#include "http_request.h"
#include "http_core.h"
#include "http_log.h"
+#include "http_vhost.h"
/* now our own stuff ... */
#include "mod_rewrite.h"
@@ -2196,7 +2197,7 @@
}
/* now check whether we could reduce it to a local path... */
- if (is_this_our_host(r, host) && port == r->server->port) {
+ if (matches_request_vhost(r, host, port)) {
/* this is our host, so only the URL remains */
r->filename = pstrdup(r->pool, url);
rewritelog(r, 3, "reduce %s -> %s", olduri, r->filename);
@@ -3715,139 +3716,6 @@
else
return 0;
}
-
-
-/*
-**
-** special DNS lookup functions
-**
-*/
-
-static int is_this_our_host(request_rec *r, char *testhost)
-{
- char **cppHNLour;
- char **cppHNLtest;
- char *ourhostname;
- char *ourhostip;
- const char *names;
- char *name;
- int i, j;
- server_addr_rec *sar;
-
- /* we can check:
- r->
- char *hostname Host, as set by full URI or Host:
- int hostlen Length of http://host:port in full URI
- r->server->
- int is_virtual 0=main, 1=ip-virtual, 2=non-ip-virtual
- char *server_hostname used on compare to r->hostname
- inet_ntoa(r->connection->local_addr.sin_addr)
- used on compare to r->hostname
- unsigned short port for redirects
- char *path name of ServerPath
- int pathlen len of ServerPath
- char *names Wildcarded names for ServerAlias servers
- r->server->addrs->
- struct in_addr host_addr The bound address, for this server
- short host_port The bound port, for this server
- char *virthost The name given in <VirtualHost>
- */
-
- ourhostname = r->server->server_hostname;
- ourhostip = inet_ntoa(r->connection->local_addr.sin_addr);
-
- /* just a simple common case */
- if (strcmp(testhost, ourhostname) == 0 ||
- strcmp(testhost, ourhostip) == 0 )
- return YES;
-
- /* now the complicated cases */
- if (!r->server->is_virtual) {
- /* main servers */
-
- /* check for the alternative IP addresses */
- if ((cppHNLour = resolv_ipaddr_list(r, ourhostname)) == NULL)
- return NO;
- if ((cppHNLtest = resolv_ipaddr_list(r, testhost)) == NULL)
- return NO;
- for (i = 0; cppHNLtest[i] != NULL; i++) {
- for (j = 0; cppHNLour[j] != NULL; j++) {
- if (strcmp(cppHNLtest[i], cppHNLour[j]) == 0) {
- return YES;
- }
- }
- }
- }
- else if (r->server->is_virtual) {
- /* virtual servers */
-
- /* check for the names supplied in the VirtualHost directive */
- for(sar = r->server->addrs; sar != NULL; sar = sar->next) {
- if(strcasecmp(sar->virthost, testhost) == 0)
- return YES;
- }
-
- /* check for the virtual-server aliases */
- if (r->server->names != NULL && r->server->names[0] != '\0') {
- names = r->server->names;
- while (*names != '\0') {
- name = getword_conf(r->pool, &names);
- if ((is_matchexp(name) &&
- !strcasecmp_match(testhost, name)) ||
- (strcasecmp(testhost, name) == 0) ) {
- return YES;
- }
- }
- }
- }
- return NO;
-}
-
-static int isaddr(char *host)
-{
- char *cp;
-
- /* Null pointers and empty strings
- are not addresses. */
- if (host == NULL)
- return NO;
- if (*host == '\0')
- return NO;
- /* Make sure it has only digits and dots. */
- for (cp = host; *cp; cp++) {
- if (!isdigit(*cp) && *cp != '.')
- return NO;
- }
- /* If it has a trailing dot,
- don't treat it as an address. */
- if (*(cp-1) == '.')
- return NO;
- return YES;
-}
-
-static char **resolv_ipaddr_list(request_rec *r, char *name)
-{
- char **cppHNL;
- struct hostent *hep;
- int i;
-
- if (isaddr(name))
- hep = gethostbyaddr(name, sizeof(struct in_addr), AF_INET);
- else
- hep = gethostbyname(name);
- if (hep == NULL)
- return NULL;
- for (i = 0; hep->h_addr_list[i]; i++)
- ;
- cppHNL = (char **)palloc(r->pool, sizeof(char *)*(i+1));
- for (i = 0; hep->h_addr_list[i]; i++)
- cppHNL[i] = pstrdup(r->pool,
- inet_ntoa(*((struct in_addr *)
- (hep->h_addr_list[i]))));
- cppHNL[i] = NULL;
- return cppHNL;
-}
-
/*
**
Index: modules/standard/mod_rewrite.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.h,v
retrieving revision 1.39
diff -u -r1.39 mod_rewrite.h
--- mod_rewrite.h 1998/02/24 16:40:52 1.39
+++ mod_rewrite.h 1998/02/27 04:49:26
@@ -430,11 +430,6 @@
static int prefix_stat(const char *path, struct stat *sb);
static void add_env_variable(request_rec *r, char *s);
- /* DNS functions */
-static int is_this_our_host(request_rec *r, char *testhost);
-static int isaddr(char *host);
-static char **resolv_ipaddr_list(request_rec *r, char *name);
-
/* Proxy Module check */
static int is_proxy_available(server_rec *s);
Index: test/vhtest/bin/test1
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/test/vhtest/bin/test1,v
retrieving revision 1.1
diff -u -r1.1 test1
--- test1 1997/11/10 02:11:42 1.1
+++ test1 1998/02/27 04:49:28
@@ -1,15 +1,29 @@
-bin/vhget 127.0.0.1 8080 '' vhost1
-bin/vhget 127.0.0.1 8080 vhost1:8080 vhost1
-bin/vhget 127.0.0.1 8080 vhost2:8080 vhost1
+bin/vhget 127.0.0.1 8080 '' '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 'vhost1:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 'vhost2:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost2:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost1:8080' vhost1
-bin/vhget 127.0.0.2 8080 '' vhost2
-bin/vhget 127.0.0.2 8080 vhost2:8080 vhost2
-bin/vhget 127.0.0.2 8080 vhost1:8080 vhost2
+bin/vhget 127.0.0.2 8080 '' '' vhost2
+bin/vhget 127.0.0.2 8080 vhost2:8080 '' vhost2
+bin/vhget 127.0.0.2 8080 vhost1:8080 '' vhost2
+bin/vhget 127.0.0.2 8080 vhost1:8080 'vhost1:8080' vhost2
+bin/vhget 127.0.0.2 8080 vhost1:8080 'vhost2:8080' vhost2
+bin/vhget 127.0.0.2 8080 vhost2:8080 'vhost2:8080' vhost2
+bin/vhget 127.0.0.2 8080 vhost2:8080 'vhost1:8080' vhost2
-bin/vhget 127.0.0.3 8080 '' vhost3
-bin/vhget 127.0.0.3 8080 vhost3:8080 vhost3
-bin/vhget 127.0.0.3 8080 vhost4:8080 vhost4
+bin/vhget 127.0.0.3 8080 '' '' vhost3
+bin/vhget 127.0.0.3 8080 vhost3:8080 '' vhost3
+bin/vhget 127.0.0.3 8080 vhost3:8080 'vhost3:8080' vhost3
+bin/vhget 127.0.0.3 8080 vhost3:8080 'vhost4:8080' vhost4
+bin/vhget 127.0.0.3 8080 vhost4:8080 '' vhost4
+bin/vhget 127.0.0.3 8080 vhost4:8080 'vhost3:8080' vhost3
+bin/vhget 127.0.0.3 8080 vhost4:8080 'vhost4:8080' vhost4
-bin/vhget 127.0.0.4 8080 '' main
-bin/vhget 127.0.0.4 8080 'vhost1' main
-bin/vhget 127.0.0.4 8080 'vhost2' main
+bin/vhget 127.0.0.4 8080 '' '' main
+bin/vhget 127.0.0.4 8080 'vhost1' '' main
+bin/vhget 127.0.0.4 8080 'vhost1' 'vhost1:8080' main
+bin/vhget 127.0.0.4 8080 'vhost2' '' main
+bin/vhget 127.0.0.4 8080 'vhost2' 'vhost2:8080' main
Index: test/vhtest/bin/test1d
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/test/vhtest/bin/test1d,v
retrieving revision 1.1
diff -u -r1.1 test1d
--- test1d 1997/11/10 02:11:42 1.1
+++ test1d 1998/02/27 04:49:28
@@ -1,15 +1,29 @@
-bin/vhget 127.0.0.1 8080 '' vhost1
-bin/vhget 127.0.0.1 8080 vhost1:8080 vhost1
-bin/vhget 127.0.0.1 8080 vhost2:8080 vhost1
+bin/vhget 127.0.0.1 8080 '' '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 'vhost1:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 'vhost2:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost2:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost1:8080' vhost1
-bin/vhget 127.0.0.2 8080 '' vhost2
-bin/vhget 127.0.0.2 8080 vhost2:8080 vhost2
-bin/vhget 127.0.0.2 8080 vhost1:8080 vhost2
+bin/vhget 127.0.0.2 8080 '' '' vhost2
+bin/vhget 127.0.0.2 8080 vhost2:8080 '' vhost2
+bin/vhget 127.0.0.2 8080 vhost1:8080 '' vhost2
+bin/vhget 127.0.0.2 8080 vhost1:8080 'vhost1:8080' vhost2
+bin/vhget 127.0.0.2 8080 vhost1:8080 'vhost2:8080' vhost2
+bin/vhget 127.0.0.2 8080 vhost2:8080 'vhost2:8080' vhost2
+bin/vhget 127.0.0.2 8080 vhost2:8080 'vhost1:8080' vhost2
-bin/vhget 127.0.0.3 8080 '' vhost3
-bin/vhget 127.0.0.3 8080 vhost3:8080 vhost3
-bin/vhget 127.0.0.3 8080 vhost4:8080 vhost4
+bin/vhget 127.0.0.3 8080 '' '' vhost3
+bin/vhget 127.0.0.3 8080 vhost3:8080 '' vhost3
+bin/vhget 127.0.0.3 8080 vhost3:8080 'vhost3:8080' vhost3
+bin/vhget 127.0.0.3 8080 vhost3:8080 'vhost4:8080' vhost4
+bin/vhget 127.0.0.3 8080 vhost4:8080 '' vhost4
+bin/vhget 127.0.0.3 8080 vhost4:8080 'vhost3:8080' vhost3
+bin/vhget 127.0.0.3 8080 vhost4:8080 'vhost4:8080' vhost4
-bin/vhget 127.0.0.4 8080 '' default1
-bin/vhget 127.0.0.4 8080 'vhost1' default1
-bin/vhget 127.0.0.4 8080 'vhost2' default1
+bin/vhget 127.0.0.4 8080 '' '' default1
+bin/vhget 127.0.0.4 8080 'vhost1' '' default1
+bin/vhget 127.0.0.4 8080 'vhost1' 'vhost1:8080' default1
+bin/vhget 127.0.0.4 8080 'vhost2' '' default1
+bin/vhget 127.0.0.4 8080 'vhost2' 'vhost2:8080' default1
Index: test/vhtest/bin/test2
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/test/vhtest/bin/test2,v
retrieving revision 1.1
diff -u -r1.1 test2
--- test2 1997/11/10 02:11:43 1.1
+++ test2 1998/02/27 04:49:28
@@ -1,28 +1,45 @@
-bin/vhget 127.0.0.1 8080 '' vhost1
-bin/vhget 127.0.0.1 8080 vhost1:8080 vhost1
-bin/vhget 127.0.0.1 8080 vhost2:8080 vhost1
+bin/vhget 127.0.0.1 8080 '' '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost1:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 'vhost2:8080' vhost1
-bin/vhget 127.0.0.1 8081 '' vhost2
-bin/vhget 127.0.0.1 8081 vhost2:8081 vhost2
-bin/vhget 127.0.0.1 8081 vhost1:8081 vhost2
+bin/vhget 127.0.0.1 8081 '' '' vhost2
+bin/vhget 127.0.0.1 8081 vhost2:8081 '' vhost2
+bin/vhget 127.0.0.1 8081 vhost1:8081 'vhost2:8081' vhost2
+bin/vhget 127.0.0.1 8081 vhost1:8081 '' vhost2
+bin/vhget 127.0.0.1 8081 vhost2:8081 'vhost1:8081' vhost2
-bin/vhget 127.0.0.2 8080 '' vhost3
-bin/vhget 127.0.0.2 8080 vhost3:8080 vhost3
-bin/vhget 127.0.0.2 8080 vhost1:8080 vhost3
-bin/vhget 127.0.0.2 8081 '' vhost3
-bin/vhget 127.0.0.2 8081 vhost3:8081 vhost3
-bin/vhget 127.0.0.2 8081 vhost1:8081 vhost3
+bin/vhget 127.0.0.2 8080 '' '' vhost3
+bin/vhget 127.0.0.2 8080 vhost3:8080 '' vhost3
+bin/vhget 127.0.0.2 8080 vhost1:8080 'vhost3:8080' vhost3
+bin/vhget 127.0.0.2 8080 vhost1:8080 '' vhost3
+bin/vhget 127.0.0.2 8080 vhost3:8080 'vhost1:8080' vhost3
+bin/vhget 127.0.0.2 8081 '' '' vhost3
+bin/vhget 127.0.0.2 8081 vhost3:8081 '' vhost3
+bin/vhget 127.0.0.2 8081 vhost3:8081 'vhost1:8081' vhost3
+bin/vhget 127.0.0.2 8081 vhost1:8081 '' vhost3
+bin/vhget 127.0.0.2 8081 vhost1:8081 'vhost3:8081' vhost3
-bin/vhget 127.0.0.3 8080 '' vhost4
-bin/vhget 127.0.0.3 8080 'vhost4:8080' vhost4
-bin/vhget 127.0.0.3 8080 'vhost5:8080' vhost5
+bin/vhget 127.0.0.3 8080 '' '' vhost4
+bin/vhget 127.0.0.3 8080 'vhost4:8080' '' vhost4
+bin/vhget 127.0.0.3 8080 'vhost5:8080' 'vhost4:8080' vhost4
+bin/vhget 127.0.0.3 8080 'vhost5:8080' 'bogus:8080' vhost4
+bin/vhget 127.0.0.3 8080 'vhost5:8080' '' vhost5
+bin/vhget 127.0.0.3 8080 'vhost4:8080' 'vhost5:8080' vhost5
-bin/vhget 127.0.0.3 8081 '' vhost5
-bin/vhget 127.0.0.3 8081 'vhost4:8081' vhost5
-bin/vhget 127.0.0.3 8081 'vhost5:8081' vhost5
-bin/vhget 127.0.0.3 8081 'alt5:8081' vhost5
+bin/vhget 127.0.0.3 8081 '' '' vhost5
+bin/vhget 127.0.0.3 8081 'vhost4:8081' '' vhost5
+bin/vhget 127.0.0.3 8081 'vhost4:8081' 'vhost4:8081' vhost5
+bin/vhget 127.0.0.3 8081 'vhost4:8081' 'bogus:8081' vhost5
+bin/vhget 127.0.0.3 8081 'vhost4:8081' 'alt5:8081' vhost5
+bin/vhget 127.0.0.3 8081 'vhost5:8081' '' vhost5
+bin/vhget 127.0.0.3 8081 'alt5:8081' '' vhost5
-bin/vhget 127.0.0.4 8080 '' main
-bin/vhget 127.0.0.4 8080 'vhost1:8080' main
-bin/vhget 127.0.0.4 8081 '' main
-bin/vhget 127.0.0.4 8081 'vhost1:8081' main
+bin/vhget 127.0.0.4 8080 '' '' main
+bin/vhget 127.0.0.4 8080 'asdf' 'bogus' main
+bin/vhget 127.0.0.4 8080 'vhost1:8080' '' main
+bin/vhget 127.0.0.4 8080 'vhost1:8080' 'vhost2:8081' main
+bin/vhget 127.0.0.4 8081 '' '' main
+bin/vhget 127.0.0.4 8081 'asdf' 'bogus:8080' main
+bin/vhget 127.0.0.4 8081 'vhost1:8081' '' main
Index: test/vhtest/bin/test2d
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/test/vhtest/bin/test2d,v
retrieving revision 1.1
diff -u -r1.1 test2d
--- test2d 1997/11/10 02:11:43 1.1
+++ test2d 1998/02/27 04:49:28
@@ -1,28 +1,45 @@
-bin/vhget 127.0.0.1 8080 '' vhost1
-bin/vhget 127.0.0.1 8080 vhost1:8080 vhost1
-bin/vhget 127.0.0.1 8080 vhost2:8080 vhost1
+bin/vhget 127.0.0.1 8080 '' '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost1:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 'vhost2:8080' vhost1
-bin/vhget 127.0.0.1 8081 '' vhost2
-bin/vhget 127.0.0.1 8081 vhost2:8081 vhost2
-bin/vhget 127.0.0.1 8081 vhost1:8081 vhost2
+bin/vhget 127.0.0.1 8081 '' '' vhost2
+bin/vhget 127.0.0.1 8081 vhost2:8081 '' vhost2
+bin/vhget 127.0.0.1 8081 vhost1:8081 'vhost2:8081' vhost2
+bin/vhget 127.0.0.1 8081 vhost1:8081 '' vhost2
+bin/vhget 127.0.0.1 8081 vhost2:8081 'vhost1:8081' vhost2
-bin/vhget 127.0.0.2 8080 '' vhost3
-bin/vhget 127.0.0.2 8080 vhost3:8080 vhost3
-bin/vhget 127.0.0.2 8080 vhost1:8080 vhost3
-bin/vhget 127.0.0.2 8081 '' vhost3
-bin/vhget 127.0.0.2 8081 vhost3:8081 vhost3
-bin/vhget 127.0.0.2 8081 vhost1:8081 vhost3
+bin/vhget 127.0.0.2 8080 '' '' vhost3
+bin/vhget 127.0.0.2 8080 vhost3:8080 '' vhost3
+bin/vhget 127.0.0.2 8080 vhost1:8080 'vhost3:8080' vhost3
+bin/vhget 127.0.0.2 8080 vhost1:8080 '' vhost3
+bin/vhget 127.0.0.2 8080 vhost3:8080 'vhost1:8080' vhost3
+bin/vhget 127.0.0.2 8081 '' '' vhost3
+bin/vhget 127.0.0.2 8081 vhost3:8081 '' vhost3
+bin/vhget 127.0.0.2 8081 vhost3:8081 'vhost1:8081' vhost3
+bin/vhget 127.0.0.2 8081 vhost1:8081 '' vhost3
+bin/vhget 127.0.0.2 8081 vhost1:8081 'vhost3:8081' vhost3
-bin/vhget 127.0.0.3 8080 '' vhost4
-bin/vhget 127.0.0.3 8080 'vhost4:8080' vhost4
-bin/vhget 127.0.0.3 8080 'vhost5:8080' vhost5
+bin/vhget 127.0.0.3 8080 '' '' vhost4
+bin/vhget 127.0.0.3 8080 'vhost4:8080' '' vhost4
+bin/vhget 127.0.0.3 8080 'vhost5:8080' 'vhost4:8080' vhost4
+bin/vhget 127.0.0.3 8080 'vhost5:8080' 'bogus:8080' vhost4
+bin/vhget 127.0.0.3 8080 'vhost5:8080' '' vhost5
+bin/vhget 127.0.0.3 8080 'vhost4:8080' 'vhost5:8080' vhost5
-bin/vhget 127.0.0.3 8081 '' vhost5
-bin/vhget 127.0.0.3 8081 'vhost4:8081' vhost5
-bin/vhget 127.0.0.3 8081 'vhost5:8081' vhost5
-bin/vhget 127.0.0.3 8081 'alt5:8081' vhost5
+bin/vhget 127.0.0.3 8081 '' '' vhost5
+bin/vhget 127.0.0.3 8081 'vhost4:8081' '' vhost5
+bin/vhget 127.0.0.3 8081 'vhost4:8081' 'vhost4:8081' vhost5
+bin/vhget 127.0.0.3 8081 'vhost4:8081' 'bogus:8081' vhost5
+bin/vhget 127.0.0.3 8081 'vhost4:8081' 'alt5:8081' vhost5
+bin/vhget 127.0.0.3 8081 'vhost5:8081' '' vhost5
+bin/vhget 127.0.0.3 8081 'alt5:8081' '' vhost5
-bin/vhget 127.0.0.4 8080 '' default1
-bin/vhget 127.0.0.4 8080 'vhost1:8080' default1
-bin/vhget 127.0.0.4 8081 '' default2
-bin/vhget 127.0.0.4 8081 'vhost1:8081' default2
+bin/vhget 127.0.0.4 8080 '' '' default1
+bin/vhget 127.0.0.4 8080 'asdf' 'bogus' default1
+bin/vhget 127.0.0.4 8080 'vhost1:8080' '' default1
+bin/vhget 127.0.0.4 8080 'vhost1:8080' 'vhost2:8081' default1
+bin/vhget 127.0.0.4 8081 '' '' default2
+bin/vhget 127.0.0.4 8081 'asdf' 'bogus:8080' default2
+bin/vhget 127.0.0.4 8081 'vhost1:8081' '' default2
Index: test/vhtest/bin/test3
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/test/vhtest/bin/test3,v
retrieving revision 1.1
diff -u -r1.1 test3
--- test3 1997/11/10 02:11:43 1.1
+++ test3 1998/02/27 04:49:28
@@ -1,13 +1,18 @@
-bin/vhget 127.0.0.1 8080 '' vhost1
-bin/vhget 127.0.0.1 8080 vhost1:8080 vhost1
-bin/vhget 127.0.0.1 8080 vhost2:8080 vhost2
-bin/vhget 127.0.0.1 8080 vhost3:8080 vhost3
-bin/vhget 127.0.0.1 8080 vhost4:8080 vhost1
-bin/vhget 127.0.0.1 8080 vhost5:8080 vhost5
+bin/vhget 127.0.0.1 8080 '' '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost1:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost1:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 '' vhost2
+bin/vhget 127.0.0.1 8080 vhost1:8080 'vhost2:8080' vhost2
+bin/vhget 127.0.0.1 8080 vhost3:8080 '' vhost3
+bin/vhget 127.0.0.1 8080 vhost4:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost5:8080 'vhost4:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost5:8080 '' vhost5
-bin/vhget 127.0.0.1 8081 '' vhost2
-bin/vhget 127.0.0.1 8081 vhost1:8081 vhost2
-bin/vhget 127.0.0.1 8081 vhost2:8081 vhost2
-bin/vhget 127.0.0.1 8081 vhost3:8081 vhost3
-bin/vhget 127.0.0.1 8081 vhost4:8081 vhost4
-bin/vhget 127.0.0.1 8081 vhost5:8081 vhost5
+bin/vhget 127.0.0.1 8081 '' '' vhost2
+bin/vhget 127.0.0.1 8081 vhost1:8081 '' vhost2
+bin/vhget 127.0.0.1 8081 vhost3:8081 'vhost1:8081' vhost2
+bin/vhget 127.0.0.1 8081 vhost2:8081 '' vhost2
+bin/vhget 127.0.0.1 8081 vhost3:8081 '' vhost3
+bin/vhget 127.0.0.1 8081 vhost4:8081 '' vhost4
+bin/vhget 127.0.0.1 8081 vhost5:8081 '' vhost5
Index: test/vhtest/bin/test4
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/test/vhtest/bin/test4,v
retrieving revision 1.1
diff -u -r1.1 test4
--- test4 1997/11/10 02:11:44 1.1
+++ test4 1998/02/27 04:49:28
@@ -1,9 +1,13 @@
-bin/vhget 127.0.0.1 8080 '' vhost1
-bin/vhget 127.0.0.1 8080 vhost1:8080 vhost1
-bin/vhget 127.0.0.1 8080 vhost2:8080 vhost2
-bin/vhget 127.0.0.1 8080 vhost3:8080 vhost1
+bin/vhget 127.0.0.1 8080 '' '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost1:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost3:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 '' vhost2
+bin/vhget 127.0.0.1 8080 vhost3:8080 '' vhost1
-bin/vhget 127.0.0.1 8081 '' vhost1
-bin/vhget 127.0.0.1 8081 vhost1:8081 vhost1
-bin/vhget 127.0.0.1 8081 vhost2:8081 vhost2
-bin/vhget 127.0.0.1 8081 vhost3:8081 vhost1
+bin/vhget 127.0.0.1 8081 '' '' vhost1
+bin/vhget 127.0.0.1 8081 vhost1:8081 '' vhost1
+bin/vhget 127.0.0.1 8081 vhost2:8081 'vhost1:8081' vhost1
+bin/vhget 127.0.0.1 8081 vhost2:8081 'vhost3:8081' vhost1
+bin/vhget 127.0.0.1 8081 vhost2:8081 '' vhost2
+bin/vhget 127.0.0.1 8081 vhost3:8081 '' vhost1
Index: test/vhtest/bin/test5
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/test/vhtest/bin/test5,v
retrieving revision 1.1
diff -u -r1.1 test5
--- test5 1997/11/10 02:11:44 1.1
+++ test5 1998/02/27 04:49:28
@@ -1,23 +1,31 @@
-bin/vhget 127.0.0.1 8080 '' vhost1
-bin/vhget 127.0.0.1 8080 vhost1:8080 vhost1
-bin/vhget 127.0.0.1 8080 vhost2:8080 vhost2
-bin/vhget 127.0.0.1 8080 vhost3:8080 vhost1
+bin/vhget 127.0.0.1 8080 '' '' vhost1
+bin/vhget 127.0.0.1 8080 vhost1:8080 '' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'bogus' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 'vhost1:8080' vhost1
+bin/vhget 127.0.0.1 8080 vhost2:8080 '' vhost2
+bin/vhget 127.0.0.1 8080 vhost1:8080 'vhost2:8080' vhost2
+bin/vhget 127.0.0.1 8080 vhost3:8080 '' vhost1
-bin/vhget 127.0.0.2 8080 '' vhost3
-bin/vhget 127.0.0.2 8080 'vhost3:8080' vhost3
-bin/vhget 127.0.0.2 8080 'vhost1:8080' vhost3
+bin/vhget 127.0.0.2 8080 '' '' vhost3
+bin/vhget 127.0.0.2 8080 'vhost3:8080' '' vhost3
+bin/vhget 127.0.0.2 8080 'vhost1:8080' 'bogus' vhost3
+bin/vhget 127.0.0.2 8080 'vhost1:8080' '' vhost3
-bin/vhget 127.0.0.3 8080 '' default1
-bin/vhget 127.0.0.3 8080 'vhost1:8080' default1
+bin/vhget 127.0.0.3 8080 '' '' default1
+bin/vhget 127.0.0.3 8080 'vhost1:8080' '' default1
+bin/vhget 127.0.0.3 8080 'asdf' 'bogus' default1
-bin/vhget 127.0.0.1 8081 '' vhost4
-bin/vhget 127.0.0.1 8081 vhost1:8081 vhost4
-bin/vhget 127.0.0.1 8081 vhost2:8081 vhost4
-bin/vhget 127.0.0.1 8081 vhost3:8081 vhost4
+bin/vhget 127.0.0.1 8081 '' '' vhost4
+bin/vhget 127.0.0.1 8081 vhost1:8081 '' vhost4
+bin/vhget 127.0.0.1 8081 vhost2:8081 'vhost1:8080' vhost4
+bin/vhget 127.0.0.1 8081 vhost2:8081 '' vhost4
+bin/vhget 127.0.0.1 8081 vhost3:8081 '' vhost4
-bin/vhget 127.0.0.2 8081 '' vhost5
-bin/vhget 127.0.0.2 8081 'vhost3:8081' vhost5
-bin/vhget 127.0.0.2 8081 'vhost1:8081' vhost5
+bin/vhget 127.0.0.2 8081 '' '' vhost5
+bin/vhget 127.0.0.2 8081 'vhost3:8081' '' vhost5
+bin/vhget 127.0.0.2 8081 'vhost1:8081' 'vhost3:8081' vhost5
+bin/vhget 127.0.0.2 8081 'vhost1:8081' '' vhost5
-bin/vhget 127.0.0.3 8081 '' default2
-bin/vhget 127.0.0.3 8081 'vhost1:8081' default2
+bin/vhget 127.0.0.3 8081 '' '' default2
+bin/vhget 127.0.0.3 8081 'bogus' 'asdf' default2
+bin/vhget 127.0.0.3 8081 'vhost1:8081' '' default2
Index: test/vhtest/bin/vhget
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/test/vhtest/bin/vhget,v
retrieving revision 1.1
diff -u -r1.1 vhget
--- vhget 1997/11/10 02:11:45 1.1
+++ vhget 1998/02/27 04:49:28
@@ -4,18 +4,20 @@
use strict;
use Socket;
-# vhget ipaddr port hostheader expect
+# vhget ipaddr port hostheader absurihost expect
-$#ARGV == 3 || die "usage: $0 ipaddr port hostheader expect\n";
+$#ARGV == 4 || die "usage: $0 ipaddr port hostheader absurihost expect\n";
my ($remote,$port, $iaddr, $paddr, $proto, $line);
-$remote = shift;
-$port = shift;
-my $hostheader = shift;
-my $expect = shift;
+my ($hostheader, $expect, $absurihost);
-printf "%-20s %-20s %-15s: ", "$remote:$port", "'$hostheader'", "'$expect'";
+($remote, $port, $hostheader, $absurihost, $expect) = @ARGV;
+if ($absurihost ne '') {
+ $absurihost = "http://$absurihost";
+}
+
+printf "%-20s %-20s %-20s %-15s: ", "$remote:$port", "'$hostheader'", "'$absurihost'", "'$expect'";
if ($port =~ /\D/) {
$port = getservbyname($port, 'tcp');
@@ -29,16 +31,18 @@
my $oldfh = select(SOCK); $| = 1; select($oldfh);
+$proto = ($absurihost ne '') ? "HTTP/1.1" : "HTTP/1.0";
+
if ($hostheader ne '') {
print SOCK <<EOR;
-GET /vhost.txt HTTP/1.0\r
+GET $absurihost/vhost.txt $proto\r
Host: $hostheader\r
Connection: close\r
\r
EOR
} else {
print SOCK <<EOR;
-GET /vhost.txt HTTP/1.0\r
+GET $absurihost/vhost.txt $proto\r
Connection: close\r
\r
EOR
@@ -56,8 +60,9 @@
chomp($line);
-my $death = "$remote:$port with " .
- ( $hostheader eq '' ? "no Host:" : "Host: $hostheader" )
+my $death = "$remote:$port with "
+ . ( $hostheader eq '' ? "no Host:" : "Host: $hostheader" )
+ . ( $absurihost eq '' ? " no absuri" : " and absuri $absurihost" )
. " expected $expect, but got $line\n";
if ($line eq $expect) {
print "passed\n";
Re: [PATCH] fix absoluteURI support and other things
Posted by Randy Terbush <ra...@Covalent.NET>.
This looks like a significant improvement Dean. I'll try to do some
real testing on this in the next 24 hours.
Dean Gaudet <dg...@arctic.org> writes:
> [This patch will include a mmn bump when committed.]
>
> Presently apache 1.2 and 1.3 don't handle absoluteURIs in the same manner
> that they handle name or ip virtual hosts. There is code duplication
> (with bugs), and there is a mixture of proxy specific code in the core. In
> particular the check_fulluri() function is wrong, and contains a DoS
> attack.
>
> If you ignore absoluteURIs our configuration language takes the approach
> that no run-time DNS should be necessary. This is a good approach... and
> so I'm extending it to absoluteURIs as well. We now treat an absoluteURI
> that is not a proxy request as equivalent to a "Host:" header with the
> same contents.
>
> To do this a few changes were made to request_rec. r->hostlen was removed
> -- it was replaced by r->absolute_uri which is the functionality that is
> really needed. r->absolute_uri is the complete, unmodified absoluteURI
> from the request if one was present; it is NULL otherwise. We need the
> unmodified uri for proxying and we had kludges elsewhere to protect r->uri
> if r->proxyreq was set. Adding r->absolute_uri removes those kludges.
>
> That lets us delay setting r->proxyreq until the translate_names phase.
> Which is when a proxy gets its hands on the request and declares if the
> request is actually a proxy request or not.
>
> While hacking on this I fixed a bunch of other related things. In
> particular I added matches_request_vhost() which is used to remove code
> from mod_rewrite which did vhost matching (including another DoS because
> it would use DNS). I merged in a memory/time saving patch for ServerAlias
> from Chia-liang Kao. I made a few small tweaks to http_vhost.c.
>
> I may have to tweak TRACE a bit more before I commit, but the rest of this
> I'm solid with. It passes the newly enhanced vhost test suite. The proxy
> still seems to work, and mod_rewrite seems to still work where I had to
> tweak it.
>
> I don't know why someone would want to... but with this patch you can
> run a proxy inside a name-virtual host. I'm not kidding. I don't think
> we want to advertise that as a supported configuration...
>
> I mentioned that I doing this work a few times in the past few weeks... I
> hope folks like the way I did it. I'm closer to thinking that vhosts
> are done done done for good ;)
>
> Dean
>
RE: [PATCH] fix absoluteURI support and other things
Posted by Lars Eilebrecht <La...@unix-ag.org>.
According to Dean Gaudet:
> This is a valid config?
Yes, of course... there are several people out there who are using
Apache as a web-server and proxy on the same hostname:port.
> gah! Ok well I'll work on it. At least you're
> only complaining about new bugs... I'm mostly concerned that folks are
> happy with the approach.
Yeah, it's ok.
ciao...
--
Lars Eilebrecht - Every program is either trivial
sfx@unix-ag.org - or it contains at least one bug.
http://www.si.unix-ag.org/~sfx/
RE: [PATCH] fix absoluteURI support and other things
Posted by Dean Gaudet <dg...@arctic.org>.
This is a valid config? gah! Ok well I'll work on it. At least you're
only complaining about new bugs... I'm mostly concerned that folks are
happy with the approach. In fact it's pretty easy to fix this one -- I
just need to do a request_matches_vhost() in proxy_trans().
Dean
On Fri, 27 Feb 1998, Lars Eilebrecht wrote:
> According to Dean Gaudet:
>
> > [This patch will include a mmn bump when committed.]
>
> -1, because your patch breaks normal page-serving if
> ProxyRequests is turned on.
>
> If I turn on ProxyRequests I'm getting status 400 'bad request'
> on normal "GET /foo/bar" requests and on requests where
> the absolute URI is the server itself. Proxy requests to
> other hosts work as expected.
>
> I'm getting the same results when using an extra ip-based
> vhost configured as a proxy.
>
>
> ciao...
> --
> Lars Eilebrecht - I still miss Windows...
> sfx@unix-ag.org - but my aim is getting better.
> http://www.si.unix-ag.org/~sfx/
>
>
RE: [PATCH] fix absoluteURI support and other things
Posted by Lars Eilebrecht <La...@unix-ag.org>.
According to Dean Gaudet:
> [This patch will include a mmn bump when committed.]
-1, because your patch breaks normal page-serving if
ProxyRequests is turned on.
If I turn on ProxyRequests I'm getting status 400 'bad request'
on normal "GET /foo/bar" requests and on requests where
the absolute URI is the server itself. Proxy requests to
other hosts work as expected.
I'm getting the same results when using an extra ip-based
vhost configured as a proxy.
ciao...
--
Lars Eilebrecht - I still miss Windows...
sfx@unix-ag.org - but my aim is getting better.
http://www.si.unix-ag.org/~sfx/