From: Colm MacCarthaigh Date: Wed, 19 Apr 2006 10:02:04 +0000 (+0000) Subject: Merge r102320 from trunk: X-Git-Tag: 2.0.57~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e5ce23c69c8443672cdd150dd94364df0d844fe;p=thirdparty%2Fapache%2Fhttpd.git Merge r102320 from trunk: If the proxy was enabled, and UseCanonicalHostname was off, then the Via: header would report not the proxy hosts's ServerName (or any of its configured VHosts's names) as it should, but the *origin hosts*'s name. Now it reports its ServerName. Author: martin git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.0.x@395190 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index db5be5d572b..0fee9f17fef 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.0.57 + *) mod_proxy: Report the proxy server name correctly in the "Via:" header, + when UseCanonicalName is Off. PR 11971. [Martin Kraemer] + *) mod_isapi: Various trivial code-fixes to permit mod_isapi to load and run on Unix. [William Wrowe] diff --git a/STATUS b/STATUS index 481ef78f154..d7e28e88838 100644 --- a/STATUS +++ b/STATUS @@ -135,15 +135,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: http://svn.apache.org/viewcvs?rev=395079&view=rev +1: colm, wrowe, niq - *) mod_proxy: Fix PR 11971 (HTTP proxy header "Via" with wrong hostname - if ServerName not set or UseCanonicalName Off) by - backporting r102320. - Trunk version of patch: - http://svn.apache.org/viewcvs?rev=102320&view=rev - 2.0.x version of patch: - http://issues.apache.org/bugzilla/attachment.cgi?id=18037 - +1: rpluem, jim, niq - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ please place SVN revisions from trunk here, so it is easy to identify exactly what the proposed changes are! Add all new diff --git a/modules/proxy/proxy_http.c b/modules/proxy/proxy_http.c index d4906fcaa6f..4cfe486d4a3 100644 --- a/modules/proxy/proxy_http.c +++ b/modules/proxy/proxy_http.c @@ -925,6 +925,14 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r, /* 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", @@ -932,12 +940,12 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r, ? 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) ); } @@ -1410,19 +1418,28 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, /* 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) ); }