使用阿里云服务器,nginx安装第三方ssl证书
环境
- 服务器:阿里云ECS
- 系统:Centos 7
- ssl证书:DigiCert
1.准备好证书的证书私钥、证书文件
2.上传至服务器
3. nginx.conf文件配置
#以下属性中,以ssl开头的属性表示与证书配置有关。
server {
listen 443 ssl;
#配置HTTPS的默认访问端口为443。
#如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。
#如果您使用Nginx 1.15.0及以上版本,请使用listen 443 ssl代替listen 443和ssl on。
server_name yourdomain.com; #需要将yourdomain.com替换成证书绑定的域名。
root html;
index index.html index.htm;
#使用绝对路径指向上传的证书文件.
ssl_certificate /usr/local/nginx/conf/xxx.pem;
#使用绝对路径指向上传的证书密钥key。
ssl_certificate_key /usr/local/nginx/conf/xxx.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#表示使用的加密套件的类型。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #表示使用的TLS协议的类型。
ssl_prefer_server_ciphers on;
location / {
root html; #站点目录。
index index.html index.htm;
}
}
4测试
#验证配置是否正确
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
#重启nginx
[root@localhost sbin]# ./nginx -s reload
#验证ssl配置是否生效
[root@iZ8vb6hrptmvexpbq6xcnuZ ~]# echo | openssl s_client -connect 127.0.0.1:443 -servername www.xxx.com 2>/dev/null
---
No client certificate CA names sent
Peer signing digest: SHA512
Server Temp Key: ECDH, P-256, 256 bits
---
SSL handshake has read 4488 bytes and written 443 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : ECDHE-RSA-AES128-GCM-SHA256
Session-ID: BD400C244CC1703151CBDB4C321456A9907A7FCAD8404638D3FBFE2F08976C09
Session-ID-ctx:
Master-Key: CD5E8E2AE3394522B559F1F09BC6C83D7CCE822E5C62CA97976A4ED5214A834902B7008C6D51B9D83B7E067F27040B46
Key-Arg : None
Krb5 Principal: None
PSK identity: None
PSK identity hint: None
TLS session ticket lifetime hint: 300 (seconds)
TLS session ticket:
0000 - 00 46 4c 78 57 e3 48 58-d7 a7 dd 4d 56 bb a2 5e .FLxW.HX...MV..^
0010 - 31 fb a1 4f 11 e0 9e 7b-3b 32 40 a3 be d4 d6 2b 1..O...{;i@....+
0020 - 0b a7 01 95 fd c2 9f 1e-88 6a 62 f9 b1 b7 a4 23 .........jb....#
0030 - d0 8f fd fb bd f2 75 06-e0 44 d1 d3 e8 8e cb 94 ......u..D......
0040 - 50 1e ca fc 56 45 9e 44-9b a7 95 15 e9 3a 65 0d P...VE.D.....:e.
0050 - 27 1a d1 9d 17 c0 b1 1c-0b d9 4e fe 05 3c f5 b1 '.........N..<..
0060 - 47 f8 15 54 00 7f aa d3-cc 2f 27 13 02 55 6d 49 G..T...../'..UmI
0070 - b9 71 55 b1 23 eb d1 08-18 8f bd 5b ad 05 d6 40 .qU.#......[...@
0080 - 7e 50 9c c8 22 a5 42 7a-17 a6 09 75 ee e5 47 ae ~P..".Bz...u..G.
0090 - 9d 55 da 5f fb 5a 59 65-a3 c4 e0 6e 23 5b ba e3 .U._.ZYe...n#[..
00a0 - 6c 43 f9 ee 8b 82 ab e0-f1 f9 85 3e 84 f6 15 d3 lC.........>....
Start Time: 1624438543
Timeout : 300 (sec)
Verify return code: 0 (ok)
---
5.将第三方的证书上传至阿里云
6.其他问题.
-
SSL证书部署后访问网站时显示为旧证书、已正确配置SSL证书,但访问网站时仍显示为旧证书。
检查是否是CDN、WAF(WEB应用防火墙)缓存。更新证书即可。
检查是否打开服务器 443端口,加入配置规则