码迷,mamicode.com
首页 > 其他好文 > 详细

Omnibus Gitlab CentOS 7使用Let's Encrypt配置免费ssl

时间:2016-08-05 13:41:02      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:

首先安装omnibus gitlab,参照

https://about.gitlab.com/downloads/

 

参照以下两篇文章结合配置:

https://certbot.eff.org/#centosrhel7-nginx

https://webnugget.de/setting-up-gitlab-with-free-ssl-certs-from-lets-encrypt-on-ubuntu-14-04/

 

1.安装certbot。

$ sudo yum install epel-release
$ sudo yum install certbot

 

2.配置gitlab:

$ vi /etc/gitab/gitlab.rb
更改以下配置项:
external_url "http://gityu.com/"

nginx[‘redirect_http_to_https‘] = true

nginx[‘ssl_certificate‘]= "/etc/letsencrypt/live/gityu.com/fullchain.pem"

nginx[‘ssl_certificate_key‘] = "/etc/letsencrypt/live/gityu.com/privkey.pem"  
nginx[‘custom_gitlab_server_config‘]="location ^~ /.well-known {\n alias /var/www/letsencrypt/.well-known;\n}\n"  

重启gitlab:

$ gitlab-ctl reconfigure

3.生成证书:
$ certbot certonly

按照步骤配置如下图:

使用webroot插件,填写域名:gityu.com,

根路径:/var/www/letsencrypt

 

技术分享

 

技术分享
技术分享
技术分享
技术分享
 
技术分享
最后成功安装,有效期90天。

 

4.生效https://:

$ vi /etc/gitlab/gitlab.rb

更改:

external_url "https://gityu.com/"
 

重启gitlab使生效:

$ gitlab-ctl reconfigure

 
此时可以访问gityu.com会自动重定向到https://gityu.com,并且证书为绿色:

技术分享

 

5.创建crontab job,自动更新证书。

$ vi /etc/cron.monthly/renew-ssl-certificates

填入以下内容:
 
certbot renew --quiet 

这样每个月更新一次,也可以使用crontab -e来创建crontab job。

 

注意,使用此命令之前先使用以下命令验证是否可以成功更新:

$ certbot renew --dry-run

 如果命令失败,那么可以使用以下文章中的方法作为备用:

 https://webnugget.de/setting-up-gitlab-with-free-ssl-certs-from-lets-encrypt-on-ubuntu-14-04/

即使用以下脚本来自动更新:

#!/bin/bash

/bin/letsencrypt certonly -c /root/letsencrypt-config/gitlab.ini --renew-by-default

gitlab-ctl restart

Omnibus Gitlab CentOS 7使用Let's Encrypt配置免费ssl

标签:

原文地址:http://www.cnblogs.com/flasheryu/p/5740862.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!