国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Docker獲取Let`s Encrypt SSL 證書

這篇具有很好參考價(jià)值的文章主要介紹了Docker獲取Let`s Encrypt SSL 證書。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

文中的操作都是在CentOS Stream release 9下執(zhí)行的,使用的是root用戶。

1. 安裝docker

# 卸載原有的docker
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
# 安裝依賴
yum install -y yum-utils device-mapper-persistent-data lvm2
# 配置docker-ce源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 安裝docker
yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# 安裝docker-compose
wget https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64
chmod +x docker-compose-linux-x86_64 && mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose && ldconfig

2. Let`s Encrypt及Certbot介紹

關(guān)于Let`s Encrypt可以參見這里。

certbot安裝使用參加這里。

3. Docker運(yùn)行Certbot獲取證書

為了方便維護(hù)、升級(jí),同時(shí)也避免破壞本地的開發(fā)環(huán)境,我這里使用docker方式來運(yùn)行certbot。整個(gè)過程分為兩步:首次申請(qǐng)證書和證書更新。

3.1 首次申請(qǐng)證書

因?yàn)槲业奈恼露际峭ㄟ^jekyll運(yùn)行的靜態(tài)網(wǎng)站,之后會(huì)通過nginx來運(yùn)行,所以這里就以nginx為例來配置網(wǎng)站的tls證書。

  1. 創(chuàng)建nginx配置文件default.conf
server {
    listen      80;
    server_name example.com www.example.com;

    # 高優(yōu)先級(jí),僅用于更新證書
    location ~ /.well-known/acme-challenge {
        allow all;
        root /data/letsencrypt;
    }
}
  1. docker-compose文件:
version: '3.3'

services:
  nginx:
    image: nginx:1.23.4-alpine
    container_name: frontend
    volumes:
      - ./default.conf:/etc/nginx/conf.d/default.conf
      - ./frontend:/usr/share/nginx/html
    ports:
      - 80:80
  1. 啟動(dòng)web服務(wù): docker-compse up -d
  2. 啟動(dòng)certbot申請(qǐng)證書:

docker run --rm -it -v ./certbot/etc/letsencrypt:/etc/letsencrypt -v ./certbot/var/log/letsencrpt:/var/log/letsencrypt -v ./frontend:/data/letsencrypt certbot/certbot:latest certonly --webroot --email your@eamil.com --agree-tos --no-eff-email --webroot-path=/data/letsencrypt -d example.com -d example.com

運(yùn)行結(jié)束后可以在./certbot/etc/letsencrypt/live目錄下找到example.com文件夾,其中包含證書文件fullchain.pem和私鑰文件privkey.pem。

  1. 停止web服務(wù):docker-compose down
  2. 更新compose文件:
version: '3.3'

services:
  nginx:
    image: nginx:1.23.4-alpine
    container_name: frontend
    volumes:
      - ./default.conf:/etc/nginx/conf.d/default.conf
      # - ./frontend:/usr/share/nginx/html
      - ./certbot/etc/letsencrypt/live:/letsencrypt/live        # 當(dāng)前證書目錄
      - ./certbot/etc/letsencrypt/archive:/letsencrypt/archive  # 歷史證書目錄
      - ./dhparam-2048.pem:/letsencrypt/dhparam-2048.pem        # 使用2048位DH(Diffie-Hellman)參數(shù)
    ports:
      - 80:80
      - 443:443

2048為DH參數(shù)生成命令:openssl dhparam -out ./dhparam-2048.pem 2048

  1. 更新nginx配置文件
# 處理http請(qǐng)求
server {
    listen      80;
    server_name example.com www.example.com;

    # 重定向到https
    location / {
        rewrite ^ https://$host$request_uri? permanent;
    }

    # 高優(yōu)先級(jí),僅用于更新證書
    location ~ /.well-known/acme-challenge {
        allow all;
        root /data/letsencrypt;
    }
}

# 處理https請(qǐng)求
server {
    listen 443 ssl http2;
    server_name example.com www.example.com;

    server_tokens off;

    ssl_certificate /letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /letsencrypt/live/example.com/privkey.pem;

    ssl_buffer_size 8k;

    ssl_dhparam /letsencrypt/dhparam-2048.pem; # 使用2048位DH參數(shù),加強(qiáng)安全

    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

    ssl_ecdh_curve secp384r1;
    ssl_session_tickets off;

    # OCSP stapling
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8;

    root /usr/share/nginx/html;
    index index.html;
}
  1. 重新啟動(dòng)web服務(wù):docker-compose up -d

3.2 證書更新

  1. 通過以下腳本可以實(shí)現(xiàn)證書更新:
#!/bin/bash

docker run -it --rm \
-v ./certbot/etc/letsencrypt:/etc/letsencrypt \
-v ./certbot/var/lib/letsencrypt:/var/lib/letsencrypt \
-v ./certbot/var/log/letsencrypt:/var/log/letsencrypt \
-v ./site:/data/letsencrypt \
certbot/certbot \
renew --webroot -w /data/letsencrypt --quiet && docker kill --signal=HUP frontend
  1. crontab -e新增一條定時(shí)任務(wù),每月1號(hào)00:00更新一次證書:0 0 1 * * {{YOURPATH}}/renew.sh

聲明:本作品采用署名-非商業(yè)性使用-相同方式共享 4.0 國(guó)際 (CC BY-NC-SA 4.0)進(jìn)行許可,使用時(shí)請(qǐng)注明出處。
Author: mengbin
blog: mengbin
Github: mengbin92
cnblogs: 戀水無意文章來源地址http://www.zghlxwxcb.cn/news/detail-427807.html


到了這里,關(guān)于Docker獲取Let`s Encrypt SSL 證書的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 寶塔面板站點(diǎn)SSL,Let‘s Encrypt 證書申請(qǐng)報(bào)錯(cuò):Invalid version. The only valid version for X509Req is 0.

    寶塔面板站點(diǎn)SSL,Let‘s Encrypt 證書申請(qǐng)報(bào)錯(cuò):Invalid version. The only valid version for X509Req is 0.

    Linux正式版 7.9.10 CentOS 7.3.1611 x86_64(Py3.7.9) 新服務(wù)器 , 新裝寶塔 , 新增站點(diǎn) ,ssl選擇Let’s Encrypt,點(diǎn)擊申請(qǐng)證書 報(bào)錯(cuò): 文件驗(yàn)證和DNS驗(yàn)證都報(bào)這個(gè)錯(cuò)。 試過修復(fù)面板(無效),試過回退到7.9.8版本(無效) 您好,您這個(gè)報(bào)錯(cuò)是因?yàn)槊姘逡蕾嚨牟患嫒輰?dǎo)致的證書申請(qǐng)失敗,

    2024年02月09日
    瀏覽(22)
  • centos Let‘s Encrypt 免費(fèi)https證書申請(qǐng),并且自動(dòng)續(xù)約

    官網(wǎng)地址: https://certbot.eff.org/instructions?ws=otheros=centosrhel8 下載 snap 工具 下載安裝 cerbot 安裝很簡(jiǎn)單 ** 在使用 webroot 之前,先配置根目錄** 我這邊以 nginx 為例 主要是 cerbot 會(huì)訪問到 .wel-known 這個(gè)目錄 配置完后,我們運(yùn)行命令 證書生成后會(huì)打印證書路徑 一般在 /etc/letsencrypt/

    2024年02月08日
    瀏覽(24)
  • 最新版 Let’s Encrypt免費(fèi)證書申請(qǐng)步驟,保姆級(jí)教程

    最近將域名遷到了google domain,就研究了一下Let’s Encrypt的域名證書配置。發(fā)現(xiàn)網(wǎng)上找到的教程在官方說明中已經(jīng)廢棄,所以自己寫一個(gè)流程記錄一下。 步驟方法官方文檔見:https://eff-certbot.readthedocs.io/en/stable/install.html#installation snapd官方文檔見:https://certbot.eff.org/instructions

    2024年02月07日
    瀏覽(44)
  • 輕松配置 https:Let‘s Encrypt 介紹及 Nginx Proxy Manager 實(shí)用操作教程

    輕松配置 https:Let‘s Encrypt 介紹及 Nginx Proxy Manager 實(shí)用操作教程

    一般我們?cè)诒镜剡M(jìn)行 web 開發(fā)時(shí)用的都是 http 協(xié)議,而部署到服務(wù)器上之后為了安全都要配置 https,以保證客戶端和服務(wù)器之間的通信內(nèi)容得到加密,不會(huì)被泄露或篡改。 本文將介紹 https 協(xié)議的基本知識(shí)(如果有基礎(chǔ)可以跳過),以及如何使用 Let’s Encrypt 給你的服務(wù)優(yōu)雅地

    2024年03月11日
    瀏覽(19)
  • Let‘s Encrypt

    ????????Let\\\'s Encrypt —— 是一個(gè)由非營(yíng)利性組織互聯(lián)網(wǎng)安全研究小組(ISRG)提供的免費(fèi)、自動(dòng)化和開放的證書頒發(fā)機(jī)構(gòu)(CA),簡(jiǎn)單的說,就是為網(wǎng)站提供免費(fèi)的 SSL/TLS 證書。互聯(lián)網(wǎng)安全研究小組(ISRG):ISRG是美國(guó)加利福尼亞州的一家公益公司,成立于2013年5月,第一個(gè)

    2024年02月09日
    瀏覽(13)
  • 11種免費(fèi)獲取SSL證書的方式

    11種免費(fèi)獲取SSL證書的方式

    從2018年7月1日開始,Chrome將顯示所有未使用SSL證書的網(wǎng)站標(biāo)記為“不安全”,而擁有SSL證書的網(wǎng)站的權(quán)重排名都會(huì)獲得提升。 隨著企業(yè)與網(wǎng)民網(wǎng)絡(luò)安全意識(shí)的增加,全網(wǎng)正在走向全面https的時(shí)代,加密將無處不在,無論是網(wǎng)站、APP、軟件、小程序等都在大規(guī)模應(yīng)用SSL進(jìn)行加密

    2023年04月09日
    瀏覽(16)
  • SSL中的CA證書

    SSL中的CA證書

    目錄 一、CA概述 二、數(shù)據(jù)加密 三、身份認(rèn)證 ????????SSL如何保證網(wǎng)絡(luò)通信的安全和數(shù)據(jù)的完整性呢?就是采用了兩種手段: 身份認(rèn)證 和 數(shù)據(jù)加密 。身份認(rèn)證就需要用到CA證書。 ????????CA是證書的簽發(fā)機(jī)構(gòu),它是公鑰基礎(chǔ)設(shè)施(Public Key Infrastructure,PKI)的核心。

    2024年04月12日
    瀏覽(22)
  • Nginx中的SSL加密配置與證書生成

    Nginx中的SSL加密配置與證書生成

    目錄 整體的操作流程 二、然后配置網(wǎng)絡(luò)yum源 并mv CentOS-* backup挪動(dòng)到上層目錄中 ?三、在家目錄下解壓 文件,并查看 ?四、添加兩種編譯模塊./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module 五、 顯示少什么就 yum install (缺少的依賴的名稱)-devel 下圖為

    2024年02月05日
    瀏覽(16)
  • docker安裝nginx并配置ssl證書

    docker安裝nginx并配置ssl證書

    騰訊云申請(qǐng) 阿里云申請(qǐng) 還有一步DNS驗(yàn)證,因?yàn)槲疫@邊已經(jīng)申請(qǐng)了證書,不好演示了。也挺簡(jiǎn)單的,按照教程來就行了,在域名解析里面加一條DNS解析記錄,然后點(diǎn)擊驗(yàn)證,通過了,就申請(qǐng)成功了,然后下載nginx版本的證書壓縮包,解壓上傳到服務(wù)器就可以了 *稍微需要注意下

    2024年02月05日
    瀏覽(37)
  • 手把手教你獲取一年免費(fèi)通配符泛域名SSL證書

    手把手教你獲取一年免費(fèi)通配符泛域名SSL證書

    (前排提示:想白嫖OV,EV SSL 的朋友們還是放棄吧,目前不存在此類服務(wù)) 眾所周知,SSL現(xiàn)已成為各種網(wǎng)站必不可少的配置了,但是主流的Let\\\'s Encrypt(Let\\\'s Encrypt),ZeroSSL(Free SSL Certificates and SSL Tools - ZeroSSL)等只能提供90天的免費(fèi)SSL,而阿里云,華為云提供的每年20張一年

    2024年02月07日
    瀏覽(57)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包