]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
backport 1927036 from trunk
authorEric Covener <covener@apache.org>
Mon, 7 Jul 2025 12:05:49 +0000 (12:05 +0000)
committerEric Covener <covener@apache.org>
Mon, 7 Jul 2025 12:05:49 +0000 (12:05 +0000)
  tolerate missing host header in h2 proxy

Reviewed By: jorton, icing, rpluem

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1927044 13f79535-47bb-0310-9956-ffa450edef68

modules/http2/h2_proxy_session.c

index d5d0f9bc6bc6d0d178aeb15aa3a260a797963cb7..2cfbb5f5d4b240dc2611b95e983eefed5c454d42 100644 (file)
@@ -850,6 +850,18 @@ static apr_status_t open_stream(h2_proxy_session *session, const char *url,
     dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
     if (dconf->preserve_host) {
         authority = orig_host;
+        if (!authority) {
+            /* Duplicate mod_proxy behaviour if ProxyPreserveHost is
+             * used but an "HTTP/0.9" request is received without a
+             * Host: header */
+            authority = r->server->server_hostname;
+            ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(10511)
+                          "HTTP/0.9 request (with no host line) "
+                          "on incoming request and preserve host set "
+                          "forcing hostname to be %s for uri %s",
+                          authority, r->uri);
+            apr_table_setn(r->headers_in, "Host", authority);
+        }
     }
     else {
         authority = puri.hostname;