不少人的个人博客已经启用SSL证书,可https访问,可如何强制全站都是https访问呢,以下以Nginx的conf配置为例说明:
server_name 是你要绑定的域名,ssl_certificate 与ssl_certificate_key 是你的SSL证书文件
server {
listen 80;
server_name xxx.com www.xxx.com;`
# 以下两行均为实现80跳转443,哪个好选用那个`
#rewrite ^ https://$server_name$request_uri? permanent;`
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name xxxx.com www.xxx.com;
index index.html index.htm index.php;
root /home/wwwroot/xxx.com;
ssl on;
ssl_certificate /usr/local/nginx/conf/ssl/xxx.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/xxx.key;
ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4";
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security max-age=63072000;
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
}
网友评论