@lijianying10
2016-04-06T08:24:59.000000Z
字数 758
阅读 1232
LE
Docker
准备配置文件
docker run -it --rm -v /root/:/data/ nginx cp -rf /etc/nginx /data/le
mkdir /root/le/static
新建的文件夹是用来给letsencrypt存放中间文件的位置。
修改配置文件/root/le/conf.d/default.conf
location / {
root /etc/nginx/static/;
index index.html index.htm;
}
中间nginx跑起来:
docker run -it -d --name lenginx -p 8989:80 -v /root/le/:/etc/nginx/ --net=aaa nginx
测试:
# curl http://127.0.0.1:8989/
a
返回a就成功了。
开始配置目标域名A 记录到服务器
在线上服务器: /etc/nginx/conf.d/your.domain.conf
location /.well-known {
proxy_pass http://lenginx.aaa;
}
这里反向代理到刚才开的nginx 进程。
这样就可以从生产服务器组的nginx进程就可以到专门的证书申请的nginx进程里面了。(这个进程可以复用所以独立出来一个容器来运行。)
运行letsencrypt
docker run -it -d --name le -v /root/le/static/:/webroot index.tenxcloud.com/philo/le:0 /bin/bash
letsencrypt-auto certonly -a webroot --webroot-path=/usr/share/nginx/html -d example.com -d www.example.com
然后这证书就申请下来了。