acme 生成ssl 域名证书,自动续费[亲测] 建议参考这个
https://www.168seo.cn/seo/24671.html
下载letsencrypt并且生成证书
git clone https://github.com/letsencrypt/letsencrypt cd letsencrypt ./letsencrypt-auto certonly 生成后的证书在 /etc/letsencrypt/live/ 目录下。 cert.pem - Apache服务器端证书 chain.pem - Apache根证书和中继证书 fullchain.pem - Nginx所需要<span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/ssl" title="View all posts in ssl" target="_blank">ssl</a></span>_certificate文件 privkey.pem - 安全证书KEY文件 <span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/ssl" title="View all posts in ssl" target="_blank">ssl</a></span>_certificate /etc/letsencrypt/live/ttync.com/fullchain.pem; <span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/ssl" title="View all posts in ssl" target="_blank">ssl</a></span>_certificate_key /etc/letsencrypt/live/ttync.com/privkey.pem; 对应的证书位置:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
git
clone
https
:
/
/
github
.com
/
letsencrypt
/
letsencrypt
cd
letsencrypt
.
/
letsencrypt
-
auto
certonly
生成后的证书在
/
etc
/
letsencrypt
/
live
/
目录下。
cert
.pem
-
Apache服务器端证书
chain
.pem
-
Apache根证书和中继证书
fullchain
.pem
-
Nginx所需要
ssl
_certificate文件
privkey
.pem
-
安全证书
KEY文件
ssl_certificate
/
etc
/
letsencrypt
/
live
/
ttync
.com
/
fullchain
.pem
;
ssl_certificate_key
/
etc
/
letsencrypt
/
live
/
ttync
.com
/
privkey
.pem
;
对应的证书位置:
|
配置nginx
server { listen 80; server_name 168seo.cn www.168seo.cn m.168seo.cn; return 301 https://$host$request_uri; # 非https 跳转到 https上 } server { listen 443; ssl on; server_name www.168seo.cn 168seo.cn; index index.html index.htm index.php default.html default.htm default.php; ssl_certificate /etc/letsencrypt/live/c.168seo.cn/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/c.168seo.cn/privkey.pem; # 证书位置 root /home/wwwroot/www.168seo.cn; include wordpress.conf; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/www.168seo.cn.log; # <span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/nginx" title="View all posts in nginx" target="_blank">nginx</a></span> 访问日志 }
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
|
server
{
listen
80
;
server
_name
168seo.cn
www
.
168seo.cn
m
.
168seo.cn
;
return
301
https
:
/
/
$host
$request_uri
;
# 非https 跳转到 https上
}
server
{
listen
443
;
ssl
on
;
server_name
www
.
168seo.cn
168seo.cn
;
index
index
.html
index
.htm
index
.php
default
.html
default
.htm
default
.php
;
ssl_certificate
/
etc
/
letsencrypt
/
live
/
c
.
168seo.cn
/
fullchain
.pem
;
ssl_certificate_key
/
etc
/
letsencrypt
/
live
/
c
.
168seo.cn
/
privkey
.pem
;
# 证书位置
root
/
home
/
wwwroot
/
www
.
168seo.cn
;
include
wordpress
.conf
;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include
enable
-
php
.conf
;
location
~
.
*
\
.
(
gif
|
jpg
|
jpeg
|
png
|
bmp
|
swf
)
$
{
expires
30d
;
}
location
~
.
*
\
.
(
js
|
css
)
?
$
{
expires
12h
;
}
location
~
/
.well
-
known
{
allow
all
;
}
location
~
/
\
.
{
deny
all
;
}
access_log
/
home
/
wwwlogs
/
www
.
168seo.cn.log
;
# nginx 访问日志
}
|
解决免费SSL证书有效期
Let's Encrypt证书是有效期90天的,需要我们自己手工更新续期才可以
./letsencrypt-auto certonly --renew-by-default --email admin@168seo.cn -d 168seo.cn -d c.168seo.cn
1
|
.
/
letsencrypt
-
auto
certonly
--
renew
-
by
-
default
--
email
admin
@
168seo.cn
-
d
168seo.cn
-
d
c
.
168seo.cn
|
这样我们在90天内再去执行一次就可以解决续期问题,这样又可以继续使用90天。如果我们怕忘记的话也可以制作成定时执行任务,比如每个月执行一次。
自动更新证书,续费方法二
这种方法也是可以的:https://github.com/Neilpang/acme.sh/wiki/%E8%AF%B4%E6%98%8E