I hacked on Jay Love's mod_webkit to make it support connections to multiple servers.

Also, It will now return status 500, rather than an empty document. In the future it will also run a specified command intended to restart the servers, and return a specified error page.


# This is a sample httpd.conf section.  I just include this file in
# my main httpd.conf with an Include directive.
# ie. Include /Webware/WebKit/mod_webkit/apache.conf

LoadModule webkit_module modules/
AddModule mod_webkit.c

AddType text/psp .psp
AddHandler psp-handler .psp

<Location /WKMod>
# WebKitServer replaces Jay's WKServer directive
# this is an example of load balancing among 8 servers on 2 machines
WebKitServer localhost 8086
WebKitServer otherhost 8086
WebKitServer localhost 8087
WebKitServer otherhost 8087
WebKitServer localhost 8088
WebKitServer otherhost 8088
WebKitServer localhost 8089
WebKitServer otherhost 8089

# the number of connection attempts before giving up
# this should be large enough to hit each server a few times
WebKitRetries 16

# FUTURE: mod_webkit will spawn this script after a failed request (e.g. after 16 retries for a single request)
WebKitSpawnOnFail /path/to/restart/script

# FUTURE: mod_webkit will have apache return this page after a failed request
WebKitErrorPage  /path/to/errorpage.html

SetHandler webkit-handler

The Code

Feedback appreciated. Help wanted.

I am very much out of my element working on this stuff. This is my first attempt at doing socket code in C. It is also my first time working with the Apache API. If someone else wants to help, I do welcome it.