Good day! I am new to these issues, so I apologize in advance if this question is stupid)

There is a server. On it n-th number of virtual machines. On these vm costs tomkat and everyone expands the site (that is, there are 4 sites). I get access to them over a local network, and after forwarding ports through the Internet.

ВМ 1 - 1.1.1.1 ВМ 2 - 1.1.1.2 ВМ 3 - 1.1.1.3 (локальная сеть) ВМ 4 - 1.1.1.4 

External IP - 10.10.10.10

  • VM 1 - 10.10.10.10:81
  • VM 2 - 10.10.10.10:82
  • VM 3 - 10.10.10.10:83 (access to deployed sites via the Internet)
  • VM 4 - 10.10.10.10:84

I want to access my deployed sites using sub-domains (domain domen.ru purchased). But, when creating a sub-domain, I can enter only ip, without specifying the port (that is, only port 80).

Is it possible to implement sub-domains for each VM with one external ip?

  • What wasps on the host machine? - Alexander
  • Hyper-V Core 2012 R2 - OA-CRU
  • VM - Ubuntu 16.04 - OA-CRU
  • Can. Use, for example, nginx, which, depending on the name of the site, will redirect requests to virtualkam. - user194374
  • one
    I can advise to raise a separate virtual machine on which to push the entire domain on port 80. You can put nginx on this virtual machine (maybe you can think of something with Tomcot, but I didn’t work with it) and already send nginx links to other virtual machines inside nginx. - Alexander

1 answer 1

Thank you Alexander and kff .

I want to issue, suddenly people will have a similar question. Raising a VM with NGINX, all your sub-domains fall into it. From where, by adding the construct to the /etc/nginx/nginx.conf file (in the http block):

 server { server_name sub1.domen.com; reset_timedout_connection on; location ~* / { proxy_pass http://1.1.1.1; } } 

You will get the desired result. Perhaps this is not the best way, but in my case it works.