Centos7 安装gitlab-ce 并开启HTTPS

最近想研究基于Kubernetes的CI/CD,没想到在Gitlab-ce安装上花费了挺多功夫,特此记录

1 安装

  1. 安装依赖 yum -y install curl policycoreutils postfix
  2. 开启postfix 邮件服务 systemctl start postfix && systemctl enable postfix
  3. 安装omnibus Gitlab-ce。在Centos7上,国内不建议使用官方镜像源,所以本次采用清华提供的镜像源
    详细描述在这

2 配置

因为是使用https访问,则需要建立自签证书(有余力的小伙伴可以使用CA方式签发)

mkdir /etc/gitlab/ssl
openssl genrsa -out "/etc/gitlab/ssl/gitlab.examle.com.key" 2048
openssl req -new -key "/etc/gitlab/ssl/gitlab.examle.com.key" -out "/etc/gitlab/ssl/gitlab.examle.com.csr"  #相关信息自己填好
openssl x509 -req -days 3650 -in "/etc/gitlab/ssl/gitlab.examle.com.csr" -signkey "/etc/gitlab/ssl/gitlab.examle.com.key" -out "/etc/gitlab/ssl/gitlab.examle.com.crt"
chmod 600 /etc/gitlab/ssl/*
vim /etc/gitlab/gitlab.rb   #以下是修改的内容
external_url 'https://gitlab.examle.com'
nginx['redirect_http_to_https'] = true
unicorn['port'] = 9091  #默认是8080,与我的k8s-apiserver 非安全端口冲突
gitlab_workhorse['auth_backend'] = "http://localhost:9091"
gitlab_rails['webhook_timeout'] = 90
gitlab_rails['git_timeout']=90

# 关闭gitlab-ce ,然后重新配置
gitlab-ctl stop
gitlab-ctl reconfigure

# 修改gitlab nginx conf
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf 
#在server_name下面添加
 rewrite ^(.*)$ https://$host$1 permanent;
 
gitlab-ctl start

在主机的Hosts加入 gitlab域名的dns解析后,进入gitlab网页如下

登录页

发布了8 篇原创文章 · 获赞 4 · 访问量 2078

猜你喜欢

转载自blog.csdn.net/weixin_40864891/article/details/99208479
今日推荐