nginx1.14 https://a.com跳转到https://www.a.com

在之前的版本这么配置没有问题,但在新的1.14上就有问题了(以let's encrypt为例)

server {
        listen 443 ssl;
        server_name  a.com;
        return 301 https://www.a.com$request_uri;
}


server {
        listen       443 ssl;
        server_name  www.a.com;

        ...
  
        ssl_certificate /etc/letsencrypt/live/a.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/a.com/privkey.pem;
}

一直不成功,改为下面:

server {
        listen 443 ssl;
        server_name  a.com;

        ssl_certificate /etc/letsencrypt/live/a.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/a.com/privkey.pem;
  
        return 301 https://www.a.com$request_uri;
}


server {
        listen       443 ssl;
        server_name  www.a.com;

        ...
  
        ssl_certificate /etc/letsencrypt/live/a.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/a.com/privkey.pem;
}
For example, "name@something.com". If someone replies to you it will be via email.
For example, "http://someaddress.com"