Post History:

Animals Matter to Me

Apache reverse proxy to SWI-Prolog

It’s the second day of my chain, working towards having up and running a blog application written in Prolog itself. I spent some time tonight getting Apache to talk to directly to a demo app running on SWI-Prolog. While I consider myself capable around an Apache config, I still had to spend a good amount of time reading about proxy modules and options. It seemed that a simple “reverse proxy” is what I needed to start off with.

  • With a forward proxy the client knows which destination URL it wants and has been specifically configured to use a proxy server to get it.
  • With a reverse proxy, the client requests normal paths on the proxy server and a proxied result will be served to the client seamlessly. The client does not know that a proxy is involved, it all occurs on the server side.

Since the requests will be normal HTTP requests from anyone on the web, the reverse proxy is what I’m looking for. To setup the reverse proxy, I added the following lines to a virtual host configuration file:

ProxyRequests Off

<Proxy *>
  Order deny, allow
  Allow from all

ProxyPass /
ProxyPassReverse /

The Prolog application, a simple Hello World program that responds to HTTP requests, was listening on port 8000, hence the ProxyPass address. It didn’t work immediately. I started off with a 500 error, and the following line in the error log:

[warn] proxy: No protocol handler was valid for the URL /. If you
are using a DSO version of mod_proxy, make sure the proxy submodules 
are included in the configuration using LoadModule.

After some Googling, this was fixed by linking the proxy-http module file in /etc/apache2/mods-available to /etc/apache2/mods-enabled.

ln -s /etc/apache2/mods-available/proxy_http.load \

I’m sure eventually I will have some more complex proxy setup for load balancing, serving static files, etc. but this config gets me by for now. My next steps for tomorrow will be putting a small Prolog application serving some simple content on the site, and reading about SWI-Prolog’s unit testing features, which I didn’t get around to tonight.


Jiri Sedlacek on March 13, 2009 9:43AM

Great stuff. I have an application in Prolog I want to make public over web but I was kind of scared to configure Apache to do it. It would be great to have an Amazon image file with everything set up for Prolog. That way anyone could start a Prolog based server on Amazon cloud in a snap.

Jeff Dallien on March 16, 2009 2:14PM

I don't really know much about the Amazon computing stuff but once I am confident that my solution works well enough I will look into creating an image. How would putting a Prolog application on the web work? Maybe there's a need for a sort of generic front end that could be designed so the app itself doesn't need to care about the HTML, if possible.

Adding new comments is currently disabled.