IIS Reverse Proxy scipt (like mod_proxy)

Discussion in 'ASP General' started by aspguru, Nov 19, 2003.

  1. aspguru

    aspguru Guest

    I have been hunting around recently for reverse proxy solutions to
    work with IIS. An example use for this would be to put outlook web
    access on your multi host IIS box on port 80 or an application like
    sitecope on IIS's port 80. There are many 3rd party solutions below
    some including ISAPI filters.

    http://www.at32.com/doc/rproxy.htm
    http://www.isapirewrite.com/
    http://www.octagate.com/

    I've managed to sort of half fudge this with a single ASP script. If
    you name it default.asp and point your default 404 error message to a
    URL of "/default.asp" it will kick in for every request on the site.
    The upshot of all this is it's like a virtual directory but instead of
    pointing to another local folder, UNC path or URL redirect it feeds
    another site by proxy.

    I have tested this with Outlook Web Access and seems to work (just
    need to pass username and password arguments on the objHTTP.send line)

    The script admittedly is far from perfect for example not handling
    form posts , login credential requests so I would welcome comments /
    enhancements.

    'BEGIN SCRIPT
    <%
    option explicit
    'on error resume next

    dim strmirrorURL
    dim strRequest
    dim strrequestfile
    dim intlen
    dim strRmethod

    strmirrorURL = "http://server.to.be.mirrored.com:80"
    strrmethod = request.servervariables("REQUEST_METHOD")
    if left(request.querystring,3) = "404" then
    'we have page request other than this one, parse script request and
    path out of querystring

    intlen = 11 + len(request.servervariables("SERVER_NAME")) + 1 + _
    len(request.servervariables("SERVER_PORT"))
    strrequestfile = right(request.querystring,len(request.querystring)-
    intlen)
    end if
    strrequest = strmirrorurl & strrequestfile

    call Proxy(strrequest,strRmethod)

    sub Proxy(strRequest,strRmethod)
    dim ObjHTTP
    dim lngResolve
    dim lngConnect
    dim lngReceive
    dim lngSend

    lngResolve =5000
    lngConnect = 5000
    lngReceive = 5000
    lngSend = 5000
    set objHTTP = server.CreateObject("Msxml2.serverXMLHTTP")


    objHttp.setTimeouts lngResolve, lngConnect, lngSend, lngReceive

    objHTTP.open strRmethod, strRequest, false
    objHTTP.send

    Response.ContentType = objhttp.getResponseHeader("Content-Type")
    Response.BinaryWrite objhttp.responsebody
    set objhttp = nothing
    end Sub
    %>
    'END SCRIPT
     
    aspguru, Nov 19, 2003
    #1
    1. Advertising

  2. aspguru

    Ken Schaefer Guest

    A bit like ISA Server?
    http://www.microsoft.com/isaserver/default.asp

    Cheers
    Ken


    --
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "aspguru" <> wrote in message
    news:...
    : I have been hunting around recently for reverse proxy solutions to
    : work with IIS. An example use for this would be to put outlook web
    : access on your multi host IIS box on port 80 or an application like
    : sitecope on IIS's port 80. There are many 3rd party solutions below
    : some including ISAPI filters.
    :
    : http://www.at32.com/doc/rproxy.htm
    : http://www.isapirewrite.com/
    : http://www.octagate.com/
    :
    : I've managed to sort of half fudge this with a single ASP script. If
    : you name it default.asp and point your default 404 error message to a
    : URL of "/default.asp" it will kick in for every request on the site.
    : The upshot of all this is it's like a virtual directory but instead of
    : pointing to another local folder, UNC path or URL redirect it feeds
    : another site by proxy.
    :
    : I have tested this with Outlook Web Access and seems to work (just
    : need to pass username and password arguments on the objHTTP.send line)
    :
    : The script admittedly is far from perfect for example not handling
    : form posts , login credential requests so I would welcome comments /
    : enhancements.
    :
    : 'BEGIN SCRIPT
    : <%
    : option explicit
    : 'on error resume next
    :
    : dim strmirrorURL
    : dim strRequest
    : dim strrequestfile
    : dim intlen
    : dim strRmethod
    :
    : strmirrorURL = "http://server.to.be.mirrored.com:80"
    : strrmethod = request.servervariables("REQUEST_METHOD")
    : if left(request.querystring,3) = "404" then
    : 'we have page request other than this one, parse script request and
    : path out of querystring
    :
    : intlen = 11 + len(request.servervariables("SERVER_NAME")) + 1 + _
    : len(request.servervariables("SERVER_PORT"))
    : strrequestfile = right(request.querystring,len(request.querystring)-
    : intlen)
    : end if
    : strrequest = strmirrorurl & strrequestfile
    :
    : call Proxy(strrequest,strRmethod)
    :
    : sub Proxy(strRequest,strRmethod)
    : dim ObjHTTP
    : dim lngResolve
    : dim lngConnect
    : dim lngReceive
    : dim lngSend
    :
    : lngResolve =5000
    : lngConnect = 5000
    : lngReceive = 5000
    : lngSend = 5000
    : set objHTTP = server.CreateObject("Msxml2.serverXMLHTTP")
    :
    :
    : objHttp.setTimeouts lngResolve, lngConnect, lngSend, lngReceive
    :
    : objHTTP.open strRmethod, strRequest, false
    : objHTTP.send
    :
    : Response.ContentType = objhttp.getResponseHeader("Content-Type")
    : Response.BinaryWrite objhttp.responsebody
    : set objhttp = nothing
    : end Sub
    : %>
    : 'END SCRIPT
     
    Ken Schaefer, Nov 19, 2003
    #2
    1. Advertising

  3. aspguru

    aspguru Guest

    aspguru, Nov 19, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. A.M

    IIS Reverse Proxy

    A.M, Dec 15, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    13,619
    Jeff Cochran
    Dec 15, 2003
  2. JAVA scipt needed

    , Nov 11, 2003, in forum: Java
    Replies:
    4
    Views:
    401
    Jezuch
    Nov 12, 2003
  3. Ramesh Singh

    Printing Scipt not working in Windows XP

    Ramesh Singh, May 8, 2008, in forum: ASP General
    Replies:
    1
    Views:
    128
    Bob Barrows [MVP]
    May 8, 2008
  4. Aquila

    Rails with mod_proxy

    Aquila, May 5, 2005, in forum: Ruby
    Replies:
    1
    Views:
    169
    Premshree Pillai
    May 7, 2005
  5. fhscobey
    Replies:
    1
    Views:
    149
    Brian McCauley
    Mar 21, 2006
Loading...

Share This Page