Hello everyone,
If the configuration sets
UseCanonicalHostname Off
and enables the proxy, then the Via: header will report not the proxy
hosts's ServerName (or any of its configured VHosts's names) as it
should, but the *origin hosts*'s name.
Example: if I go thru a local apache-2.1 proxy on port 8007 to
httpd.apache.org, then the Via header (sent or returned) looks like
this:
Via: 1.0 httpd.apache.org:8007 (Apache/2.1.0-dev)
The reason is that the function ap_get_server_name() returns
r->hostname (which is the origin server's for proxy requests) if
UseCanonicalHostname is off
The attached patch checks for r->hostname equality (because the proxy
has no access to core.c's per_dir_config).
Martin
--
<[EMAIL PROTECTED]> | Fujitsu Siemens
Fon: +49-89-636-46021, FAX: +49-89-636-47655 | 81730 Munich, Germany
Index: modules/proxy/proxy_http.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_http.c,v
retrieving revision 1.177
diff -u -r1.177 proxy_http.c
--- modules/proxy/proxy_http.c 9 Jan 2004 03:04:41 -0000 1.177
+++ modules/proxy/proxy_http.c 12 Jan 2004 11:19:24 -0000
@@ -509,6 +509,14 @@
/* Block all outgoing Via: headers */
apr_table_unset(r->headers_in, "Via");
} else if (conf->viaopt != via_off) {
+ const char *server_name = ap_get_server_name(r);
+ /* If USE_CANONICAL_NAME_OFF was configured for the proxy virtual host,
+ * then the server name returned by ap_get_server_name() is the
+ * origin server name (which does make too much sense with Via: headers)
+ * so we use the proxy vhost's name instead.
+ */
+ if (server_name == r->hostname)
+ server_name = r->server->server_hostname;
/* Create a "Via:" request header entry and merge it */
/* Generate outgoing Via: header with/without server comment: */
apr_table_mergen(r->headers_in, "Via",
@@ -516,12 +524,12 @@
? apr_psprintf(p, "%d.%d %s%s (%s)",
HTTP_VERSION_MAJOR(r->proto_num),
HTTP_VERSION_MINOR(r->proto_num),
- ap_get_server_name(r), server_portstr,
+ server_name, server_portstr,
AP_SERVER_BASEVERSION)
: apr_psprintf(p, "%d.%d %s%s",
HTTP_VERSION_MAJOR(r->proto_num),
HTTP_VERSION_MINOR(r->proto_num),
- ap_get_server_name(r), server_portstr)
+ server_name, server_portstr)
);
}
@@ -905,19 +913,27 @@
/* handle Via header in response */
if (conf->viaopt != via_off && conf->viaopt != via_block) {
+ const char *server_name = ap_get_server_name(r);
+ /* If USE_CANONICAL_NAME_OFF was configured for the proxy virtual
host,
+ * then the server name returned by ap_get_server_name() is the
+ * origin server name (which does make too much sense with Via:
headers)
+ * so we use the proxy vhost's name instead.
+ */
+ if (server_name == r->hostname)
+ server_name = r->server->server_hostname;
/* create a "Via:" response header entry and merge it */
apr_table_mergen(r->headers_out, "Via",
(conf->viaopt == via_full)
? apr_psprintf(p, "%d.%d %s%s (%s)",
HTTP_VERSION_MAJOR(r->proto_num),
HTTP_VERSION_MINOR(r->proto_num),
- ap_get_server_name(r),
+ server_name,
server_portstr,
AP_SERVER_BASEVERSION)
: apr_psprintf(p, "%d.%d %s%s",
HTTP_VERSION_MAJOR(r->proto_num),
HTTP_VERSION_MINOR(r->proto_num),
- ap_get_server_name(r),
+ server_name,
server_portstr)
);
}