how to disable direct access to a web site by ip address

前端 未结 8 1465
滥情空心
滥情空心 2021-01-31 02:17

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

8条回答
  •  野性不改
    2021-01-31 03:06

    Put this at top of your /etc/nginx/conf.d/SERVER_IP_ADDRESS.conf file and comment everything what is below it.

    #disabling accesing server by ip address
    server {
            listen SERVER_IP_ADDRESS:80 default;
            server_name _;
            return 404;
    }
    

    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.

提交回复
热议问题