使用nginx搭建一个普通http网站很简单,修改nginx.conf,
配置好server{}里,root相关的路径,添加自己的Index.html即可,一搜一大堆,我就不copy了。
https的就比较复杂了,也是一搜一大堆,有些文章实测说的不对,
有的介绍的很详细,技术和配置步骤穿插,但略显繁琐,
本文不介绍原理,只说最简步骤,相当于第一次学C语言时的hello,world,先跑起来再说,不要问为什么!
流程如下:
1.安装ngnix和openssl
2.自建证书
2.1 生成nginx私钥,
openssl genrsa -aes128 -out nginx.key 2048
这里输入一个密码,后续会用到,比如123456。
2.2 通过上面的私钥生成公钥
openssl rsa -in nginx.key -pubout -out nginx_pub.key
输入上面的密码123456。
2.3 通过nginx私钥生成nginx.crs
openssl req -new -key nginx.key -out nginx.csr
2.4 生成nginx证书
openssl req -new -x509 -days 3650 -key nginx.key -out nginx.crt
根据提示输入相关信息即可,需要注意的是,填