zoukankan      html  css  js  c++  java
  • 创建免费的证书,实现网站HTTPS

      公司最近给自己的自媒体产品开发微信小程序,但是使用的后台接口需要是https服务,而之前公司使用的是阿里云的免费的HTTPS证书,蛋疼的阿里云突然把证书给下架了,突然想到之前看左耳朵耗子的一篇文章使用Certbot来实现HTTPS,这边也就考虑采用Cerbot来实现下

    配置Certbot 证书

    Certbot 的官方网站是 https://certbot.eff.org/ ,打开官网选择的 web server 和操作系统,如下图

    此时会出现一个安装文档,告诉你如何来安装

    1.下载certbot 客户端

    wget https://dl.eff.org/certbot-auto
    chmod a+x certbot-auto

    2.生成https证书

    $ sudo ./certbot-auto --authenticator webroot --installer nginx

    此时会有很多的操作步骤,这个时候你可以根据自己需求来配置,但是这个过程有点小麻烦,下面介绍一种简单的配置

    3.停止nginx 服务

    service nginx stop

    4.生成证书

    ./certbot-auto certonly --standalone --email '邮箱地址' -d '域名地址'

    5.nginx中配置证书

    server {
        listen 443;
        ssl on;
        ssl_certificate /etc/letsencrypt/live/wechat.rest.90dichan.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/wechat.rest.90dichan.com/privkey.pem;
        server_name  wechat.rest.90dichan.com;
        location / {
            proxy_pass  http://10.30.49.201:9088/;
            proxy_buffer_size 512m;
            proxy_buffers 4 512m;
            proxy_redirect  off;
            proxy_set_header  Host $host;
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header  X-Real-Port $remote_port;
        }
    
    }

    至此https配置完成

    6.重新启动nginx服务

    service nginx start

    7.证书续签

    Let’s Encrypt 生成的免费证书为3个月时间,所以这个问题就很蛋疼,这里我们使用定时任务来续签证书;

    ./certbot-auto renew 
  • 相关阅读:
    防止sql注入的方法
    二叉树的LCA(最近公共祖先)算法
    二叉树的计算
    @RestController和@Controller注解的区别
    单调栈与单调队列
    java中删除list指定元素遇到的问题
    随机打乱数组
    Mysql基本操作
    二叉树的构建
    synchronized修饰方法和对象的区别
  • 原文地址:https://www.cnblogs.com/mengyu/p/8399976.html
Copyright © 2011-2022 走看看