download
#
# An example of doing virtualhosts in Zorp
#
from Zorp.Core import *
from Zorp.Http import *
Zorp.firewall_name = 'zorp@example.net'
InetZone("site-net", "192.168.1.0/24",
outbound_services=["intra_http"],
inbound_services=[])
InetZone("internet", "0.0.0.0/0",
inbound_services=["*"],
outbound_services=[])
class MyHttp(HttpProxy):
def setServerAddr(self, host, port):
if host == 'www1.domain.hu':
self.session.setServer(SockAddrInet('1.2.3.4', 80))
elif host == 'www2.domain.hu':
self.session.setServer(SockAddrInet('2.3.4.5', 80))
def virtualhost():
Service('http', MyHttp, router=InbandRouter(), snat=ForgeClientSourceNAT())
Listener(SockAddrInet('3.4.5.6', 8080), 'http')
|