Can the Nginx instance be configured to ONLY respond to named requests?

I would like requests by IP to either blackholed respond back with a 400 or 403. Is that possible through global variables? I don’t want requests directly to the endpoint IP to redirect to the correct DNS hostname. I guess what I am asking is how can i persist custom Nginx changes?