I'm trying to get the https://domain.ltd
redirected to https://www.domain.ltd
on Nginx (note the www), here's the config:
server {
listen 80;
server_name domain.ltd;
return 301 https://www.$host$request_uri;
}
server {
listen 443;
server_name domain.ltd;
return 301 https://www.$host$request_uri;
}
server {
listen 443 ssl;
server_name www.domain.ltd domain.ltd;
...main config goes here
}
What I found strange is that all other options work fine:
http://domain.ltd
redirects to https://www.domain.ltd
http://www.domain.ltd
redirects to https://www.domain.ltd
https://www.domain.ltd
works too
But no way for https://domain.ltd
, it only shows ERR_CONNECTION_REFUSED
.
What's the problem with configuration? How do I solve it?
UPD. I have both www.domain.ltd and domain.ltd included in my SSL cert, so there's no reason not to work