阿里云 SSL 免费证书使用

申请

[申请地址]
https://common-buy.aliyun.com/?spm=5176.2020520163.cas.20.165a56a7xopCbo&commodityCode=cas#/buy

在这里插入图片描述
申请完成页面
在这里插入图片描述
将主机记录解析
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
将主机记录和记录值填写
在这里插入图片描述
解析成功后下载证书
在这里插入图片描述
我用的是 Apache ,所以下载的是 Apache
在这里插入图片描述

上传证书

由于本人使用的是 apache ,以下配置是 apache 的通用配置,具体可参看官方文档

  1. 在 apache 的路径下新建一个 cert 目录,其实该目录建在哪里都可以,但是放在 apache 下方便管理.
    在这里插入图片描述
    在 cert 目录下可以建不同的文件夹放在不同域名或子域名的 ssl 文件.
    在这里插入图片描述
    把我们刚才下载的证书上传到服务器上
    在这里插入图片描述
配置

这是基本的配置语句

# 添加 SSL 协议支持协议,去掉不安全的协议
SSLProtocol all -SSLv2 -SSLv3
# 修改加密套件如下
SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
SSLHonorCipherOrder on
# 证书公钥配置
SSLCertificateFile cert/a_public.crt
# 证书私钥配置
SSLCertificateKeyFile cert/a.key
# 证书链配置,如果该属性开头有 '#'字符,请删除掉
SSLCertificateChainFile cert/a_chain.crt

我们将默认的配置 copy 一份出来,取一个跟域名有关的文件名

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/www.xiaobinqt.cn.conf

具体配置可参考

<VirtualHost *:80>

      ServerName www.xiaobinqt.cn
      Redirect permanent / https://www.xiaobinqt.cn/
</VirtualHost>

<VirtualHost *:443>
     SSLEngine On
        # 添加 SSL 协议支持协议,去掉不安全的协议
SSLProtocol all -SSLv2 -SSLv3
# 修改加密套件如下
SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
SSLHonorCipherOrder on
# 证书公钥配置
SSLCertificateFile cert/xiaobinqt.cn/2324042_www.xiaobinqt.cn_public.crt
# 证书私钥配置
SSLCertificateKeyFile cert/xiaobinqt.cn/2324042_www.xiaobinqt.cn.key
# 证书链配置,如果该属性开头有 '#'字符,请删除掉
SSLCertificateChainFile cert/xiaobinqt.cn/2324042_www.xiaobinqt.cn_chain.crt
    # etc
ServerName www.xiaobinqt.cn
     ProxyPreserveHost On
     ProxyRequests Off
     ProxyPass / http://localhost:30007/
     ProxyPassReverse / http://localhost:30007/
</VirtualHost>

我用的是 docker 服务,如果你的只是项目文件夹可以参考这样配置

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        #ServerAdmin webmaster@localhost
        ServerName www.xiaobinqt.cn
        DocumentRoot /var/www/html
        Redirect permanent / https://www.xiaobinqt.cn/

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

<VirtualHost *:443>
     SSLEngine On
        # 添加 SSL 协议支持协议,去掉不安全的协议
SSLProtocol all -SSLv2 -SSLv3
# 修改加密套件如下
SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
SSLHonorCipherOrder on
# 证书公钥配置
SSLCertificateFile cert/xiaobinqt.cn/public.pem
# 证书私钥配置
SSLCertificateKeyFile cert/xiaobinqt.cn/214792197160511.key
# 证书链配置,如果该属性开头有 '#'字符,请删除掉
SSLCertificateChainFile cert/xiaobinqt.cn/chain.pem
    # etc
     ServerName www.xiaobinqt.cn
</VirtualHost>

以上配置全部基于 apache ,如果你用的不是 apache ,以上配置可能不适合你.
关于 apache 服务的一些其他知识可以参考这篇文章,该文章可能需要翻~墙访问.
配置完成后重启服务,可以利用 curl 命令查看是否配置成功.

curl -I localhost:xxx

在这里插入图片描述
对于 ssl 是否配置成功可以通过浏览器查看.

可以看到这是我们最新申请的一年的 ssl 证书.
在这里插入图片描述
以上,配置完成.

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值