How to have multiple servers on one IP address
Solution 1:
I assume this is a small office/home setup.
There is no way to assign the same IP to multiple devices. Therefore, you'll either have to host everything on the same device or use a mechanism that helps you to distribute the packets to the corresponding servers. I think what you need to look into here are ports, NAT and reverse proxies.
If you only have one single IP address available, you will have to either
- Configure the public IP to a single device and distribute the requests within your local network
- Host all services on the same hardware (e.g. your raspberry).
An example for port forwarding:
- You configure
cloud.mydomain.com
to point at your IP. Here, you will run a web server on port 443 (https). - You configure
mc.mydomain.com
to point at your IP. Here, you will run your Minecraft server on a port of your choice, e.g. 25565. - You configure your firewall/router to forward everything that it receives on its public IP.
- ...on port 443 to the raspberry that is hosting the ownCloud instance.
- ...on port 25565 to the raspberry that is hosting the Minecraft server.
- These can be different devices on your local network. You just set up the port forwarding or NAT rules.
An example using a proxy:
- You want to run multiple web servers having only a single IP. You do not want to use different ports for different websites.
- You configure your subdomains to point at your single IP.
- You set up a port forwarding/NAT rule to forward any incoming traffic on port 443 to one of your raspberries.
- You set up web servers on two other raspberries that shall each handle traffic for one of the subdomains.
- On the first raspberry, you set up a reverse proxy, e.g. using Nginx. You set up different configurations for your subdomains: one for
sub1.mydomain.com
, one forsub2.mydomain.com
, withproxy_pass
directives pointing to other web servers within your local network. - Your Nginx-proxy now handles any incoming traffic, distributing it to the correct web server on the basis of the subdomain that the user is requesting.