1. letsencrypt 证书申请. 官方指引
1. 申请证书需要安装Cerbto. 脚本
yum -y install epel-release
yum -y install yum-utils
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
yum install certbot python2-certbot-nginx
2. 手动去申请证, 我这里申请全部子域名的. 验证身份的方式需要在域名供应商添加dns txt的.
1. 开始安装, 有下面提示信息. 这里需要暂停, 去添加DNS TXT即第2步.
# 执行
certbot certonly -d "*.actiger.com" --manual --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory
执行到下面提示信息后, 需要暂停.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#Please deploy a DNS TXT record under the name
#_acme-challenge.actiger.com with the following value:
#
#这里是需要添加的DNS TXT信息
#
#Before continuing, verify the record is deployed.
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3. 添加DNS TXT
1. 在域名服务商中, 添加DNS TXT
2. 测试DNS TXT是否生效.
# Windows
nslookup -qt=mx _acme-challenge.actiger.com
# Mac linux
dig TXT _acme-challenge.actiger.com
看到你添加的DNS TXT才可以执行确认, 进行下一步.
成功后, 会告诉证书存放位置, 及什么时间到期

3. 拉取docker-compose文件, 运行.
1. 注意修改内容, 非常重要.
docker-compose.yml 中 需要更改为自己的.
2. 拉取运行, hugo文件也拉取到nginx-https-hugoBlog文件夹中.
# 拉取docker-compose文件
git clone https://github.com/Charles-one/docker-compose-repository.git ~/docker-compose-repository
cp -r ~/docker-compose-repository/nginx-https-hugoBlog ~/nginx-https-hugoBlog
# 进入文件夹, 执行前, 注意修改内容
cd ~/nginx-https-hugoBlog
# 在目录中获取自己的hugo博客
# https方式
git clone https://github.com/Charles-one/www.actiger.com.git
# 使用ssh的方式git clone [email protected]:Charles-one/www.actiger.com.git
# 运行
docker-compose run -d
目录结构

截取nginx配置
server {
listen 80;
server_name www.actiger.com;
# 把80端口http请定向到https
return 301 https://actiger.com$request_uri;
}
server{
listen 443 ssl;
ssl on;
ssl_certificate /etc/letsencrypt/live/actiger.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/actiger.com/privkey.pem;
*
*
*
这里错乱的
需要hugo使用新baseurl生成博客目录, 原来的http://www.actiger.com/更改为https://www.actiger.com/
hugo --theme=hugo-paper --baseUrl="https://actiger.com/" --destination="www.actiger.com"
上传提交博客到github上, 并到在服务器上拉取代码.
cd ~/nginx-https-hugoBlog/www.actiger.com/
git pull