acme获取泛域名证书

Huan Lee Lv5

下载acme脚本

1
curl  https://get.acme.sh | sh

设置证书CA - ZeroSSL

acme 3.0开始默认使用ZeroSSL作为证书服务商, 这步可以跳过

1
acme.sh --set-default-ca --server zerossl

设置API Key

https://app.zerossl.com/developer

1
acme.sh --register-account -m myemail@example.com --server zerossl --eab-kid <eab-kid> --eab-hmac-key <eab-hmac-key>

配置DNS_API和获取证书

https://github.com/acmesh-official/acme.sh/wiki/dnsapi

找到自己使用的域名供应商, 进行配置

安装证书

把证书安装到nginx目录下.

1
2
3
4
5
acme.sh --install-cert -d yourdomain.com -d "*.yourdomain.com" \
--cert-file /etc/nginx/cert/cert.crt \
--key-file /etc/nginx/cert/privkey.pem \
--fullchain-file /etc/nginx/cert/fullchain.pem \
--reloadcmd "service nginx force-reload"

nginx设置https

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

server {
server_name www.mirthfullee.top blog.mirthfullee.top mirthfullee.top;
# hexo blog content
root <content-root>;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

error_page 404 /404.html;
location = /404.html {
}

# ssl cert
include /etc/nginx/ssl.conf;

}
server {

if ($host = mirthfullee.top) {
return 301 https://$host$request_uri;
} # managed by Certbot

if ($host = *.mirthfullee.top) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80;
listen [::]:80;
# 设置自动http转https
server_name *.mirthfullee.top mirthfullee.top;
return 404;

}
# proxy nas services
include /etc/nginx/proxy.d/*.conf;
}

注意nginx的ssl_certficate设置的是fullchain证书, 否则会报错.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# ssl.conf
# listen [::]:443 ssl ipv6only=on;
# listen [::]:443; # manually changed
# ssl on;
listen 443 ssl;
ssl_certificate /etc/nginx/cert/fullchain.pem;
ssl_certificate_key /etc/nginx/cert/privkey.pem;

ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_session_tickets off;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;

ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384";

  • Title: acme获取泛域名证书
  • Author: Huan Lee
  • Created at : 2024-02-28 15:55:55
  • Updated at : 2024-02-28 08:16:56
  • Link: https://www.mirthfullee.com/2024/02/28/notion-acme获取泛域名证书-413fe32e/
  • License: This work is licensed under CC BY-NC-SA 4.0.