什么是https?
HTTP:是互联网上应用最为广泛的一种网络协议,是一个客户端和服务器端请求和应答的标准(TCP),用于从WWW服务器传输超文本到本地浏览器的传输协议,它可以使浏览器更加高效,使网络传输减少。
HTTPS:全称:Hyper Text Transfer Protocol over Secure Socket Layer,则是以安全为目标的HTTP通道,简单讲是HTTP的安全版,即HTTP下加入SSL层,HTTPS的安全基础是SSL,因此加密的详细内容就需要SSL。
HTTPS协议的主要作用可以分为两种:一种是建立一个信息安全通道,来保证数据传输的安全;另一种就是确认网站的真实性。
openssl自签证书
自签证书测试
1. 安装nginx
[root@ c7-47 ~]# yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel wget pcre pcre-devel
[root@ c7-47 ~]# wget http://nginx.org/download/nginx-1.14.2.tar.gz
[root@ c7-47 ~]# tar zxf nginx-1.14.2.tar.gz
[root@ c7-47 ~]# cd nginx-1.14.2/
./configure --with-http_stub_status_module --with-http_ssl_module
[root@ c7-47 nginx-1.14.2]# make && make install
2. 检查Nginx的SSL模块
[root@ c7-47 ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.14.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --with-http_stub_status_module --with-http_ssl_module
3. 准备私钥和证书
创建私钥
[root@ c7-47 ~]# cd /usr/local/nginx/
[root@ c7-47 nginx]# mkdir -p