Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.