[ZWeb] Patch: Preserving the original IP for Apache 2.0.x

Andreas Lauser and@poware.org
Tue, 30 Jul 2002 14:22:46 +0200


--------------Boundary-00=_YDA2L5A3VP4IR9UZP9JZ
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi!

I'm not sure whether this is the right place to post stuff like this, but=
=20
ok...

I've modified the patch to preserve the original IP of an request when us=
ing=20
apache as proxy (See http://www.zope.org/Members/unfo/apache_zserver_ssl)=
 to=20
make it compile with apache 2.0.39. You may want to update that document.

To apply the patch try 'patch -p0 ProxyVia-apache2.diff' in the directory=
=20
where the HTTPD sources reside. (I couldn't figure out how to persuade di=
ff=20
to produce the same output format as the original patch. Any Hints?)

mfg
  AND

--=20
Equal bytes for women.

--------------Boundary-00=_YDA2L5A3VP4IR9UZP9JZ
Content-Type: text/x-diff;
  charset="us-ascii";
  name="ProxyVia-apache2.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="ProxyVia-apache2.diff"

--- modules/proxy/proxy_http.c	Tue Jul 30 14:06:13 2002
+++ modules/proxy/proxy_http.c	Tue Jul 30 13:43:44 2002
@@ -494,20 +494,9 @@
         /* Block all outgoing Via: headers */
         apr_table_unset(r->headers_in, "Via");
     } else if (conf->viaopt != via_off) {
-        /* Create a "Via:" request header entry and merge it */
         /* Generate outgoing Via: header with/without server comment: */
-        apr_table_mergen(r->headers_in, "Via",
-                         (conf->viaopt == via_full)
-                         ? apr_psprintf(p, "%d.%d %s%s (%s)",
-                                        HTTP_VERSION_MAJOR(r->proto_num),
-                                        HTTP_VERSION_MINOR(r->proto_num),
-                                        ap_get_server_name(r), server_portstr,
-                                        AP_SERVER_BASEVERSION)
-                         : apr_psprintf(p, "%d.%d %s%s",
-                                        HTTP_VERSION_MAJOR(r->proto_num),
-                                        HTTP_VERSION_MINOR(r->proto_num),
-                                        ap_get_server_name(r), server_portstr)
-        );
+        ap_table_setn(r->headers_in, "Via", ap_psprintf(p, "%s",
+          ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME, NULL)));
     }
 
     /* X-Forwarded-*: handling
@@ -779,7 +768,7 @@
             /* handle Via header in response */
             if (conf->viaopt != via_off && conf->viaopt != via_block) {
                 /* create a "Via:" response header entry and merge it */
-                ap_table_mergen(r->headers_out, "Via",
+/*                ap_table_mergen(r->headers_out, "Via",
                                 (conf->viaopt == via_full)
                                 ? apr_psprintf(p, "%d.%d %s%s (%s)",
                                                HTTP_VERSION_MAJOR(r->proto_num),
@@ -792,7 +781,13 @@
                                                HTTP_VERSION_MINOR(r->proto_num),
                                                ap_get_server_name(r),
                                                server_portstr)
-                );
+					       );
+*/
+            ap_table_mergen(r->headers_out, "Via",
+                           ap_psprintf(p, "%s",
+                                       ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME, NULL)
+                           ));
+	
             }
 
             /* cancel keepalive if HTTP/1.0 or less */

--------------Boundary-00=_YDA2L5A3VP4IR9UZP9JZ--