一:加装nginx的ssl模块
1.1:切换到源码包
cd /zz/nginx-1.14.2
1.2:查看已安装模块
/usr/local/nginx/sbin/nginx -V
[root@games nginx-1.14.2]# /usr/local/nginx/sbin/nginx -V nginx version: nginx/1.14.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module
1.3:运行新配置
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
1.4:make(不要 make install)
1.5:备份原文件cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginxbak
1.6:停止nginx
./nginx -s stop
1.7:拷贝新文件替换原文件
cp -r ./objs/nginx /usr/local/nginx/sbin/
1.8:查看是否加载成功
/usr/local/nginx/sbin/nginx -V
二:配置http与https共存
2.1:ssl写在443端口后面,这样http和https的链接都可以用
server { listen 80; listen 443 ssl; server_name www.xxx.com; ssl_certificate /usr/local/ssl/Nginx/xxx.crt; ssl_certificate_key /usr/local/ssl/Nginx/xxx.key; }
感谢:
https://www.cnblogs.com/ghjbk/p/6744131.html