Putting Apache in Front of Domino
Dec 8, 2012, 1:59 PM
- Putting Apache in Front of Domino
- Better Living Through Reverse Proxies
- Domino's Server-Side User Security
- A Partially-Successful Venture Into Improving Reverse Proxies With Domino
- PSA: Reverse-Proxy Regression in Domino 12.0.1
- Overdue PSA: Reverse-Proxy Headers in Domino 12.0.1FP1 and Newer
The other day, for my side-project company, I wanted to set up hosting for a WordPress site, ideally without setting up another whole server. The first two ideas I had were pretty terrible:
- Hosting it on Domino directly with PHP via CGI. Even if this worked, I assume the performance would be pretty poor and I'd have no confidence in its general longevity.
- Hosting it on Apache on another port and using Domino to proxy through. While Domino does have some minor proxy capabilities, they didn't strike me as particularly thorough or suitable for the task.
Since the second option involved running two web servers anyway, I decided to flip it around and do the more-common thing: making Apache the main server and switching Domino to another port. Fortunately, even though it's been years since I ran an Apache server and I'd consider myself novice at best, the process has been exceptionally smooth and has brought with it a couple benefits:
- Apache's virtual-host support works perfectly, allowing me to host just the one named site and pass through all other requests to Domino.
- My crummy SSL setup works better with Apache, allowing for a poor-man's multi-host-name SSL with my one basic StartSSL certificate. Not only does Apache support SNI for down the line, but in the mean time I can use the same certificate for multiple names (with the usual "mis-matched name" warning) - since Apache handles all requests and funnels them over with the host name to Domino via HTTP, I don't run into the usual Domino problem of only the one SSL-enabled Web Site document being active.
- I'm now ready to add load-balancing servers at any time with just a one-line adjustment in my Apache config.
The actual configuration of Apache on my Linux machine was pretty straightforward, with the layout of the configuration directory making it fairly self-explanatory. I linked the modules I wanted from the /etc/apache2/mods-available directory to /etc/apache2/mods-enabled (namely, proxy, proxy_balancer, proxy_http, php5, rewrite, and ssl). Then, I set up a couple NameVirtualHost lines in ports.conf:
NameVirtualHost *:80 NameVirtualHost *:443
Then, I set up a new default site in /etc/apache2/sites-available and linked it to /etc/apache2/sites-enabled/000-domino:
<VirtualHost *:80> <Proxy balancer://frostillicus-cluster> BalancerMember http://ceres.frostillic.us:8088 ProxySet stickysession=SessionID </Proxy> ProxyPass / balancer://frostillicus-cluster/ nocanon ProxyPassReverse / balancer://frostillicus-cluster/ ProxyPreserveHost On AllowEncodedSlashes On </VirtualHost>
That last directive is an important note, and I missed it at first. The "optimize CSS and JS" option in 8.5.3 creates URLs with encoded slashes and, by default, Apache's proxy breaks them, leading to 404 errors in apps that use it. If you turn on
AllowEncodedSlashes, though, all is well. Note also the
ProxySet line: if that's working correctly (I haven't tested it yet since I don't have a second host set up), that should make sure that browser sessions stick to the same server.
For SSL, I'm not sure what the absolute best way to do it is, but I set it up as another proxy just pointing to the HTTP version locally, so I don't have to set up multiple SSL sites for each virtual host (put into a new site document, 002-ssl):
<VirtualHost *:443> ProxyPass / http://127.0.0.1/ ProxyPassReverse / http://127.0.0.1/ ProxyPreserveHost On SSLEngine On SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM SSLCertificateFile /path/to/ssl.crt SSLCertificateKeyFile /path/to/ssl-decrypt.key SSLCertificateChainFile /path/to/sub.class1.server.ca.pem SSLCACertificateFile /path/to/ca.pem </VirtualHost>
With that config, SSL seems to work exactly like I want: all my sites have an SSL counterpart that acts just like the normal one, much like with Domino normally.
It's only been running like this a couple days, so we'll see if I run into any more trouble, but so far this seems to be a solid win for my hosting, other than the increase in memory usage. I'm looking forward to having another clustermate in the same location so I can try out the load balancing down the line.
Patrick Kwinten - Mar 11, 2013, 7:47 AM
We had hoped that Domino 6 would support JSP and J2EE.