[Twisted-Python] ReverseProxy doesn't send X-Forwarded-For header

Lance Kurisaki lkurisaki at ambiron.net
Mon Jun 2 19:24:57 EDT 2003


The ReverseProxy doesn't send an X-Forwarded-For header field with the
real client's IP address. This convention is used by Squid, Pound, and
other proxies to communicate the real client's IP address to the
destination server.

I added the header with the following patch.

					Lance

Index: twisted/web/proxy.py
===================================================================
RCS file: /cvs/Twisted/twisted/web/proxy.py,v
retrieving revision 1.12
diff -c -r1.12 proxy.py
*** twisted/web/proxy.py        2 Jun 2003 18:14:59 -0000       1.12
--- twisted/web/proxy.py        2 Jun 2003 23:14:59 -0000
***************
*** 178,183 ****
--- 178,184 ----

      def render(self, request):
          request.received_headers['host'] = self.host
+       request.received_headers["x-forwarded-for"] = request.client[1]
          request.content.seek(0, 0)
          clientFactory = ProxyClientFactory(request.method, self.path,
                                       request.clientproto,




More information about the Twisted-Python mailing list