Production use - Proxying eXist-db behind a Web Server
Abstract
From a security perspective, it is recognised best practice to proxy Web Application Servers behind dedicated Web Servers, and eXist-db is no exception.
Some other nice side-effects of proxying eXist-db behind a Web Server include -
- Unified web namespace
You can map eXist-db or an application build atop eXist-db into an existing web namespace. If your website is - http://www.mywebsite.com, then your eXist-db 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-db REST URLs which may belong to one or more eXist-db instances. This in effect allows a single eXist-db 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.
Example 1 - Proxying a Web Domain Name to an eXist-db Collection
In this example we look at how to proxy a web domain name onto an eXist-db Collection. We make the following assumptions -
- http://www.mywebsite.com is our website domain name address
- eXist-db is running in standalone mode (i.e. http://localhost:8088/) on the same host as the Web Server (i.e. http://localhost:80/)
- /db/mywebsite.com is the eXist-db collection we want to proxy
- Web Server access logging will be written to /srv/www/vhosts/mywebsite.com/logs/access.log
Nginx
This needs to be added to the http section of the nginx.conf file -
Apache HTTPD
This needs to be added to your httpd.conf -