Hello everyone, I am deploying twisted as a web server for my site. I am looking into possibilities of reverse proxying.
I have the following code right now hooked up to my reactor for django. I am using comet, and I realize that I absolutely must use port 80 hence I am looking into possibilities of reverse proxying. On this site, I found the following example:
# Django setup
sys.path.append("shoout_web")
os.environ['DJANGO_SETTINGS_MODULE'] = 'shoout_web.settings'
def wrapper_WSGIRootWrapper():
# Build the wrapper first
generic = WSGIHandler()
def HandlerWrapper(environ, start_response):
environ['engine'] = engine
return generic(environ, start_response)
# Thread and Allowing Ctrl-C to get you out cleanly:
pool = threadpool.ThreadPool()
pool.start()
reactor.addSystemEventTrigger('after', 'shutdown', pool.stop)
return wsgi.WSGIResource(reactor, pool, HandlerWrapper)
WSGIRoot = wrapper_WSGIRootWrapper()
# Reverse Proxy
class Simple(Resource):
isLeaf = False
def getChild(self, name, request):
if name == "orbited":
print "orbited"
return proxy.ReverseProxyResource('localhost', 12345, "/"+name)
else:
return WSGIRoot.getChildWithDefault(name, request)
# Attaching proxy + django
log_dir = './.log'
if not os.path.exists(log_dir):
os.makedirs(log_dir)
reactor.listenTCP(DJANGO_PORT, server.Site(Simple(), logPath=os.path.join(log_dir, '.django.log')))
My trouble is I don't really know what to fill in in the else part of that second code part. I looked at text_proxy on twisted-src and there weren't substantial examples for this. Any help?