IP address to domain redirection in NGINX
so you can add the server block in the sites-available configuration file like below
server {listen 80;server_name 111.11.111.111;return 301 $scheme://yourname.com$request_uri;
}
so above code will make sure that if you enter 111.11.111.111 it will redirect to http://yourname.com
make sure after editing the config file to reload nginx server
It is known as IP Canonical IssueYou want your ip address to be redirected to your domain name
for that you can add following code in nginx server block or add an additional server block in nginx configuration
server { listen 80; server_name www.example.com example.com 192.168.xxx.xx; return 301 https://www.example.com$request_uri;}
I use this configuration on my server; if you try an HTTP connection to the IP address of the VPS it will be redirected to my main web site.
i solved redirect from ip adress http/https in ispconfig with:
server { listen *:80; listen *:443 ssl http2; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_certificate /var/www/clients/client1/web1/ssl/domain.example-le.crt; ssl_certificate_key /var/www/clients/client1/web1/ssl/domain.example-le.key; server_name xxx.xxx.xxx.xxx; return 301 https://domain.example;}