Package: libapache-mod-rpaf
Version: 0.5-2inra1
Severity: normal
Tags: patch

libapache-mod-rpaf can work with multiple IPs in the X-Forwarded-For
header, it always use the last one as the original IP.

However it doesn't behave like this for the X-Forwarded-Host header
although this one can also have multiple hostnames in it.

As a result, RPAFsethostname will not work correctly, it will set the
Host to "server2, server1" instead of server1.
In my case the virtualhost server1 doesn't the recognize the host and so will 
always replies with a redirect
to http://server1 which is a problem.

The following patch allows libapache-mod-rpaf to process
X-Forwarded-Host like X-Forwarded-For. 
It's only for the apache 1.3 module, I can have a look at the apache 2
module if you consider this patch to be included.


--- mod_rpaf.c  2004-03-17 16:47:30.000000000 +0100
+++ mod_rpaf.c.new      2007-03-27 16:16:29.000000000 +0200
@@ -151,10 +151,16 @@
             r->connection->remote_addr.sin_addr.s_addr = 
inet_addr(r->connection->remote_ip);
             if (cfg->sethostname) {
                 const char *hostvalue;
-                if (hostvalue = ap_table_get(r->headers_in, 
"X-Forwarded-Host")) {
+               if (hostvalue = ap_table_get(r->headers_in, 
"X-Forwarded-Host")) {
+                   array_header *arr = ap_make_array(r->pool, 0, 
sizeof(char*));
+                   while (*hostvalue && (val = ap_get_token(r->pool, 
&hostvalue, 1))) {
+                           *(char **)ap_push_array(arr) = ap_pstrdup(r->pool, 
val);
+                           if (*hostvalue != '\0')
+                                   ++hostvalue;
+                   }
                     /* 2.0 proxy frontend or 1.3 => 1.3.25 proxy frontend */
-                    ap_table_set(r->headers_in, "Host", ap_pstrdup(r->pool, 
hostvalue));
-                    r->hostname = ap_pstrdup(r->pool, hostvalue);
+                    ap_table_set(r->headers_in, "Host", ap_pstrdup(r->pool, 
((char **)arr->elts)[((arr->nelts)-1)]));
+                    r->hostname = ap_pstrdup(r->pool, ((char 
**)arr->elts)[((arr->nelts)-1)]);
                     ap_update_vhost_from_headers(r);
                 } else if (hostvalue = ap_table_get(r->headers_in, "X-Host")) {
                     /* 1.3 proxy frontend with mod_proxy_add_forward */



-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.16-2-686-smp-pea
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages libapache-mod-rpaf depends on:
ii  apache-common         1.3.33-6sarge3     support files for all Apache webse
ii  libc6                 2.3.2.ds1-22sarge4 GNU C Library: Shared libraries an

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to