Hey everyone!
I wanted to share my experience of setting up multiple instances of ODK Central behind a reverse proxy (Multiple Instances Within Same Docker on a VM is also possible). This setup allows you to efficiently manage and access multiple instances of ODK Central on different virtual machines. Here's a step-by-step guide on how to achieve this configuration.
Prerequisites:
- ODK Central is installed in a virtual machine (let's call it VM1).
- You have a main server with internet connectivity that will act as the reverse proxy server.
- The main server uses Apache as the web server.
Step 1: Installing ODK Central on VM1
Install ODK Central on your virtual machine (VM1) following the standard installation instructions.
Step 2: Configuring Reverse Proxy on the Main Server
On the main server, generate an Apache configuration file (usually saved at /etc/apache2/sites-available). Let's use an example configuration file called mycentral.conf
for this demonstration.
Here's an example of the mycentral.conf file:
<VirtualHost *:80>
ServerName mycentral.example.com
ServerAlias www.mycentral.example.com
# Log configuration
ErrorLog ${APACHE_LOG_DIR}/mycentral_error.log
CustomLog ${APACHE_LOG_DIR}/mycentral_access.log combined
ProxyPreserveHost On
ProxyPass / http://192.168.1.11/
ProxyPassReverse / http://192.168.1.11/
</VirtualHost>
Please note the following:
- Replace mycentral.example.com with the actual domain or hostname you use for your ODK Central
- Use the local IP of your VM1 instead of http://192.168.1.11
Step 3: Register SSL Certificate
Before proceeding, ensure that you have registered an SSL certificate for your domain using Let's Encrypt in your main server. You can follow their documentation or use tools like Certbot for the certificate registration process.
Once you have obtained the SSL certificate, add the following line to the mycentral-le-ssl.conf
file generated by Certbot (usually saved at /etc/apache2/sites-available):
SSLProxyEngine On
Additionally, modify the http://192.168.1.11/ line in the file to https://192.168.1.11/ to ensure the proxy forwards requests over HTTPS.
The final config file should be like this:
<IfModule mod_ssl.c>
<VirtualHost *:443>
SSLProxyEngine On
ServerName mycentral.example.com
ServerAlias www.mycentral.example.com
# Log configuration
ErrorLog ${APACHE_LOG_DIR}/mycentral_error.log
CustomLog ${APACHE_LOG_DIR}/mycentral_access.log combined
ProxyPreserveHost On
ProxyPass / https://192.168.1.11/
ProxyPassReverse / https://192.168.1.11/
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mycentral/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mycentral/privkey.pem
</VirtualHost>
</IfModule>
Step 4: Restart Apache
After making the necessary changes, save the configuration file and restart Apache using the following command:
sudo systemctl restart apache2
Step 5: Accessing ODK Central Instances
With the reverse proxy configured, you can now create and access multiple instances of ODK Central by using different subdomains or URLs that point to the main server. Each subdomain or URL can be associated with a specific ODK Central instance running on it's own VM.
For example, if you have another ODK Central instance installed on a different virtual machine (VM2), you can configure a new virtual host in the mysecondcentral.conf
file for that instance using a different subdomain or URL.
That's it! You should now have multiple instances of ODK Central accessible through the main server using a reverse proxy.
If you have any questions or encounter any issues during the setup process, feel free to ask for help in this forum. Good luck!