NginX is a fast, lightweight alternative to Apache, and can be used as a front-end for serving Tomcat pages. The docs on how to set this up are scattered all over the web, so I thought I'd bring them together here.

First of all, I have the following in my Tomcat server.xml file:

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
        <Context path="/dspace" docBase="/path/to/dspace/webapps/jspui" debug="0"
                reloadable="true" cachingAllowed="false"
                allowLinking="true" />
        <Context path="/xmlui" docBase="/path/to/dspace/webapps/xmlui" debug="0"
                reloadable="true" cachingAllowed="false"
                allowLinking="true" />
        <Context path="/oai" docBase="/path/to/dspace/webapps/oai" debug="0"
                reloadable="true" cachingAllowed="false"
                allowLinking="true" />
</Host>

This gives me the flexibility to use both the JSPUI and the XMLUI if needed.

I have DSpace running on a subdomain, "http://collections.example.com/dspace/". This is configured as a virtual host in NginX.


server {
	listen 111.222.11.22:80;
	server_name collections.example.com;
	access_log /var/log/collections.example.com/access_log;
	error_log /var/log/collections.example.com/error_log;
	root /path/to/dspace/webapps/;
	
        location / {
                deny all;
        }

	location /dspace/ {
		index index.jsp;
		proxy_set_header X-Forwarded-Host $host;
		proxy_set_header X-Forwarded-Server $host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_pass http://111.222.11.22:8180/dspace/;
		proxy_redirect	http://111.222.11.22:8180/dspace/ http://collections.example.com/dspace/;
		
		proxy_buffering off;
		proxy_store 	off;

		proxy_connect_timeout 120;
		proxy_send_timeout    120;
		proxy_read_timeout    120;
	}

	location /oai/ {
		proxy_set_header X-Forwarded-Host $host;
		proxy_set_header X-Forwarded-Server $host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_pass http://111.222.11.22:8180/oai/;
		proxy_redirect	http://111.222.11.22:8180/oai/ http://collections.example.com/oai/;
		
		proxy_buffering off;
		proxy_store 	off;

		proxy_connect_timeout 120;
		proxy_send_timeout    120;
		proxy_read_timeout    120;

	}

	location /xmlui/ {
		proxy_set_header X-Forwarded-Host $host;
		proxy_set_header X-Forwarded-Server $host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_pass http://111.222.11.22:8180/xmlui/;
		proxy_redirect	http://111.222.11.22:8180/xmlui/ http://collections.example.com/xmlui/;
		
		proxy_buffering off;
		proxy_store 	off;

		proxy_connect_timeout 120;
		proxy_send_timeout    120;
		proxy_read_timeout    120;
		
	}
}

I've set the proxy timeouts somewhat high since we're uploading large files into our DSpace instance. So far it's been working great. The only other thing that I've changed is to add

client_max_body_size 2000m;

to the "http" section of my nginx.conf file. This sets the uploaded file limit to 2GB.