最近在升级交流学习社区,感觉有必要升级到https。以下是我自己在升级中的记录。下面包括以下几个部分:1、阿里云免费购买SSL证书1、我在阿里云上申请了免费的,然后自己付0元购买了SSL证书2、我选择了DNS验证3、在SSLcertificate,下载cert证书,然后放到nginx服务器上2,nginx无缝升级https4,检查nginx是否支持ssl5,配置ssl模块6,重新编译7,因为这是升级nginx,所以不需要执行makeinstall,先备份原来的nginx执行脚本8.将新编译好的nginx执行脚本复制到对应目录:'9.最后,进行平滑升级。10、再次查看nginx是否有https模块。11.显示https网址,https://www.mwcxs.top/注1:nginx配置SSL错误,sslonerror注2:nginxhttps服务配置1.我在阿里云上免费申请,然后交了0元自己去买SSL证书2.我选择DNS验证,因为域名是你自己的。DNS验证方式一般需要您的域名管理员操作。请按照您的证书订单中的进度提示,在您的域名管理系统中进行相应的配置。选择DNS域名授权验证方式,需要在您的域名解析服务商(如万网、信网、DNSPod等)提供的系统中进行配置。例如,如果您的域名托管在阿里云上,则需要到阿里云DNS控制台进行相关配置。生成的域名验证可以在域名解析管理中看到。3、在SSL证书中,下载cert证书,放到nginx服务器上。4.查看nginx是否支持ssl:./nginx-V查看configurearguments信息中是否有-with-http_ssl_module字样5.配置ssl模块在找到之前安装解压Nginx目录,配置ssl模块:./configure--with-http_ssl_module6,在解压目录下重新编译执行makemake7,因为这里是升级nginx,所以不需要执行makeinstall,先备份原来的nginx执行脚本:mv/usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx.old8。将新编译好的nginx执行脚本复制到对应目录:cdobjscpnginx/usr/local/nginx/sbin/9,最后执行平滑升级cd..makeupgrade10,再次查看nginx是否有https模块11,显示https网址,https://www.mwcxs.top/注1:nginx配置ssl报错问题,sslonerror报错启动错误(报错信息:nginx:[emerg]the"ssl"parameterrequiresngx_http_ssl_modulein/home/soft/nginx/conf/nginx.conf:76)需要配置模块ssl模块--with-http_ssl_modul,请看本文第二部分:2.配置ssl模块注2:nginx的https服务配置#HTTPSserverserver{listen443;服务器名称www.mwcxs.top;SSL开启;根/home/nodejs/liblog/www;indexindex.jsindex.html索引。htm;ssl_certificate/usr/local/nginx/cert/15420110408020120565539868.crt;ssl_certificate_key/usr/local/nginx/cert/15420110408020120565539868.key;ssl_session_cache共享:SSL:1m;ssl_session_timeout5m;ssl_ciphersECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocolsTLSv1TLSv1.1TLSv1.2;ssl_prefer_server_ciphers开启;if(-f$request_filename/index.html){重写(.*)$1/index.html中断;}if(!-f$request_filename){重写(.*)/index.js;}location/{proxy_http_version1.1;proxy_set_header连接“”;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_header主机$http_host;proxy_set_headerX-NginX-Proxytrue;proxy_set_header升级$http_upgrade;proxy_set_header连接“升级”;proxy_passhttp://learning_community_node$request_uri;proxy_redirect关闭;}location=/production.js{全部拒绝;}location=/testing.js{全部拒绝;}location~/static/{etagon;过期最大值;}}服务器{听80;服务器名称www.mwcxs.topmwcxs.top;return301https://$server_name$request_uri;}注意:return301https://$server_name$request_uri;用于http转https欢迎关注:https://github.com/saucxs/nod...,欢迎fork开始
