D
D
Denis Safronov2014-05-09 16:35:58
iptables
Denis Safronov, 2014-05-09 16:35:58

Home server: 1 Public IP -> several virtual machines

Good afternoon!
The situation is as follows: There is a GPON Internet with Public IP 1.2.3.4 and, for example, a home server with an internal IP of 192.168.1.101. In the router settings, I specify port forwarding 22, 80, 8080 to the corresponding ports 192.168.1.101. There is a KVM on machine 192.168.1.101, for example, with three virtual machines looking into the network through its own NAT, for example, with IP 192.168.100.101, 192.168.100.102, 192.168.100.103 .. Here the question arises, as already from machine 192.168. 1.101 do a redirect(?) to virtual machines, depending on which host was accessed and at the same time it was all visible via the Internet?
Those. I just type, for example, somehost.example.com, which looks in DNS A-record in IP 1.2.3.4, then the router sends this request to the machine 192.168.1.101 in its local network, the machine 192.168.1.101 looks which host is from it want and sends the request further, for example, to the machine 192.168.100.102.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vlad Zhivotnev, 2014-05-09
@mcdb

server {
server_name somehost.example.com;
listen 80;
    location / {
      proxy_pass http://192.168.0.100;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
    }
}

Drive the same for each site in the nginx config on the server 192.168.1.101 (or where your traffic flows there)

S
Scorp919, 2014-05-09
@Scorp919

This is just the job of the web server. Install a web server and it will do just that. I would recommend keeping everything on one web server, and not on 3 virtual machines. You waste a lot of resources on this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question