Block direct access to IP Address in Nginx

Admit it, we've all been there! We spin up a new VPS and find out that the server was earlier being used by someone else who didn't deal with their mess properly and now all those internet zombies are now trying to find directories on your new server. While this may not be a problem for some but it definitely is an issue for people who keep a strict audit of their access log to ensure that their services are safe and working as expected. I'm one of those and I really like to keep my server logs clean while also saving myself from some potential data leak situations.

This is a companion discussion topic for the original entry at