0

I have a google cloud compute engine instance and a node app is deployed. I have added that IP to my domain and everything is fine. But the app is accessing via domain and ip as well.

I dont want to access my app with IP address. Any firewall rule that lets you to access only with domain name but not IP ??

-1

I am using nginx. So I have added this to nginix virtual host file in server block

  listen 80 default_server;
  listen [::]:80 default_server;
  return 444;

This will drop any connection made to IP address directly.

  • Normally you do not want to do that. You are misunderstanding how DNS, HTTP and TCP/IP works. All connections to your server are via the IP address. It is the HTTP Host header which defines which host (dns name) to connect to. Instead, you should redirect requests that use any address but your desired DNS name using a Redirect 301. Otherwise, you will break software that uses the HTTP/1.0 protocol (which does not require an HTTP host header). – John Hanley Jun 24 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.