First, make sure all the virtual host site conf file has no default_server. Then, make a new conf file under /etc/nginx/conf.d/. For me I use default.conf. Add the following into this file to block all the direct IP access for port 80, or http. where _ catches all the domain
The 404 error or Not Found error message is an HTTP standard response code indicating that the client was able to communicate with the server but either the server could not find what was requested, or it was configured not to fulfill the request and not reveal the reason why.