Setting location for 2 domains on a single ip?

Hello, faced with the need to setup nginx as a reverse proxy. Situation - one white ip that is bound 2 domain. In addition to nginx there are 2 backend servers running on 80
you need to have nginx listened 80 port and proximal depending on the url - the domain name(for example roga.com; kopita.org) to the correct server in the local network. Ie, in fact I don't know the location to put the condition for proxying.
April 3rd 20 at 17:39
1 answer
April 3rd 20 at 17:41
Solution
server {
listen 80;
server_name roga.com;
location / {
proxy_pass http://local_roga_com_ip;
}
}

server {
listen 80;
server_name kopita.org;
location / {
proxy_pass http://local_kopita_org_ip;
}
}
Tell me about it, sites as subdomains.
type a.roga.com - 192.168.1.2
b.roga.com - 192.168.1.3 ... - gaylord_Dicki commented on April 3rd 20 at 17:44
@gaylord_Dicki, that is exactly the same. - julian81 commented on April 3rd 20 at 17:47
@gaylord_Dicki, I'll tell you more if you were not overloaded with corporate portals, it is generally possible all on one server to deploy, read about virtual hosting in relation to nginx - julian81 commented on April 3rd 20 at 17:50
@julian81, just like read, but in practice something does not work.
There is a domain dom.io
Router is 192.168.1.1 with a web admin :81
There are 2 sites server 192.168.1.2 and 192.168.1.3

Want to do like this:
admin.dom.io - proxy pass 192. 168.1.1:81
dom.io - proxy pass 192.168.1.2
test.dom.io - proxy 192.168.1.3 pass

Configure nginx going on the router 192.168.1.1.

Write a basic config so I looked where I went wrong.

It would be nice if I was prompted as to traverse multiple sites on the same server with containers. I understand that it is necessary to raise one container with nginx to do, to say half of the sites on 192.168.1.1 was proxied to the container with nginx and it has proximal in local containers? - gaylord_Dicki commented on April 3rd 20 at 17:53
@gaylord_Dicki,
admin.dom.io and test.dom.io
dns resolveda? - julian81 commented on April 3rd 20 at 17:56
@gaylord_Dicki, can containers to bindit not on 127.0.0.1, and 0.0.0.0
Or to put nginx on the server with the container, not the container - julian81 commented on April 3rd 20 at 17:59
@julian81, DNS will not rezolvata. Don't know where to dig.
And nginx separately in a container wanted to it was easy to migrate / replace the equipment.

//I was just trying to examine jails in FreeBSD :)
All a lot we have to learn. The brain does not pull.

If someone has free time to knock in the telegram @chifty , I have a lot of questions have accumulated... - gaylord_Dicki commented on April 3rd 20 at 18:02
>DNS will not rezolvata. Don't know where to dig
in the DNS configuration - julian81 commented on April 3rd 20 at 18:05

Find more questions by tags Nginx