Zope IIS Proxy

Spinner Wiki

SourceForge.net Logo
As an example of how to use a code sample in a Wiki page (at least that's my excuse), here's a prototype ASP script that can be used to integrate Zope into IIS. It works sort of the same way that you can integrate Zope into Apache with mod_proxy. - BruceDodsonNew Page

'This script is installed in /zope.asp
'ASPFool.dll is installed as a filter.

Const zopeurl = "http://localhost:8080"

zopepath = Mid(Request.ServerVariables("PATH_INFO"), Len(Request.ServerVariables("SCRIPT_NAME")) + 1)

if Len(Request.QueryString) then
  zopepath = zopepath & "?" & Request.QueryString
end if

Sub CopyContentType()
  On Error Resume Next
  Dim contentType
  contentType = xmlhttp.getResponseHeader("Content-Type")
  if Len(contentType) then
    Response.ContentType = contentType
  end if
End Sub

Sub CopyResponseHeader(headerName)
  On Error Resume Next
  Dim hearderVal
  headerVal = xmlhttp.getResponseHeader(headerName)
  if Len(headerVal) then
    Response.AddHeader headerName, headerVal
  end if
End Sub

Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

xmlhttp.open Request.ServerVariables("REQUEST_METHOD"), zopeurl & zopepath, false
'BASIC authentication won't work, because the IIS auth filters get first crack at it.
'Request.ServerVariables("AUTH_USER"), Request.ServerVariables("AUTH_PASSWORD")

'Response.Write Request.ServerVariables("REQUEST_METHOD") 'zopeurl & zopepath
' copy request headers?  yes (selectively), but not for prototype.
' Request.ServerVariables("ALL_RAW")
' xmlhttp.setRequestHeader(header, value)

if (Request.TotalBytes > 0) then
end if

Response.Status = xmlhttp.status & " " & xmlhttp.statusText

CopyResponseHeader "Content-Length"

' copy response headers?  yes (selectively) but not for prototype.
' xmlhttp.getResponseHeader / getAllResponseHeaders
' Response.AddHeader HeaderName, HeaderVaue

Response.BinaryWrite xmlhttp.responseBody

' Another thing for after prototype would be to go in async
' mode so the whole body doesn't need to be read and written
' in one gulp.


As you can tell that's just a prototype - some functionality and some of the finer points are omitted. However, it does allow you to have URLs like http://my.server.net/zope.asp/myzopeapp/somepage.zpt get proxied to http://localhost:8080/myzopeapp/somepage.zpt on the same server, where Zope is assumed to be running.

Note, this is different from just redirecting to Zope, as it does not require the port Zope HTTP port to be open on the firewall.

You do need an IIS filter to go with this: aspfool.dll. I could have sworn I got my copy with SourceForgeProjectSourceForge Project: viewcvs, but I can't find a link anywhere on their site or elsewhere on the web. ASPFool is what convinces ASP to recognize that URI with zope.asp in the middle, as an ASP script. If anyone has a link to it, please update this page.

Also, of course, this could be used for other "reverse proxy" scenarios besides Zope. For example, SourceForgeProjectSourceForge Project: roundup could be proxied the same way, just by renaming it roundup.asp and changing the port number if appropriate.

The above is just a prototype. For anything useful like Roundup or an actual Zope app, the above script would need to be fleshed out to transfer more headers (like expires and cookies) through the proxy. There are some starting points in the comments.

Related pages: Unclassified
This page last edited on 29 April 2004 at 13:26 GMT