]> granicus.if.org Git - apache/commitdiff
On the trunk:
authorStefan Eissing <icing@apache.org>
Tue, 2 May 2017 15:16:43 +0000 (15:16 +0000)
committerStefan Eissing <icing@apache.org>
Tue, 2 May 2017 15:16:43 +0000 (15:16 +0000)
mod_proxy_http2: adding support for Reverse Proxy Request headers.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1793525 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/http2/h2_proxy_session.c

diff --git a/CHANGES b/CHANGES
index 687cf65e6b6cc28487272a72f1348cf7111278f9..c23e529f8d1f60672bedc023856521badb440a52 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_proxy_http2: adding support for Reverse Proxy Request headers.
+     [Stefan Eissing]
+     
   *) Evaluate nested If/ElseIf/Else configuration blocks.
      [Luca Toscano, Jacob Champion]
 
index 5a66f2ab6930d944fc11b6e5f39a77555b938cdb..66a878a0ee5220c23fbfb6200ab391d27a65cd84 100644 (file)
@@ -742,6 +742,32 @@ static apr_status_t open_stream(h2_proxy_session *session, const char *url,
     h2_proxy_req_make(stream->req, stream->pool, r->method, scheme,
                 authority, path, r->headers_in);
 
+    if (dconf->add_forwarded_headers) {
+        if (PROXYREQ_REVERSE == r->proxyreq) {
+            const char *buf;
+
+            /* Add X-Forwarded-For: so that the upstream has a chance to
+             * determine, where the original request came from.
+             */
+            apr_table_mergen(stream->req->headers, "X-Forwarded-For",
+                             r->useragent_ip);
+
+            /* Add X-Forwarded-Host: so that upstream knows what the
+             * original request hostname was.
+             */
+            if ((buf = apr_table_get(r->headers_in, "Host"))) {
+                apr_table_mergen(stream->req->headers, "X-Forwarded-Host", buf);
+            }
+
+            /* Add X-Forwarded-Server: so that upstream knows what the
+             * name of this proxy server is (if there are more than one)
+             * XXX: This duplicates Via: - do we strictly need it?
+             */
+            apr_table_mergen(stream->req->headers, "X-Forwarded-Server",
+                             r->server->server_hostname);
+        }
+    }
+    
     /* Tuck away all already existing cookies */
     stream->saves = apr_table_make(r->pool, 2);
     apr_table_do(add_header, stream->saves, r->headers_out, "Set-Cookie", NULL);