0

How do I configure multiple virtual nginx server so that they respond to a subdomain and an ip/path combination like:

virtual host A: a.example.com xxx.xxx.xxx.xxx/a

virtual host B: b.example.com xxx.xxx.xxx.xxx/b

Currently the DNS is down and our services aren't reachable via the configured subdomains. We want to be prepared in case something like that happens again. By bypassing the DNS and direct usage of the ip/path we would solve any DNS related problem.

pauel
  • 115
  • 1
  • 1
  • 5

1 Answers1

1

Every web-server simply responds on the configured ports, and while responding it matches the Host header with configured server name, server_name in case of nginx. Thus it doesn't depend on DNS, clients do. Regarding the case that you're describing - nginx didn't stop working, instead nobody comes in.

So, you cannot avoid this issue using other methods than using redundant DNS configuration. In your case - multiple NS in several datacenters.

drookie
  • 8,625
  • 1
  • 19
  • 29
  • Thank you very much. I understand. But if we could simply give the IP/path to our customers in case of such a problem this would solve any NS issue. – pauel Nov 29 '17 at 17:21
  • Add second IP on your primary network interface on the web-server, make *vhost A* `default` on 1st IP, make *vhost B* `default` on second IP, give your customers both IP, voila. I strongly suggest, however, paying more attention to your DNS infrastructure. – drookie Nov 29 '17 at 17:23
  • Ok, thats an idea sure. But we would need a lot of ip's. Does your response mean there is no way to do the ip/path solution? If I remember correctly with apache this was an easy task. – pauel Nov 29 '17 at 17:29
  • You could use one IP, but in this case your customers would have to add a record for each of your vhosts to their *hosts* local file, and you see, this is where they will start to replicate your DNS infrastructure. So why don’t you stop reinventing the wheel and do this for them. – drookie Nov 29 '17 at 19:24