From: Stefan Eissing Date: Sun, 19 Feb 2017 21:02:26 +0000 (+0000) Subject: On the trunk: X-Git-Tag: 2.5.0-alpha~647 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=757e5a0ad615a8ae9074acf041a14ace1c5b401f;p=apache On the trunk: mod_proxy_http2: support for ProxyPreserverHost directive. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1783693 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 014d4ed415..a1e9bdadea 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_proxy_http2: support for ProxyPreserverHost directive. [Stefan Eissing] + *) mod_proxy_fcgi: Add ProxyFCGISetEnvIf to fixup CGI environment variables just before invoking the FastCGI. [Eric Covener, Jacob Champion] diff --git a/modules/http2/h2_proxy_session.c b/modules/http2/h2_proxy_session.c index 7d28699a37..49476e965b 100644 --- a/modules/http2/h2_proxy_session.c +++ b/modules/http2/h2_proxy_session.c @@ -697,6 +697,7 @@ static apr_status_t open_stream(h2_proxy_session *session, const char *url, apr_uri_t puri; const char *authority, *scheme, *path; apr_status_t status; + proxy_dir_conf *dconf; stream = apr_pcalloc(r->pool, sizeof(*stream)); @@ -715,14 +716,22 @@ static apr_status_t open_stream(h2_proxy_session *session, const char *url, status = apr_uri_parse(stream->pool, url, &puri); if (status != APR_SUCCESS) return status; - + scheme = (strcmp(puri.scheme, "h2")? "http" : "https"); - authority = puri.hostname; - if (!ap_strchr_c(authority, ':') && puri.port - && apr_uri_port_of_scheme(scheme) != puri.port) { - /* port info missing and port is not default for scheme: append */ - authority = apr_psprintf(stream->pool, "%s:%d", authority, puri.port); + + dconf = ap_get_module_config(r->per_dir_config, &proxy_module); + if (dconf->preserve_host) { + authority = r->hostname; } + else { + authority = puri.hostname; + if (!ap_strchr_c(authority, ':') && puri.port + && apr_uri_port_of_scheme(scheme) != puri.port) { + /* port info missing and port is not default for scheme: append */ + authority = apr_psprintf(stream->pool, "%s:%d", authority, puri.port); + } + } + /* we need this for mapping relative uris in headers ("Link") back * to local uris */ stream->real_server_uri = apr_psprintf(stream->pool, "%s://%s", scheme, authority); diff --git a/modules/http2/mod_proxy_http2.c b/modules/http2/mod_proxy_http2.c index f9a3b31cc7..437fecc1c5 100644 --- a/modules/http2/mod_proxy_http2.c +++ b/modules/http2/mod_proxy_http2.c @@ -577,6 +577,10 @@ run_connect: /* New conection: set a note on the connection what CN is * requested and what protocol we want */ if (ctx->p_conn->ssl_hostname) { + ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, ctx->owner, + "set SNI to %s for (%s)", + ctx->p_conn->ssl_hostname, + ctx->p_conn->hostname); apr_table_setn(ctx->p_conn->connection->notes, "proxy-request-hostname", ctx->p_conn->ssl_hostname); }