您的位置:首页 > 其它

gitlab更新ssl证书

2017-08-22 00:00 761 查看
ssl用的是Let's Encrypt,但是只有三个月的有效期,但是至少是免费的呀。

其实gitlab上的服务器已经是启用了ssl,知识证书过期了。需要更新一下证书

网上我找到了这个命令

./certbot-auto renew --dry-run
用了这个命令也一样
./certbot-auto renew --force-renew

但是执行后的的输出是

WARNING: unable to check for updates.
Requesting root privileges to run certbot...
/home/ubuntu/.local/share/letsencrypt/bin/letsencrypt renew --dry-run
The standalone specific supported challenges flag is deprecated. Please use the --preferred-challenges flag instead.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Currently, the renew verb is capable of either renewing all installed certificates that are due to be renewed or renewing a single certificate specified by its name. If you would like to renew specific certificates by their domains, use the certonly command. The renew verb may provide other options for selecting certificates to renew in the future.

这个应该是更新失败了。

百度查了怎么跟新但是还是失败了,后来想想还是卸载重装一下好了。

在这个网站上有详细的教程。
certbot

开始选了nginx和ubuntu16.04的组合,但是失败了
后来我改为None of the above和ubuntu16.04的组合

命令行入下

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install certbot

$ sudo certbot certonly

因为我配置了ini文件,所以不需要用下面的命令

$ sudo certbot certonly --webroot -w /var/www/example -d example.com -d www.example.com -w /var/www/thing -d thing.is -d m.thing.is

这个是添加在/etc/letsencrypt/cli.ini或者在~/.config/letsencrypt/cli.ini中

agree-tos = true

rsa-key-size = 4096

email = admin@laozuo.com

#authenticator = standalone
standalone-supported-challenges = http-01
preferred-challenges = http

domain =laozuo.org

更新指令

$ sudo certbot renew --dry-run

certbot renew

执行命令过程中,会出现错误。原因是/boot目录空间不够或者apt-get本身需要跟新
解决方法可以查看我的博客。

如果是正常生产ssl证书

在完成Let's Encrypt证书的生成之后,我们会在"/etc/letsencrypt/live/laozuo.org/"域名目录下有4个文件就是生成的密钥证书文件。
cert.pem  - Apache服务器端证书
chain.pem  - Apache根证书和中继证书
fullchain.pem  - Nginx所需要ssl_certificate文件
privkey.pem - 安全证书KEY文件

从上面的列表中可以看出Nginx启用ssl需要fullchain.pem和privkey.pem

目前安装gitlab是使用自带的nginx来进行反向代理的

####一般在nginx的配置文件中添加ssl配置

server
{
listen 80;
listen 443 ssl;
#listen [::]:80;
ssl on;
ssl_certificate /root/ssl.crt;
ssl_certificate_key /root/ssl.key;
server_name laozuo.org www.laozuo.org;

nginx的安装目录是在

/var/opt/gitlab/nginx/

修改nginx中的配置文件

2、定时任务
脚本有了,还需要在linux中添加一个定期执行脚本的任务,这里用linux自带的cron来处理这部分。
crontab -e
在打开的编辑器中添加如下内容(每个月1号凌晨3点更新)
0    0  3 *  *  sh /mnt/web/lets/ssl_auto_auth.sh >/dev/null 2>&1 &

 #crontab -e

  00 00 00 */3 * /sbin/certbot renew --renew-hook "sudo gitlab-ctl start" --quiet > /dev/null 2>&1 &
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: