Figured it out. Here's how to do it:
First, we need to generate a self-signed certificate from the server.
Enter the following command in SSH and make sure to replace <SERVER-IP> with your SERVER IP Address.
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /www/ipssl/privateKey.key -out /www/ipssl/certificate.crt -subj '/CN=<SERVER-IP>'
It will generate and Save Self-Signed Private Key and Certificate files at /www/ipssl/ path.
Now open nginx.conf file located at: /www/server/nginx/conf
Locate the following piece of code at the end of file:
include /www/server/panel/vhost/nginx/*.conf;
}
Paste the following code just above the above-mentioned code and save.
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
server_name SERVER-IP;
ssl_certificate /www/ipssl/certificate.crt;
ssl_certificate_key /www/ipssl/privateKey.key;
return 403;
}
Now just reload or restart nginx and try to access your server IP with HTTP or HTTPS, it will throw a 403 Forbidden error, instead of loading your website.