You are not logged in Log in Join
You are here: Home » Members » andym » Zope behind IIS » howto_view

Log in
Name

Password

 

Zope behind IIS

 

Created by andym . Last modified 2004-11-22 12:19:53.

Using Zope behind IIS

Note: Enfold Systems now sells a full featured proxy for IIS that is designed for Plone, it features caching, compression and much more. It also removes the need to hook up 404's, which will make your logs much better. For more information see: EEP

Note: This has now been much improved by Hyperlogica, take a look here: http://www.zope.org/Members/hiperlogica/ASP404.

Files: error.asp

Running Zope behind IIS is a pain. PCGI sucks and is single threaded, but thats the only real option people have. Most Zope solutions involve Apache and that rocks 'cos Apache is great but for consultants or people who have to use IIS there are no great solutions.

One solution was proposed by David Carter-Tod here: http://www.wc.cc.va.us/dtod/zope/. Essentially you send your 404 error to an ASP script which then sends it on to Zope. I had an afternoon and to find a solution so I tried implementing his suggestion. After finding a few issues I thought I would post a how to...

  • Added a Virtual Host Monster to my root. The VHM handles all the Zope URL rewriting you might need.
  • Stuck the script from David's site in my IIS server. Changed the error message for a 404 to be a url, in my case /Zope/error.asp. I have since modified this script and you should be able to take the script error.asp and just customise the urls.

Notes

I made the following changes to Davids original script:

  • Changed the urls so Virtual Host Monster likes it. For example the original is intranet.activestate.com, this gets changed to intranet.activestate.com:1500/VirtualHostBase/https/intranet.activestate.com:443/VirtualHostRoot. Zope runs on port 1500 and IIS runs on port 443 (SSL).
  • Use Server.CreateObject("Microsoft.XMLHTTP"), I couldn't get MSDN to explain to me why, but for IIS 5.0 on Win 2k Server, thats the magic object Id.
  • Changed to use binary reads and writes.
  • Banged my head against the XMLHTTP object, because for some reason it was caching every request. Im sure our server is messed up, but it wouldn't be sending the requests to Zope, it would happily cache them indefinitely. I read through MSDN for a long time and still couldn't find a solution. I set cache-control headers all through Zope to no avail. In the end I threw in a stupid hack to make each request have a unique query string appended to the end of it. XMLHTTP doesnt cache it then.
Problems:
  • The stupid caching thing mentioned above.
  • Posting some data with a resulting redirect seems to fail. I cant get IIS to tell me what the error might be, this occurs for example on editing a Wiki. Is it the post or the redirect it doesnt like? I found the answer and altered ZWiki. ZWiki was returning a http:// url (because it was using SERVER_URL) XMLHTTP raised that as an error (A redirect request will change a non-secure to a secure connection). For more error codes go here.
  • Performance this is in asp so you are doing a lot of work
  • Name clashes, it relies on the file not exisiting in IIS so the 404 is generated, which is another request.
The real solution is an ISAPI filter that does the proxing, but I couldn't do that in the afternoon I had.
Comments from: Mike Sharp, thanks!

First, this line:

Set objXMLHttp = Server.CreateObject("Microsoft.XMLHTTP") ...uses wininet, the old parser API, and isn't server safe. MSXML 3.0 had the server safe XMLHTTPRequest object, but IIRC, it's only functional with the service pack. Anyway, the correct progID (version independant) is:

Set objXMLHttp = Server.CreateObject("Msxml2.SERVERXMLHTTP")

Using this object gives you a couple of really nice new features, too. For one thing, you can set timeouts, and there are methods for asyncronously polling for a response. You can also set and read headers. Here's an MSDN article on the new object: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmobjxmldomserverxmlhttp.asp

MSXML 4.0 of the parser has improved it even more.

Also, your caching problems might be solved with this line at the beginning of error.asp:

Response.Expires = -1000


Comments from: Chaitra on trying not to get

I set the if-modified-since tag in the request header and gave some old date..so its always greater that the date specified..so it gets the new response...and it works fine :)

pIXMLHTTPRequest->setRequestHeader("If-Modified-Since","Tue, 11 Jul 2000
18:23:51 GMT");