Nginx SSL证书安装
将域名 www.domain.com 的证书文件1_www.domain.com_bundle.crt 、私钥文件2_www.domain.com.key保存到同一个目录,例如/usr/local/nginx/conf目录下。
更新Nginx根目录下 conf/nginx.conf 文件如下:
server {
listen 443 ssl;
server_name www.domain.com; #填写绑定证书的域名
ssl_certificate 1_www.domain.com_bundle.crt;
ssl_certificate_key 2_www.domain.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
ssl_prefer_server_ciphers on;
location / {
root html; #站点目录
index index.html index.htm;
}
if (server_port = 80) {
rewrite ^(.*) https://host1 permanent;
} #使用全站加密,http自动跳转https
}
配置完成后,先用bin/nginx –t来测试下配置是否有误,正确无误的话,重启nginx。就可以使 https://www.domain.com 来访问了。