On Wed, May 29, 2002 at 07:20:17PM +0200, Graham Leggett wrote:
> Thomas Eibner wrote:
> 
> > Ah yes, X-Forwarded-For is there, but not the two others there is in
> > 2.0 (X-Forwarded-Server and X-Forwared-Host) I read in the source that
> > someone thinks it needs to go into the Via header instead. And as I can
> > read from the source, X-Forwarded-For is only sent when it's a reverse
> > proxy request in 2.0, and always sent in 1.3.
> 
> Oh yes... I remember now (memory rusty). If you can get a patch in
> before tomorrow, should be cool :)

Inline patch here, but I'm wondering if you want the X-Forwarded-For
header to be stuck inside the conditional too? 

Index: proxy_http.c
===================================================================
RCS file: /home/cvspublic/apache-1.3/src/modules/proxy/proxy_http.c,v
retrieving revision 1.98
diff -u -r1.98 proxy_http.c
--- proxy_http.c        21 Apr 2002 21:16:39 -0000      1.98
+++ proxy_http.c        29 May 2002 17:04:38 -0000
@@ -350,6 +350,20 @@
      * where the original request came from.
      */
     ap_table_mergen(req_hdrs, "X-Forwarded-For", r->connection->remote_ip);
+    if (r->proxyreq == PROXY_PASS) {
+        const char *buf;
+        /* Add X-Forwarded-Host: so that upstream knows what the
+         * original request hostname was.
+         */
+        if ((buf - ap_table_get(r->headers_in, "Host"))) {
+            ap_table_mergen(req_hdrs, "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?
+         */
+        ap_table_mergen(req_hdrs, "X-Forwarded-Server", r->server_hostname);
+    } 
 
     /* we don't yet support keepalives - but we will soon, I promise! */
     ap_table_set(req_hdrs, "Connection", "close");


-- 
  Thomas Eibner <http://thomas.eibner.dk/> DnsZone <http://dnszone.org/>
  mod_pointer <http://stderr.net/mod_pointer> <http://photos.eibner.dk/>
  !(C)<http://copywrong.dk/>                  <http://apachegallery.dk/>
          Putting the HEST in .COM <http://www.hestdesign.com/>

Reply via email to