-3

In the coming months I'll be creating different websites. Actually, one has been up already for awhile but I shut it down because of internet issues.

My issue now is I want to create another website but just under a certain sub-domain. I want to do this so that I can maximize my domain. So I'll be creating say:

1. www.example.com
2. api.example.com
3. xyz.example.com

My home router forwards port 80 to a certain local IP 192.168.0.3 which is a virtual machine. I want to make contents of different websites to reside in different VMs to avoid conflicts. So those 3 websites, are in different VMs.

Now, how can I set my router to target a VM depending on the website being requested provided that my router only targets one IP to port forward port 80?

Am I correct that I'll be using reverse proxy of Apache2?

Update: Is this an ideal solution on websites with this setup? If not how is large corporations set it up?

user3856437
  • 1,359
  • 2
  • 12
  • 16
  • Why someone downvoted it? – user3856437 Dec 16 '17 at 06:01
  • 3
    Probably because it is not programming related. Anyway, your home router most probably can't look into HTTP headers to make a routing decision, so yes, you can forward 80 to one VM with apache, and use reverse proxy there to route traffic to appropriate VM. – Dusan Bajic Dec 16 '17 at 10:39
  • Is this the best way to run several sites with this setup? Because I don't like setting up Apache virtual host because I'm avoiding conflicts. Because when Apache is down all sites are down. – user3856437 Dec 20 '17 at 04:21
  • I suggest you ask new question on [superuser.com](https://superuser.com/) – Dusan Bajic Dec 20 '17 at 07:31

1 Answers1

1

first you have to configure the dns server of your domain to forward all domains to the same ip address (use some a A-Records) a-record

and then configure Name-based virtual hosts in the configuration of your apache webserver.

Name-based virtual hosts

in this Virtual hosts you can forward to the VMs

Dirk Sonne
  • 21
  • 3
  • I have edited this question just added a question found at the bottom. Can you answer it please? – user3856437 Dec 18 '17 at 10:48
  • what do you want to do with the Virtual machines? answering html traffic? host a application with a application server (tomcat)? – Dirk Sonne Dec 20 '17 at 15:33