nginx 301 redirect to www and https

nginx 301 redirect to www and https
website:

http://www.cl-light.com -> https://www.cl-light.com
{http://cl-light.com + https://cl-light.com} -> https://www.cl-light.com

server {
listen 80;
server_name www.cl-light.com;
location / {
return 301 https://$host$request_uri;
}
}

server {
listen 80;
server_name cl-light.com;
listen 443 ssl;
ssl on;
error_page 497 https://$request_uri;

ssl_certificate /usr/local/nginx/cert/cl-light.pem;
ssl_certificate_key /usr/local/nginx/cert/cl-light.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

location / {
return 301 https://www.cl-light.com$request_uri;
}

server {
listen 443;
server_name www.cl-light.com;
listen 443 ssl;
ssl on;
ssl_certificate /usr/local/nginx/cert/cl-light.pem;
ssl_certificate_key /usr/local/nginx/cert/cl-light.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

}

}

相关推荐

nginx pagespeed config

# Enable pagespeed module by putting the following in http context pagespeed on; pagespeed Domain example. …

暂无评论

微信扫一扫,分享到朋友圈

nginx 301 redirect to www and https