OpenSSL

製作證書,停掉docker所佔用的80端口,啟動Ubuntu本身的Nginx。

Nginx通常在etc/nginx 目錄下,配置nginx.conf 或者 /etc/nginx/sites-available/default.

讓certbot 可以訪問到80服務。Nginx配置.well-known/acme-challenge 訪問路徑,並設置allow all權限,certbot可以寫入。

1. Create fullchain.pem and privkey.pem

复制代码
openssl req -new -nodes \
  -newkey rsa:2048 \
  -keyout privkey.pem \
  -out cert.csr \
  -config openssl.cnf

2.. Cerbot apply Let's Encrypt

复制代码
certbot certonly --manual --csr request.csr
或者

certbot certonly --webroot -w /var/www/html -d yourdomain.com
  1. /etc/nginx/sites-available 修改Nginx配置文件

    复制代码
     listen 80;
     listen [::]:80;
    
     server_name erp.vital-base.com;
    
     location /.well-known/acme-challenge/ {
         root /var/www/html;
         allow all;
     }
  2. 創建測試文件

    sudo mkdir -p /var/www/html/.well-known/acme-challenge
    echo hello | sudo tee /var/www/html/.well-known/acme-challenge/test.txt

复制代码
http://erp.vital-base.com/.well-known/acme-challenge/test.txt
  1. 結果

/var/www/html 與Nginx 保持一致

复制代码
certbot certonly --webroot -w /var/www/html -d domain.com
  1. 如果用Docker,需要掛載

    cannot load certificate "/etc/ssl/myerp/fullchain.pem"
    : BIO_new_file() failed (SSL: error:80000002:system
    library::No such file or directory:calling
    fopen(/etc/ssl/myerp/fullchain.pem, r)
    error:10000080:BIO routines::no such file)

    查看目錄下有沒有文件

    ls -l /opt/myspace/wrp/ssl2

    chmod 644 /opt/workspace/worker_myerp/ssl2/*.pem

    或者

    chmod -R 755 /opt/workspace/worker_myerp/ssl2

相关推荐
SelectDB18 小时前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
AlfredZhao19 小时前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
zzzzzz3102 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode2 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220703 天前
如何搭建本地yum源(上)
运维
A小辣椒4 天前
TShark:Wireshark CLI 功能
linux
A小辣椒4 天前
TShark:基础知识
linux
AlfredZhao4 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao5 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334665 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux