My server is built using Nginx. Now there is a scenario as follows:
A.com的A记录指向a.b.c.d
B.com的A记录指向a.b.c.d
My Nginx settings
listen a.b.c.d:80 default;
server_name A.com;
Currently, when you visit B.com, my site will be opened by default, and the resources on the site can also be referenced correctly.
How to configure it so that B.com and other domain names cannot be accessed?
I understand that if you add a judgment if{}, you can return error codes for other domain names, but if there are multiple vhosts, it will be more troublesome to configure. Is there a more elegant and universal way?
You configure the default domain name to return 403:
See: http://wiki.nginx.org/NginxVirtualHostExample