IIS Reverse Proxy scipt (like mod_proxy)

A

aspguru

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
 
K

Ken Schaefer

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

Cheers
Ken


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top