It's possible to have multiple physical servers behind one home router?

3

I have multiple Raspberry Pi at home and I would like to use them as web servers for some of my projects. I'm aware that I could host several sites on one Pi with virtual hosts, but I want just one on each, so they have more resources available and there are more independent.

I' also aware that I could use different ports for each one,but I would like to use port 80 for all of them, so there are accessible to anyone that type the domain.

So the question is, how can I have two or more domains pointing to the same IP address and make the router (or one of the RPi) figure out which website is hosted in which Pi?

Is it possible at all?

Pablo Lorenzo

Posted 2016-11-22T18:20:18.327

Reputation: 33

Keep in mind that many ISPs explicitly prohibit hosting websites on your home Internet connection in their Terms of Service. At best, they might ask you to stop. At worst, they could force you to pay for a business plan or terminate your service. – Moshe Katz – 2016-11-22T18:29:39.653

Thanks for the heads up! but I already checked it and I can do it – Pablo Lorenzo – 2016-11-22T18:32:37.520

I'll keep the comment there for future visitors anyway. – Moshe Katz – 2016-11-22T18:33:30.573

Answers

4

Yes it is possible. Your easiest way is probably to setup a reverse proxy. You would then point all your URLs to the reverse proxy server that would retrieve the URL endpoint and point back to the appropriate server.

Here is the Wikipedia article on them: https://en.wikipedia.org/wiki/Reverse_proxy

A good open source (free) reverse proxy is: https://www.nginx.com/products/feature-matrix/

IronWilliamCash

Posted 2016-11-22T18:20:18.327

Reputation: 1 314

I'm already using Nginx as my web-server in the different machines, should I use one just for the proxy or it's ok to have on one the proxy and a website? – Pablo Lorenzo – 2016-11-22T18:36:30.430

I see no problem with having both on one machine, as long as the requests go to the reverse proxy and then redirects to this same machine. To be able to do this though, you'll probably have to change the listening port of the webserver on that same machine to not have any conflicts. – IronWilliamCash – 2016-11-22T18:38:07.503

@PabloLorenzo Using the same nginx instance for both hosting and reverse proxying is perfectly fine. This is a SOHO setup anyway. – Daniel B – 2016-11-22T19:10:01.017