nginx http转https, 不带www转带www
server { listen 80; listen 443 ssl http2; ssl_certificate /usr/local/nginx/conf/ssl/longe.net.cn.pem; ssl_certificate_key /usr/local/nginx/conf/ssl/longe.net.cn.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; server_name xxx.cn www.xxx.cn; if ($scheme = http) { return 301 https://$host$request_uri; } if ($host = 'xxx.cn') { return 301 https://www.xxx.cn$request_uri; } return 404; }