From: Martin Kraemer Date: Tue, 13 Jan 2004 16:11:55 +0000 (+0000) Subject: If the proxy was enabled, and UseCanonicalHostname was off, X-Git-Tag: pre_ajp_proxy~806 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f0ca54f433918ded82c797a61666553c6a7bb7bb;p=apache 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102320 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/proxy_http.c b/modules/proxy/proxy_http.c index 7dc8e87275..4df949dd9b 100644 --- a/modules/proxy/proxy_http.c +++ b/modules/proxy/proxy_http.c @@ -509,6 +509,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", @@ -516,12 +524,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) ); } @@ -902,19 +910,27 @@ 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) ); }