How to redirect an URL such as http://192.0.2.4
to https://example.com
and not https://192.0.2.4
in Nginx?
Like Google is doing by redirecting https://172.217.7.206
to https://google.com
My nginx configuration:
#Redirect all traffic to HTTPS
server {
listen 80 default_server;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name www.example.com;
I don't want any rewrite because it cost more resources.