以下文章内容在后面使用gitlab的时候会比较麻烦,请参考:https://blog.csdn.net/zhuwei_clark/article/details/90812175 进行配置
安装gitlab
yum -y install policycoreutils openssh-server openssh-clients postfix
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.4.3-ce.0.el7.x86_64.rpm
yum install policycoreutils-python
rpm -i gitlab-ce-11.4.3-ce.0.el7.x86_64.rpm
配置配置文件:
vim /etc/gitlab/gitlab.rb
设置配置内容
#禁用内置NG
nginx['enable'] = false
# 指定NG的用户名
web_server['external_users'] = ['root']
# 添加NG地址到信任列表,我这里就是本机地址
gitlab_rails['trusted_proxies'] = ['172.17.4.178']
# 配置监听网络:tcp
gitlab_workhorse['listen_network'] = "tcp"
# 配置GitLab的地址和端口
gitlab_workhorse['listen_addr'] = "172.17.4.179:6868"
重新加载配置文件,并重启
gitlab-ctl reconfigure
gitlab-ctl restart
查看gitlab的启动状态
gitlab-ctl status
配置nginx配置
upstream git{
server 172.17.4.179:6868 weight=1;
}
server {
listen 443;
server_name git.zhubanxian.com;
ssl on;
ssl_certificate /etc/nginx/vhosts/git/2220513_git.zhubanxian.com.pem;
ssl_certificate_key /etc/nginx/vhosts/git/2220513_git.zhubanxian.com.key;
location ~ ^/(.*){
proxy_pass http://git;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 80;
server_name git.zhubanxian.com;
location ^~ /.well-known/acme-challenge/ {
alias /data/sites/challenges/;
try_files $uri = 404;
}
location / {
rewrite ^/(.*)$ https://$host/$1 permanent;
}
}
重启nginx
systemctl restart nginx
使用域名进行访问