Hi,
I just setup Twisted to provide virtual hosting with Zope3. Run the program with:
twistd --python=application.py
Optionally with the --nodaemon option. Script is attached and pasted below.
Enjoy!
"""
A reverse proxy that runs on the server, dispatching requests to various other
underlying services or applications.
"""
from twisted.application import internet, service
from twisted.web import proxy, server, vhost, rewrite
# this is the base of our site, a container of vhosts root = vhost.NameVirtualHost()
# list of subdomains mapped to Zope3
virtualHostZopeList = [
'subdomain1',
'subdomain2'
]
# set up each one of the subdomains as a reverse proxy on the server for v in virtualHostZopeList: path = v+'/++vh++http:'+v+'.my-site.org:80/++/' rp = proxy.ReverseProxyResource('localhost', 8080, path) root.addHost(v+'.my-site.org', rp)
# create an application to handle the forwarding of requests application = service.Application('twisted')
# our application is a set of multiple services sc = service.IServiceCollection(application)
# create our proxy TCP server, and add it to the services i = internet.TCPServer(80, server.Site(root)) i.setServiceParent(sc)
""" A reverse proxy that runs on the server, dispatching requests to various other underlying services or applications. """ from twisted.application import internet, service from twisted.web import proxy, server, vhost, rewrite
# this is the base of our site, a container of vhosts root = vhost.NameVirtualHost() # list of subdomains mapped to Zope3 virtualHostZopeList = [ 'subdomain1', 'subdomain2' ] # set up each one of the subdomains as a reverse proxy on the server for v in virtualHostZopeList: path = v+'/++vh++http:'+v+'.my-site.org:80/++/' rp = proxy.ReverseProxyResource('localhost', 8080, path) root.addHost(v+'.my-site.org', rp) # create an application to handle the forwarding of requests application = service.Application('twisted') # our application is a set of multiple services sc = service.IServiceCollection(application) # create our proxy TCP server, and add it to the services i = internet.TCPServer(80, server.Site(root)) i.setServiceParent(sc)
_______________________________________________ Zope3-dev mailing list [EMAIL PROTECTED] Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com