Production use - Proxying eXist behind a Web Server

From a security perspective, it is recognised best practice to proxy Web Application Servers behind dedicated Web Servers, and eXist is no exception.

Some other nice side-effects of proxying eXist behind a Web Server include -

Unified web namespace

You can map eXist or an application build atop eXist into an existing web namespace. If your website is - http://www.mywebsite.com, then your eXist application could be mapped into http://www.mywebsite.com/myapplication/.

Virtual Hosting

Providing your Web Server supports Virtual Hosting, then you should be able to proxy many URLs from different domains onto different eXist REST URLs which may belong to one or more eXist instances. This in effect allows a single eXist instance to perform virtual hosting.

Examples are provided for -

Nginx

A very small but extremely poweful Web Server which is also very simple to configure. It powers some of the biggest sites on the Web.

Apache HTTPD

The most prolific Web Server used on the web.

1. Example 1 - Proxying a Web Domain Name to an eXist Collection

In this example we look at how to proxy a web domain name onto an eXist Collection. We make the following assumptions -

  1. http://www.mywebsite.com is our website domain name address
  2. eXist is running in standalone mode (i.e. http://localhost:8088/) on the same host as the Web Server (i.e. http://localhost:80/)
  3. /db/mywebsite.com is the eXist collection we want to proxy
  4. Web Server access logging will be written to /srv/www/vhosts/mywebsite.com/logs/access.log

1.1. Nginx

This needs to be added to the http section of the nginx.conf file -

server {
    listen 80;
    server_name *.mywebsite.com;
    charset utf-8;
    access_log /srv/www/vhosts/mywebsite.com/logs/access.log;

    location / {
        proxy_pass http://localhost:8088/db/mywebsite.com/;
    }
}
                
September 2009
The eXist Project
Adam Retter