You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2002/05/30 12:19:50 UTC

cvs commit: apache-1.3/src/modules/proxy proxy_http.c

minfrin     02/05/30 03:19:49

  Modified:    src      CHANGES
               src/modules/proxy proxy_http.c
  Log:
  Add X-Forwarded-Host and X-Forwarded-Server to X-Forwarded-For
  to the proxy.
  Submitted by:	Thomas Eibner <th...@stderr.net>
  Reviewed by:	Graham Leggett
  
  Revision  Changes    Path
  1.1825    +3 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1824
  retrieving revision 1.1825
  diff -u -r1.1824 -r1.1825
  --- CHANGES	29 May 2002 20:39:15 -0000	1.1824
  +++ CHANGES	30 May 2002 10:19:48 -0000	1.1825
  @@ -1,5 +1,8 @@
   Changes with Apache 1.3.25
   
  +  *) Add X-Forwarded-Host and X-Forwarded-Server to X-Forwarded-For
  +     to the proxy. [Thomas Eibner <th...@stderr.net>]
  +
     *) Fix a problem in mod_proxy: it would not set the number of bytes
        transferred, so other modules could not access the value from
        the request_rec->bytes_sent field.
  
  
  
  1.99      +24 -4     apache-1.3/src/modules/proxy/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_http.c,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- proxy_http.c	21 Apr 2002 21:16:39 -0000	1.98
  +++ proxy_http.c	30 May 2002 10:19:49 -0000	1.99
  @@ -345,11 +345,31 @@
               );
       }
   
  -    /*
  -     * Add X-Forwarded-For: so that the upstream has a chance to determine,
  -     * where the original request came from.
  +    /* the X-* headers are only added if we are a reverse
  +     * proxy, otherwise we would be giving away private information.
        */
  -    ap_table_mergen(req_hdrs, "X-Forwarded-For", r->connection->remote_ip);
  +    if (r->proxyreq == PROXY_PASS) {
  +        const char *buf;
  +
  +        /*
  +         * Add X-Forwarded-For: so that the upstream has a chance to determine,
  +         * where the original request came from.
  +         */
  +        ap_table_mergen(req_hdrs, "X-Forwarded-For", r->connection->remote_ip);
  +
  +        /* 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->server_hostname);
  +    } 
   
       /* we don't yet support keepalives - but we will soon, I promise! */
       ap_table_set(req_hdrs, "Connection", "close");