There are two ip, in the server that use nginx to set up a station. How to specify a different ip? for each domain name setting?

now I can find the corresponding ip, when I resolve different ip, speed tests for domain names directly in dns. Can I just resolve domain names and specify what ip, doesn"t need to be set ?

after I set ip in the current site profile include / www/server/panel/vhost/nginx/ domain name .conf;
listen, the site will be 404.

server
{
    listen XX.XXX.80.104:80;
    *************************
    *************************

A few years ago, someone asked
nginx listen to specify IP:80 and not specify to listen for all port 80 requests. The former accesses normally and the latter accesses 404. Why? -SegmentFault want to https://codeshelper.com/q/10.


  1. first notice the cache of DNS. For example, if you are connected to the Internet, the native DNS recommends using Ali's public DNS.
  2. if it is diverted directly at the DNS level, the request should not reach the Ngx you have set. For example, you have two ip, 10.0.0.1 and 10.0.0.2 . If you set the former to www.a.com and the latter to www.b.com , then the request of www.b.com will not reach 10.0.0.1 .
  3. if you want to divert streams to a certain ip, you should parse them all to this ip, and then use server_name or reverse proxy to different application services on Ngx
Menu