[zorp] Rewriting URLs for reverse proxy WAS: Reverse proxy + side stacking broken (config?) for large pages?

KOVACS Krisztian hidden at balabit.hu
Thu Dec 15 08:58:09 CET 2011


Hi David,

On 12/12/2011 10:27 PM, David Yerger wrote:
> Another question:  is it possible to rewrite a URL like
> 
>   Def filterURL(self, method, url, version):
>     If ("http://foo.bar.com:5500/fubar" in url):
>        self.request_url = "http://<inside address>/bugzilla"
>        self.session.setServer(SockAddrInet("<inside address>", 80))
> 
> for my reverse proxy?  I am now getting an error
> 
>     Firefox can't establish a connection to the server at <inside
> address>:5500.
> 
> So I probably want somewhere else in the object hierarchy
> (self.session.owner.proxy.request_url doesn't work either...)

Maybe you're missing the return HTTP_REQ_ACCEPT from the end of your filterURL() method?

I've just checked it and setting self.request_url seems to be working just fine for me,

- 8< -
MatcherPolicy(name="DNS", matcher=DNSMatcher(hosts=("google.com")))

class TestHttpProxy(HttpProxyNonTransparent):
    def config(self):
        HttpProxyNonTransparent.config(self)
        self.request["GET"] = (HTTP_REQ_POLICY, self.checkurl)
        self.request_header["Host"] = (HTTP_HDR_POLICY, self.checkhosthdr)

    def __post_config__(self):
        # check client IP address with DNSMatcher
        matcher = getMatcher("DNS")
        if matcher.checkMatch(self.session.client_address.ip_s):
            proxyLog(self, HTTP_DEBUG, 3, "Matcher matched")

    def checkurl(self, method, url, version):
        proxyLog(self, HTTP_DEBUG, 5, "Checking URL; url='%s'", (url,))
        self.request_url = "http://google.com/"
        return HTTP_REQ_ACCEPT

    def checkhosthdr(self, name, value):
        if name == "Host":
                proxyLog(self, HTTP_DEBUG, 5, "Processing header; name='%s', value='%s'", (name, value))

        return HTTP_HDR_ACCEPT

    def connectServer(self):
        # check server IP address with DNSMatcher
        stream = HttpProxyNonTransparent.connectServer(self)
        matcher = getMatcher("DNS")
        if matcher.checkMatch(self.session.server_address.ip_s):
            proxyLog(self, HTTP_DEBUG, 3, "Server matched")
        return stream

def http_test():
        Service("http1", TestHttpProxy, router=InbandRouter())
        Dispatcher(transparent=FALSE, bindto=DBSockAddr(SockAddrInet("127.0.0.1", 8765), protocol=ZD_PROTO_TCP), service="http1")
- 8< -

-- 
KOVACS Krisztian



More information about the zorp mailing list