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 Answer 1

-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.

1
  • 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). Commented Jun 24, 2019 at 0:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.