ODK aggregate and apache’s mod proxy

SCENARIO:

I needed to publish an ODK aggregate server that was already deployed in a virtual machine. So it was not possible to add it to the existing web server. The problem that I found was that only one public IP address was available, so all the http requests were routed to the “main” web server.

Two solutions were founded:

  • Use the mikrotik’s proxy feature to route depending on the incoming subdomain.
  • Use apache in the main server as a reverse proxy.

The first option was discarded due to the technical difficulty and because I didn’t want to overload the tiny processor of the mikrotik routerboard. So the second one was the chosen.

Network's diagram

 

PREREQUISITES:

  • An apache server already running where all the external http requests are headed to.
  • An ODK server running on another private IP address.

STEPS:

  • To use the proxy feature of the apache server you need to activate the main proxy module (“proxy”) and the submodule (“proxy_http”).
a2enmod proxy
a2enmod proxy_http
  • Create a new apache virtual host in /etc/apache2/sites-available/ and use the code below:
<VirtualHost *:80>
        ServerAdmin user@domain
        #USE YOUR OWN DOMAIN, IT'S CRTICAL
        ServerName subdomain.domain.

        ProxyRequests Off
        ProxyPreserveHost On
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>
        ProxyErrorOverride On
        ProxyPass / http://10.0.0.10/
        ProxyPassReverse / http://10.0.0.10/
     

</VirtualHost>
  • Activate the virtual host that you’ve just created, in this case “example.conf”.
a2ensite example.conf
  • Restart apache
service apache2 restart

And it should work!

Attention:

I had some issues trying to download/upload forms to the ODK aggregate server until I added the line below in the configuration file of the virtual host.

ProxyPreserveHost On

Links: