Reject Requests without a Host Name Header on NGINX

The Objective: Reject all requests that reach the NGINX server with our a host name in its header

Why it matters: When a request is made to via IP address (http://your.add.rress.here), it will return what is determined to be the “default server” for that IP address. This is often not the desired result. The result we are going for here is to close the connect with the requesting client.

The solution:

generate a bogus cert and store it in your /etc/nginx/certs/bogus/ (or whichever folder you use for your certificates)

create a “default.conf” configuration file in your /etc/nginx/conf.d/ (or whichever folder you include in your config)

add the configuration to the “default.conf” file (update it if your folders are different for certs)