Question

Background

I currently have multiple low power servers running on my LAN. They all run different services, but some of them are similar. I also own 3 domains and have many sub-domains for those domains.

So, what's your problem?

Well, as I said before, some of my service are REALLY similar, and run on the same port (I have an Owncloud server on one, and my website is hosted on another). This means that if I want owncloud.mydomain.com to go to my Owncloud server, and www.mydoamain.com to go to my web server, I have a little bit of an issue. Both sub-domains just go to my house and the services use the same port. I can't really separate the traffic per subdomain.

edit: It also needs to be able to direct many types of traffic like SSH, HTTPS, and FTP

Possible Solutions

I've though about just running the different service on different ports, but would not be optimal AT ALL. It means it's weird to look at, people will have a harder time using any of my services, and it will generally be something I do not like.

I've thought about similar services on the same server, but their are some pretty dinky servers. I'd rather not have to do anything like that at all. Also, since the servers are a little old, it's nice to know that if one of them dies, at least I'll have my other services. I don't think this option is good at all.

Best possible solution: I've heard that there's a service that has the exact functionality that I'm looking for called haproxy. My only issues with this is that I don't know how to use this service and I especially don't know How to get the use I want out of it.

My final question

I would love to get haproxy working, I just need to know how to set it up the way I need. If anyone has a link to a tutorial on how to do what I want specifically (I've already found out how to get haproxy working, just not the way I want) then I would be really grateful. I would look for this myself, but I already have, and I don't even know what to search for. Can anyone help me out?

Thank you

Was it helpful?

Solution

Make your own config file, say haproxy.cfg, containing something like the following

defaults
 mode http

frontend my_web_frontend
  bind 0.0.0.0:80
  timeout client 86400000
  acl is_owncloud   hdr_end(host) -i owncloud.mydomain.com
  acl is_webserver  hdr_end(host) -i www.mydomain.com
  use_backend       owncloud      if is_owncloud
  use_backend       webserver     if is_webserver

backend owncloud
 balance source
 option forwardfor
 option httpclose
 timeout queue 500000
 timeout server 500000
 timeout connect 500000
 server server1 10.0.0.25:5000 weight 1 maxconn 1024 check inter 10000

backend webserver
 balance source
 option forwardfor
 option httpclose
 timeout queue 500000
 timeout server 500000
 timeout connect 500000
 server server1 10.0.0.30:80 weight 1 maxconn 1024 check inter 10000

And then run haproxy on one of your servers.

./haproxy -f ~/haproxy.cfg

Point all your domains and subdomain to this machine. They'll route according to the config.

OTHER TIPS

You only need one ip address but you need to configure the virtual host correctly. This link provides step by step details for Ubuntu virtual host configuration. This is the easiest way and everyone else will agree it's the cheapest if you insist on using your personal network.

https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top