[zorp-hu] Zorp 3.3.6 - port valasztas hostnev alapjan

Farkas Dániel linux at farkasdaniel.hu
2011. Feb. 20., V, 23:21:25 CET


Sziasztok!

A multkor mar sikerult beuzemelni a zorpot, aminek nagyon orulok.
Most vettem eszre (amikor elesben akartam hasznalni az iranyitasokat),
hogy nem megy.

Minden a regi config alapjan van, hibat nem dob, debugban sem latok
tobbet. Esetleg valtozhatott valami a kifejezesekben, vagy valamit
elirtam?

Mindenkepp a belso 127.0.0.1:50080-as cimre iranyitja a kereseket,
nem veszi figyelembe a hostnevenkent megadott tobbi portot.

Koszi!
D.



################ CONFIG : #####################

from Zorp.Core import *
from Zorp.Plug import *
from Zorp.Http import *
from Zorp.Ftp import *

Zorp.firewall_name = 'zorp at moya'

InetZone("site-net", "x.y.x.y/24",
         # list of allowed outbound services, '*' matches anything
         #outbound_services=["intra_http", "intra_ftp", "intra_cvs"],
         outbound_services=["intra_http"],
                
         # list of allowed inbound services, '*' matches anything
         inbound_services=["intra_http"])
                
InetZone("local", "127.0.0.0/8",
         inbound_services=["*"],
         outbound_services=["*"])
        
InetZone("internet", "0.0.0.0/0",
         inbound_services=["intra_http"],
         outbound_services=["intra_http"])

#
# Let's define a transparent http proxy, which rewrites the user_agent
# header to something different.
#

class IntraHttp(HttpProxy):

        def config(self):
                HttpProxy.config(self)
                self.transparent_mode = TRUE
                self.request_timeout = 1800000
                self.request_header["Host"] = (HTTP_HDR_POLICY, self.TargetByHostHeader)
                self.request["GET"] = (HTTP_REQ_POLICY, self.filterURL)
                self.request["POST"] = (HTTP_REQ_POLICY, self.filterURL)                


        def filterURL(self, method, url, version):
            self.setRequestHeader("X_HOST", self.session.client_address.ip_s)
            log("http.info", 3, "%s: GET: %s" % (self.session.session_id, url))
            return HTTP_REQ_ACCEPT


        def filterHost (self, hdr_name, hdr_value):
            return HTTP_HDR_ACCEPT


        def TargetByHostHeader(self, name, value):
            if(value == "domain1.hu" or value == "www.domain1.hu" or
            value == "www2.domain2.hu"
            ):
                    self.session.server_address = SockAddrInet("127.0.0.1" ,50083) # APACHE 3
                    return HTTP_HDR_ACCEPT
            elif(value == 'domain3.hu' or value == 'domain4.hu'
            ):
                    self.session.server_address = SockAddrInet("127.0.0.1" ,50081)
                    return HTTP_HDR_ACCEPT
            else:
                    self.session.server_address = SockAddrInet("127.0.0.1" ,50080)
                    return HTTP_HDR_ACCEPT


# zorp_http instance
def zorp_http():
        
        # create services
        Service("intra_http", IntraHttp, router=DirectedRouter(SockAddrInet("127.0.0.1", 50080)))
        Listener(SockAddrInet("x.y.x.y", 80), "intra_http")




További információk a(z) zorp-hu levelezőlistáról