[Twisted-Python] ReverseProxy with additional headers

Pawel Lewicki lewicki at provider.pl
Wed Apr 19 18:59:24 MDT 2006


Hello,
I try to make a simple reverse proxy service that would add authentication
info for the Plone site.
Is it a good direction or not? I'm not sure if I modify outgoing or incoming
headers.

Pawel

----------------------
from twisted.internet import reactor
from twisted.web import proxy, server

class MyReverseProxyResource(proxy.ReverseProxyResource):

    def render(self, request):
        request.setHeader('__ac_name','username')
        request.setHeader('__ac_password','password')
        return proxy.ReverseProxyResource.render(self, request)

    def getChild(self, path, request):
        return MyReverseProxyResource(self.host, self.port,
self.path+'/'+path)


site = server.Site(MyReverseProxyResource('localhost', 80, '/'))
reactor.listenTCP(8080, site)
reactor.run()







More information about the Twisted-Python mailing list