Restriction of access on HTTPS to any website via IP Address on NGINX

It is recommended to access any web site via domain address instead of IP address, therefore please use the following steps to configure your NGINX.

server {
listen 443 ssl;

ssl_certificate /etc/nginx/ssl/;
ssl_certificate_key /etc/nginx/ssl/;
if ($host != "") {
return 301 $scheme://$request_uri;

After configuration is saved, reload your NGINX:

# service nginx reload

After NGINX reloaded, It will redirect all direct accesses using IP address to along with the URI in the request.