centOS安装gitlab并使用外部nginx且支持https

8 篇文章 0 订阅
5 篇文章 0 订阅

以下文章内容在后面使用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

使用域名进行访问

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值