1.生成公钥与私钥
[root@proxy ~]# cd /usr/local/nginx/conf
[root@proxy ~]# openssl genrsa > cert.key //生成私钥
[root@proxy ~]# openssl req -new -x509 -key cert.key > cert.pem //生成证书
2.修改配置文件
[root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf
… …
server {
listen 443 ssl;
server_name www.c.com;
ssl_certificate cert.pem; #这里是证书文件
ssl_certificate_key cert.key; #这里是私钥文件
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
3.重启nginx服务