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?

  • 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 Nov 22 '16 at 18:29
  • Thanks for the heads up! but I already checked it and I can do it – Pablo Lorenzo Nov 22 '16 at 18:32
  • I'll keep the comment there for future visitors anyway. – Moshe Katz Nov 22 '16 at 18:33

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/

  • 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 Nov 22 '16 at 18:36
  • 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 Nov 22 '16 at 18:38
  • @PabloLorenzo Using the same nginx instance for both hosting and reverse proxying is perfectly fine. This is a SOHO setup anyway. – Daniel B Nov 22 '16 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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