Gitlab-安装配置管理-12干掉内部Nginx,使用外部nginx(clone代码500错误)

本博文操作安装gitlab版本管理工具,采用配置使用外部的nginx来完成安装,集成安装可参考博文:https://blog.csdn.net/cen50958/article/details/93225968

nginx安装可参考博文:
https://blog.csdn.net/cen50958/article/details/89819419

Gitlab-基础安装
  • 参考安装博文:Gitlab-安装配置管理,安装步骤到:Gitlab相关配置 之前即可
使用外部Nginx(http服务)
  • 配置nginx配置文件

    #gitlab socket 文件地址
    upstream gitlab {
    server unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
    }
    
    server {
    listen *:80;
    
    server_name gitlab.silly.com;   # 请修改为你的域名
    
    server_tokens off;     # don't show the version number, a security best practice
    root /opt/gitlab/embedded/service/gitlab-rails/public;
    
    # Increase this if you want to upload large attachments
    # Or if you want to accept large git objects over http
    client_max_body_size 250m;
    
    # individual nginx logs for this gitlab vhost
    #access_log  /var/log/gitlab/nginx/gitlab_access.log;
    #error_log   /var/log/gitlab/nginx/gitlab_error.log;
    
    location / {
    	# serve static files from defined root folder;.
    	# @gitlab is a named location for the upstream fallback, see below
    	try_files $uri $uri/index.html $uri.html @gitlab;
    }
    
    # if a file, which is not found in the root folder is requested,
    # then the proxy pass the request to the upsteam (gitlab unicorn)
    location @gitlab {
    	# If you use https make sure you disable gzip compression 
    	# to be safe against BREACH attack
    
    	proxy_read_timeout 300; # Some requests take more than 30 seconds.
    	proxy_connect_timeout 300; # Some requests take more than 30 seconds.
    	proxy_redirect     off;
    
    	proxy_set_header   X-Forwarded-Proto $scheme;
    	proxy_set_header   Host              $http_host;
     proxy_set_header   X-Real-IP         $remote_addr;
    	proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
     proxy_set_header   X-Frame-Options   SAMEORIGIN;
    
    	proxy_pass http://gitlab;
    }
    
    # Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
     # WARNING: If you are using relative urls do remove the block below
    # See config/application.rb under "Relative url support" for the list of
    # other files that need to be changed for relative url support
    location ~ ^/(assets)/  {
    	root /opt/gitlab/embedded/service/gitlab-rails/public;
     # gzip_static on; # to serve pre-gzipped version
    	expires max;
     add_header Cache-Control public;
     }
    
    error_page 502 /502.html;
    }
    
  • 配置gitlab配置文件禁用nginx模块

    vim /etc/gitlab/gitlab.rb

    external_url 'http://gitlab.silly.com'
    web_server['external_users'] = ['nginx']
    nginx['enable'] = false
    
      ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190622154319247.png)
    

    在这里插入图片描述
    在这里插入图片描述

  • 初始化gitlab服务配置

    gitlab-ctl reconfigure
    
  • 启动gitlab服务

    gitlab-ctl restart
    

    启动的服务中没有nginx

    [root@localhost conf.d]# gitlab-ctl restart
    ok: run: alertmanager: (pid 10129) 0s
    ok: run: gitaly: (pid 10138) 0s
    ok: run: gitlab-monitor: (pid 10157) 1s
    ok: run: gitlab-workhorse: (pid 10160) 0s
    ok: run: logrotate: (pid 10169) 1s
    ok: run: node-exporter: (pid 10176) 0s
    ok: run: postgres-exporter: (pid 10187) 1s
    ok: run: postgresql: (pid 10197) 0s
    ok: run: prometheus: (pid 10209) 0s
    ok: run: redis: (pid 10220) 0s
    ok: run: redis-exporter: (pid 10229) 0s
    ok: run: sidekiq: (pid 10321) 1s
    ok: run: unicorn: (pid 10348) 0s

  • 启动外部的nginx

    /application/nginx/sbin/nginx -t
    /application/nginx/sbin/nginx -s reload
    
界面展示
  • 登录时候,显示错误信息
    Gitlab-安装配置管理-12干掉内部Nginx,使用外部nginx(clone代码500错误)_第1张图片
    原因: upstream gitlab {
    server unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
    } /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket nginx 用户无权访问
    解决:
     chmod o+x /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket 
    
问题
  • 克隆代码的时候提示:

    $ git -c http.sslVerify=false clone https://gitlab.silly.com/root/demo1.git
    Cloning into ‘demo1’…
    fatal: unable to access ‘https://gitlab.silly.com/root/demo1.git/’: The requested URL returned error: 500

    查看nginx日志:

    2019/06/23 00:21:13 [error] 11785#0: *46 connect() to unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket failed (111: Connection refused) while connecting to upstream,

    显示连接gitlab.socket failed 拒绝

希望哪位大神能够留言解决这个问题

你可能感兴趣的:(自动化部署)