Apache can be the web server in front of MDriven Server and MDriven Turnkey on Linux, in the same way as Nginx: the applications run as services on local ports, and Apache passes the requests on to them (a reverse proxy) and handles https. See How MDriven Core runs.
This page shows the Apache configuration. It assumes the setup from Install on Linux as services: MDriven Server on port 5010 and Turnkey on port 5011, both with nohttps. The same setup with Nginx is described step by step in Nginx as a reverse proxy.
1. Install Apache and the proxy modules
On Ubuntu or Debian:
sudo apt-get install apache2
sudo a2enmod proxy proxy_http proxy_wstunnel headers rewrite ssl
sudo systemctl restart apache2
proxy_wstunnel is needed because MDriven Server and Turnkey use WebSockets.
2. One site per application
Create /etc/apache2/sites-available/mdriven-turnkey.conf for Turnkey (replace the host name):
<VirtualHost *:80>
ServerName app.example.com
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "http"
# WebSockets
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule ^/(.*) ws://127.0.0.1:5011/$1 [P,L]
ProxyPass / http://127.0.0.1:5011/
ProxyPassReverse / http://127.0.0.1:5011/
</VirtualHost>
Create /etc/apache2/sites-available/mdriven-server.conf for MDriven Server the same way, with its own host name (for example server.example.com) and port 5010. Then enable the sites:
sudo a2ensite mdriven-turnkey mdriven-server
sudo apache2ctl configtest
sudo systemctl reload apache2
3. https
Add a certificate to each site, for example a free Let's Encrypt certificate with Certbot:
sudo apt-get install certbot python3-certbot-apache
sudo certbot --apache -d app.example.com -d server.example.com
Certbot adds the https sites and renews the certificates automatically. In the https site, set RequestHeader set X-Forwarded-Proto "https".
4. Tell the applications their public address
Behind a proxy the applications see the local address. Give each its public address with HardServerUrl.xml, and let Turnkey reach MDriven Server on the local port through MDrivenServerOverride.xml (http://localhost:5010/).
When Apache is the public entry point, ports 5010 and 5011 do not need to be open in the firewall.
