Our web-servers have multiple IPs so we do it using:
if ( $http_host ~* "^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$" ) {
return 444;
}
if ( $http_host ~* "^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$" ) {
return 444;
}