]> granicus.if.org Git - apache/commitdiff
If the proxy was enabled, and UseCanonicalHostname was off,
authorMartin Kraemer <martin@apache.org>
Tue, 13 Jan 2004 16:11:55 +0000 (16:11 +0000)
committerMartin Kraemer <martin@apache.org>
Tue, 13 Jan 2004 16:11:55 +0000 (16:11 +0000)
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

modules/proxy/proxy_http.c

index 7dc8e8727537c553743c0e6cd87099350fc4f35a..4df949dd9b0c322105232653036a57ddde71c14b 100644 (file)
@@ -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)
                 );
             }