centos6 nginx 配置本地https访问
-
安装准备
yum install openssl openssl-devel
-
生成文件
cd /usr/local/nginx/conf
# 生成密钥privkey.pem:
openssl genrsa -out privkey.pem 1024/2038
# 使用密钥生成证书server.pem:
openssl req -new -x509 -key privkey.pem -out server.pem -days 365
# 证书信息可以随便填或者留空,只有第一个填国家可以填写`CN`
-
修改对应网站server内容
listen 80;
server_name example.com;
# 修改成如下
listen 443;
server_name example.com;
ssl on;
ssl_certificate server.pem;
ssl_certificate_key privkey.pem;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
-
重启nginx即可
如果报错unknown directive "ssl" in /usr/local/nginx
,那应该是nginx安装的时候,没有安装ssl_module
,不需要重新安装nginx,方法请参考下面链接
https://www.cnblogs.com/qq917937712/p/11799524.html