Hosting more than one MarkLogic site on a server can be tricky to the uninitiated in Apache configuration. This is not my area of expertise by any means; so given that I had to figure it out yesterday after once again forgetting how it works I think I’ll write it down here for the next time I need it. Each MarkLogic application server listens on a different high numbered port. Given the potential of draconian firewalls rules for both your hosting provider and users, typically the only reliable HTTP port will be 80. Here’s what I do on Linux and Mac OSX (sorry Windows):
- Set up my MarkLogic machine in cloud hosting (I’ve used both Amazon EC2 and Rackspace) or on on a spare machine with a dependable internet connection / power supply.
- Running 40GB instances of MarkLogic in production is now free with the MarkLogic Express License. Woot!
- Register <domain>.com with a hosting provider or a domain registry
- The hosting provider usually will have a website where I can edit my DNS rules
- Create an A rule for <subdomain1> and direct it to my ML machine’s IP
- Create a second A rule for <subdomain2> and direct it to the ML machine’s IP
- On the ML machine, install Apache2 and edit the /etc/apache2/httpd.conf file to load the following modules (add to the end of the LoadModule section if it isn’t loaded already):
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
- Add the following virtual host records to the very bottom of the file
NameVirtualHost *
<VirtualHost *>
ServerName subdomain1.domain.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:9001/
ProxyPassReverse / http://localhost:9001/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
<VirtualHost *>
ServerName subdomain2.domain.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:9002/
ProxyPassReverse / http://localhost:9002/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
- When done editing the file restart Apache2 with the following command:
sudo /usr/sbin/apachectl restart
Now requests for subdomain1.domain.com will go to port 80 of my ML machine and then internally within the server be proxied (reverse proxied actually) to port 9001.
–Dave
If you can control the IP addresses of the server itself, you can bind a MarkLogic App Server to a specific IP address. Rather than using the default of 0.0.0.0, which binds the App Server to all IP addresses on the server, you specify a specific IP and the port of 80. The IP:port combination must be unique, but you can host as many port 80 App Servers on a server as you have IP addresses.