Probably they could be several redirects at the same time, if we follow Google’s classical advice on either all www or all non-www (SEO advice: url canonicalization - Matt Cutts).
For example, if we want Nginx redirects for http → https and www → non-www:
server {
listen 93.184.216.34:80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 93.184.216.34:443 ssl http2;
server_name www.example.com;
ssl_certificate /etc/letsencrypt/(...).cer;
ssl_certificate_key /etc/letsencrypt/(...).key;
return 301 https://example.com$request_uri;
}
server {
listen 93.184.216.34:443 default_server ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/(...).cer;
ssl_certificate_key /etc/letsencrypt/(...).key;
(...)
}
(93.184.216.34 is example.com’s IP)
Update: Although this simple configuration works, see another example below on this thread, more compatible with Ghost CLI’s files, Let’s Encrypt renewals, etc.