Nginx 配置 SSL 可信证书

目录

1. 使用 acme.sh 签发 ZeroSSL 证书

1.1. 安装依赖

shell
# On Ubuntu/Debian:
sudo apt install cron socat -y

# On Fedora/RHEL/CentOS:
sudo yum install nc socat -y

1.2. 安装 acme.sh

1.2.1. 一键安装

shell
# https://github.com/acmesh-official/acme.sh/wiki/说明
curl https://get.acme.sh | sh -s email=service@wangyan.org

1.2.2. 自定义安装(可选)

shell
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
sudo ./acme.sh --install  \
--home /usr/local/acmesh \
--config-home /usr/local/acmesh/data \
--cert-home  /usr/local/acmesh/data \
--accountemail  "service@wangyan.org"

1.3. 签发证书(DNS 模式)

1.3.1. 注册 ZeroSSL

获取 eab-kid 和 eab-hmac-key替换 xxxx

shell
acme.sh --register-account --server zerossl \
        --eab-kid xxxx \
        --eab-hmac-key xxxx

1.3.2. 导入域名注册商 KEY

dnsapi

##acmesh-official / ##acme.sh

shell
# Cloudflare
export CF_Key="" && \
export CF_Email=""

# DNSPod
export DP_Id="" && \
export DP_Key=""

# West
export WEST_Username="" && \
export WEST_Key=""

1.3.3. 签发 ECC 证书

注意修改 dns_west_cn 为 dns_cf 或者其他 dns_dp

shell
acme.sh --register-account --server zerossl \
        --eab-kid xxx \
        --eab-hmac-key xxxxx

acme.sh --server zerossl --issue --force \
        -d 'wangyan.cloud/' -d '*.wangyan.cloud/' \
        --dns dns_cf --keylength ec-256

ln -s wangyan.cloud/_ecc /usr/local/nginx/conf/ssl-certs/

1.3.4. 撤销 && 删除

shell
acme.sh --revoke -d 'wangyan.cloud/' -d '*.wangyan.cloud/' --ecc
acme.sh --list

2. 二、Nginx SSL 配置

2.1. 生成 dhparam

shell
sudo chmod 777 /usr/local/nginx/conf/ssl-certs && \
sudo chmod o+t /usr/local/nginx/conf/ssl-certs

sudo openssl dhparam -out /etc/nginx/ssl-certs/dhparam.pem 2048
sudo curl https://ssl-config.mozilla.org/ffdhe2048.txt > /etc/nginx/ssl-certs/dhparam.pem
ESC