1

I'm trying to set up my own vps hosting. It wont be a paid service, just an experiment for me and some nerdy friends.

What I'd like to be able to do is this: Run multiple virtual servers on 1 external IP. These servers can run anything from Minecraft servers to simple http servers. They will also need to be accessible thru SSH.

What I don't get is how I can address these servers using domain names. I've done some research and found out that I could use Vhosts with Apache. However this only applies to http servers. It was also suggested I'd use a reverse proxy(squid) but this also only applies to http requests.

I could just use different ports for different servers, but thats not ideal and not what I want.

Can someone suggest a setup? Maybe some tutorials or anything.

Reaces
  • 5,597
  • 4
  • 38
  • 46
RobinFTW
  • 11
  • 1
  • possible duplicate of [Is there a name based virtual host SSH reverse proxy?](http://serverfault.com/questions/34552/is-there-a-name-based-virtual-host-ssh-reverse-proxy) – kasperd Sep 16 '15 at 19:44

4 Answers4

2

You cannot access the virtual machines via domain names if you have only 1 IP address (other than the http proxy method you suggested). Just spend some extra bucks and buy a /29 IP address class.

As for virtualization, you have some options. The main battle now is between Xen and KVM, each one with fierce supporters. I am currently using Xen and I'm pretty happy with it.

Mihai B.
  • 118
  • 1
  • 1
  • 4
1

To achieve complete separation of services you would need to leverage virtual machines. They can be configured to share the same network interface and IP while existing on a single physical server. You might have to route traffic with a layer 7 firewall on the host before passing connections into the virtual machines for HTTP traffic at least. SSH will probably just need to use different ports unless you modify the OpenSSH daemon. In this configuration you can spawn a number of completely independent "virtual opperating systems" within a single host. Then you could assign a VM to each of your friends where aach VM could potentially run multiple virtual HTTP sites within itself. The VM's act just like a normal OS, unaware it's actually virtualized sharing cpu and memory resources with parallel operating systems.

I'm not sure if you actually need this type of separation but this will accomplish what you're looking for. Don't expect it to scale very well with load without throwing some money at your hardware however.

1

yea, I sense a bit of confusion in your post. A Virtual Machine (VM) is just that; a logical and completely seperate, we'll say, instance of emulated hardware upon which you install an operating system like Linux or Windows.

The whole HTTP and DNS concepts are not related to VMs! A domain like stackexchange.com may be hosted on multiple physical or virtual machines in order to load balance or just generally keep content separate.

You can host multiple domains (stackoverflow.com, stackexchange.com) on a single IP address. This is part of the HTTP 1.1 specification. Under Apache it's called name based virtual hosts (vhosts for short). Same capability exists in Microsoft IIS.

Since web server software (Apache and IIS) run within the context of an operating system (Linux and Windows respectively), you would need either a VM or physical hardware to run either OS and the web server software (apache, IIS).

Apache/IIS (and others) bind themselves to the IP stack within the operating system which, again, is running on either a VM or physical hardware. The IP stack and all the related management associated with managing IP addresses, IP resolution (called the resolver) is OS specific. Under Linux, for example, you deal with /etc/resolv.conf on many distributions or you can set up BIND to respond to DNS requests to convert things like stackoverflow.com to an IP address.

So you could have a single Linux VM running Apache and hosting multiple web sites on a single IP address!

The trick is to making the marriage between DNS and your web server software all work together or in concert so that the different protocols (http, dns) are correct. NOTE: You can host DNS outside of your VMs too.

hope this helps

To answer the other part of the question about how to get a single public IP to hit multiple VMs or physical computers running web sites, you need a reverse proxy. Apache does this; not sure about IIS and there is HAProxy that can do this too.

You can, for example, have HAProxy listen on the single PUBLIC IP and then route traffic to the correct internal server on a private IP. Keep in mind that there is two way communication here -- so a reply from your web server needs to show up as if it came from the single IP.

Kilo
  • 1,564
  • 13
  • 21
0

I don't know for sure if it would work, it's just something I'm thinking about:
You could try assigning an IPv6-address to each machine that tunnels everything via the IPv4-address.

Bart De Vos
  • 17,911
  • 6
  • 63
  • 82