I have a website on a VPS.
The issue I am having is that when I enter the IP of the server, it links to the website.
Even when entering mail.domain.com, it does the same thing.
How do I disable that, so a visitor would get a message or be directed to the domain?
I tried disabling the IP and mail a record on cloud flare but it didn't work.
My setup is:
VPS on Linux Debian
Nginx
no control panel just command line
Cloudflare
DNS setup with BIND
You may try to set the server IP address in:
So it looks like this:
Then you can specify the subdomain vhost, like:
And the main domain, like:
Then restart Nginx:
Each vhost should have its own *.conf file (for better organization), like:
you can return any error you find suitable. A list of errors can be found here List_of_HTTP_status_codes
Put this at top of your
/etc/nginx/conf.d/SERVER_IP_ADDRESS.conf
file and comment everything what is below it.Then restart your Nginx server (on Ubuntu it is done by
service nginx restart
this command)Now when you will put your server's ip address to browser url field you will get 404 error.
You can use redirect, nginx config:
You can just add a server directive before others.