Hi this must be a basic question but I haven't seen an answer with cerbot considerations (if there are any considerations). How do I get https www to redirect to non-www instead of timing out?
The https www version of my site times out instead of redirecting to non-www, whereas all other versions (http and https non-www) work fine.
Preferably I would like to future proof so that I can renew the certs through certbot and not need to manually change the nginx config afterwards.
The nginx server config is shown below:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name www.mydomain.com mydomain.com;
listen 443 ssl; # managed by Certbot
ssl_certificate <path_to_cert> # managed by Certbot
ssl_certificate_key <path_to_key>; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam <path_to_this>
if ($scheme != "https") {
return 301 https://$host$request_uri;
} # managed by Certbot
}