O
O
ONIKSfly2015-05-15 16:11:51
network hardware
ONIKSfly, 2015-05-15 16:11:51

How to organize access to several servers behind a router with an external static ip?

I am not very versed in the topic and the question is to understand in which direction to look for information. To be honest, I found the answer to serverfault , but it didn't help me much.
There is a home network with an Asus RT-N16 router, a cable with an external static ip is connected to it. Previously, there was a server behind the router with a local ip 192.168.0.2 and a raised nginx, which served several sites. The router was configured to forward port 80 to the ip of this server and this option worked successfully.
Now another server has appeared on the home network with two virtual machines (192.168.0.4 and 192.168.0.5), each of which is running nginx on port 80. Schematically, it looks like this:
672249afc1f44aac98bf211aaab528d8.png
Is it possible to make sure that the server on the local network on port 80 answers the request for the corresponding domain name? That is, something like this:
www.example.com → external ip 133.0.125.133 → 192.168.0.2 (name based virtual host)
www.example-2.com → external ip 133.0.125.133 → 192.168.0.2 (name based virtual host )
www.example-3.com → external ip 133.0.125.133 → 192.168.0.3
www.example-4.com → external ip 133.0.125.133 → 192.168.0.4
I would not want to implement the option using different ports, since they can be blocked on the client side. And if it is impossible to organize this programmatically, then how to do it in hardware? Connect a separate cable with your external ip to the second server?
I will be glad to any advice, except for comments that I do not understand anything on the topic. Yes, I do not understand, so I want to understand.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mureevms, 2015-05-15
@ONIKSfly

Forward port 80 to any server with apache\nginx , and then proxy requests to different sites
For apache - Is it possible to broadcast several web servers through one web server?
For nginx - Nginx as proxy to remote host?
According to the scheme, it will work like this:
www.example.com → external ip 133.0.125.133:80 → (port 80 redirect, regardless of the domain name) → 192.168.0.2:80 (proxy web server) → 192.168.0.3 (web server with www.example.com)

S
solalex, 2015-05-15
@solalex

Is it necessary to respond from port 80? You can redirect different ports of the router (81,82,83....) to 80 ports of different machines.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question