Using HAProxy to Host Multiple Subdomains

I was recently given cause to find an alternative to Dropbox for syncing files and creating a basic backup. I wanted to host this on my own systems on my home network. OwnCloud is the leading open-source file syncing utility. It uses standard HTTP/S for syncing, making it firewall friendly, but HTTP runs on port 80, and I already had Port 80 occupied. I could manually configure a port, but that just seems ugly to me, so instead I looked in to it and decided I needed a Reverse Proxy.

Here’s my setup:

Firewall ------ HAPRoxy
           |               |
       ownCloud          Other

Using this blog post, I was able to quickly get this setup.

frontend slatehorizon
mode http
acl is_cloud hdr_dom(host) -i cloud
acl is_guac hdr_dom(host) -i guacamole
use_backend cloud if is_cloud
use_backend guac if is_guac

backend cloud
balance roundrobin
option httpclose
option forwardfor
server cloud1

backend guac
balance roundrobin
option httpclose
option forwardfor
server guac1

You’ll note that each domain can still operate with independent load balancing were that to be needed. And I am even able to redirect to HTTP running on Tomcat.

The biggest pain in all this was that these services should be secure. Unfortunately, I found no way to do it…for both. At the moment, any HTTPS traffic goes straight to the OwnCloud backend.

Leave a Comment

Your email address will not be published.