So my example.com
configuration file successfully redirect the following URL to https://example.com/
...
http://1.2.3.4
http://example.com
http://www.example.com
https://example.com
https://www.example.com
... but not https://1.2.3.4
. My question is, how do I redirect https://1.2.3.4
to https://example.com
?
I have not make any changes to default
configuration file. Here is my example.com
configuration file:
server {
listen 80;
listen [::]:80;
server_name www.example.com example.com 1.2.3.4;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
server_name www.example.com 1.2.3.4;
return 301 https://example.com$request_uri;
}
server {
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
server_name example.com;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
root /var/www/example.com/html;
index index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
}
Thank you and have a nice day.
server
block is only listening on IPv4 while the other two are listening on both IPv4 and IPv6. Obviously the browser will generate a certificate warning as1.2.3.4
is not a domain name.listen 443 ssl;
and addlisten [::]:443 ssl ipv6only=on; listen 443 ssl;
?-d 1.2.3.4
argument insidesudo certbot --nginx -d example.com -d www.example.com
when initializingcertbot
?