gitlab 安装自带 nginx,如果想利用原有 nginx,可按如下操作:

8.0 版本 socket 文件位置有变动,感谢评论区的同学。

  • nginx 增加虚拟主机配置

    # gitlab socket 文件地址
    upstream gitlab {
    # 7.x 版本在此位置
    # server unix:/var/opt/gitlab/gitlab-rails/tmp/sockets/gitlab.socket;
    # 8.0 位置
    server unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
    } server {
    listen *:80; server_name gitlab.liaohuqiu.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;
    }
  • 禁用自带 nginx

    vim /etc/gitlab/gitlab.rb

    加入

    nginx['enable'] = false
  • 重启 nginx, 重启gitlab

    sudo /usr/local/nginx/sbin/nginx -s reload
    sudo gitlab-ctl reconfigure
  • 权限配置

    访问会报502。原本是 nginx 用户无法访问gitlab用户的 socket 文件,用户权限配置,因人而异。粗暴地:

    sudo chmod -R o+x /var/opt/gitlab/gitlab-rails
    
    
    . 拷贝一份内置nginx 的配置文件 gitlab-http.conf  到新的nginx的配置中
    . 修改 /etc/gitlab/gitlab.rb ,禁用nginx nginx[enable] = false
    . vim /etc/gitlab/gitlab.rb external_url 'http://git.qiwenqiqu.com' #域名配置
    unicorn['listen'] = '0.0.0.0'
    unicorn['port'] =
    # git_data_dirs({ "default" => { "path" => "/var/opt/gitlab/git-data" } })
    git_data_dirs({ "default" => { "path" => "/data/git-data" } }) #web_server['external_users'] = ['nginx','gitlab-www','git','www','www-data']
    #新nginx用户www能够访问gitlab,很重要
    web_server['external_users'] = ['www'] #然后 gitlab-ctl reconfigure ,然后 gitlab-ctl restart
    #备忘录 ,比较乱 忽略
    
    gitlab 坑
    ./embedded/service/gitlab-shell/lib/gitlab_config.rb ./embedded/lib/ruby/gems/2.3.0/gems/omniauth-gitlab-1.0.2/lib/omniauth/strategies/gitlab.rb
    ./embedded/cookbooks/cache/cookbooks/gitlab/libraries/gitlab.rb
    ./embedded/cookbooks/gitlab/libraries/gitlab.rb
    ./embedded/service/gitlab-rails/lib/gitlab.rb 1.[端口不通]
    vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
    listen "0.0.0.0:8081", :tcp_nopush => true
    一定不要用 127.0.0.1 firewall-cmd --permanent --add-port=8081/tcp
    firewall-cmd --reload 1.[样式错乱] gitlab error compiling css asset
    vim ./embedded/service/gitlab-rails/config/gitlab.yml
    webhook_timeout: 120 gitlab 数据迁移
    http://blog.csdn.net/hj7jay/article/details/54311010 vim /etc/gitlab/gitlab.rb external_url 'http://git.qiwenqiqu.com' #域名配置
    unicorn['listen'] = '0.0.0.0'
    unicorn['port'] = 8081
    # git_data_dirs({ "default" => { "path" => "/var/opt/gitlab/git-data" } })
    git_data_dirs({ "default" => { "path" => "/data/git-data" } })
    [迁移数据注意目录名称不要写错了] #web_server['external_users'] = ['nginx','gitlab-www','git','www','www-data']
    web_server['external_users'] = ['www’] 配置文件位置: [
    /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
    /etc/gitlab/gitlab.rb
    /opt/gitlab/embedded/service/gitlab-shell/config.yml
    ] 域名配置
    vim /opt/gitlab/embedded/service/gitlab-shell/config.yml
    gitlab_url: "http://0.0.0.0:8081" ####
    配置GitLab域名,否则项目git clone的地址时错
    vim /etc/gitlab/gitlab.rb 编辑:external_url '你的网址' 例如:external_url 'http://192.168.1.100' 编辑完成后,再sudo gitlab-ctl reconfigure一下,使配置生效 #### ### gitlab配置 http://www.cnblogs.com/softidea/p/5229412.html ### nginx 冲突配置
    https://docs.gitlab.com/omnibus/settings/nginx.html
    https://gitlab.com/gitlab-org/gitlab-workhorse/issues/26 $$
    2017/04/25 00:18:37 [crit] 6297#0: *32 connect() to unix:/var/opt/gitlab/gitlab-workhorse/socket failed (13: Permission denied) while connecting to upstream, client: 221.216.146.9, server: test.qiwenqiqu.com, request: "GET / HTTP/1.1", upstream: "http://unix:/var/opt/gitlab/gitlab-workhorse/socket:/", host: "test.qiwenqiqu.com"
    $$
    $$sudo usermod -aG gitlab-www www$$
     

gitlab 使用现有 nginx 服务器的更多相关文章

  1. 2018.11.15 Nginx服务器的使用

    Nginx简单教程 1.什么是Nginx? Nginx(engine x)是一款轻量级的Web服务器.反向代理服务器及电子邮件(IMAP/POP3)代理服务器 什么是反向代理服务器? 反向代理方式是指 ...

  2. 修改gitlab默认的nginx

    目录 1. 修改gitlab的配置文件 2. nginx配置 3. 重载 前言: 本文将介绍,如何禁用gitlab自带的nginx,用已经安装的nginx提供web服务. 1. 修改gitlab的配置 ...

  3. Nginx 服务器 之Nginx与tomcat实现负载均衡

      本文讲解我们如何使用Nginx做反向带服务器,实现nginx与tomcat服务器集群做负载均衡. 一.nginx与tomcat实现负载均衡 1.在/usr/local/ngnix/conf  创建 ...

  4. Nginx服务器 之反向代理与负载均衡

    一.反向代理 正向代理: 客户端要获取的资源就在服务器上,客户端请求的资源路径就是最终响应资源的服务器路径,这就是正向代理.正向代理的特点:就是我们明确知道要访问哪个网站地址. 反向代理: 客户端想获 ...

  5. 把域名绑定到某个项目,以nginx服务器为例

    一:登陆域名服务器平台,把域名解析到项目对应的IP上面. 二:配置nginx服务器 1./etc/nginx/conf.d/ 在服务器该目录下,添加.conf文件,如命名为:www.demo.com. ...

  6. 在阿里云服务器(ECS)上从零开始搭建nginx服务器

    本文介绍了如何在阿里云服务器上从零开始搭建nginx服务器.阿里云服务器(ECS)相信大家都不陌生,感兴趣的同学可以到http://www.aliyun.com/product/ecs去购买,或到体验 ...

  7. nginx入门篇----nginx服务器基础配置

    1.nginx.conf文件结构...                         #全局块  events{  ...  }  http                      #http块{ ...

  8. --with-http_realip_module选项(后台Nginx服务器记录原始客户端的IP地址 )

    转自:http://blog.itpub.net/27043155/viewspace-734234/ 通过这个模块允许我们改变客户端请求头中客户端IP地址值(例如,X-Real-IP 或 X-For ...

  9. 【转】Nginx服务器的反向代理proxy_pass配置方法讲解

    [转]Nginx服务器的反向代理proxy_pass配置方法讲解 转自:http://www.jb51.net/article/78746.htm 就普通的反向代理来讲Nginx的配置还是比较简单的, ...

随机推荐

  1. HashMap的长度为什么要是2的n次方

    HashMap为了存取高效,要尽量较少碰撞,就是要尽量把数据分配均匀,每个链表长度大致相同,这个实现就在把数据存到哪个链表中的算法: 这个算法实际就是取模,hash%length,计算机中直接求余效率 ...

  2. thinkphp 伪静态 自定义后缀

    <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.we ...

  3. 批量kill 进程

    场景: 需要批量kill tail 进程. 解决方法: ps -ef | grep IC.IndexServer.log | grep -v grep | awk -F' ' '{print $2}' ...

  4. 转载:手把手教你做iOS推送

    手把手教你做iOS推送 http://www.cocoachina.com/industry/20130321/5862.html

  5. iOS7以上: 实现如“日历”的 NavigationBar

    第一步,隐藏导航栏底部的分割线 如何隐藏导航栏底部的分割线(shadow image/ hairline)? navigationBar.clipsToBounds = YES; //隐藏 navig ...

  6. c++ String去除头尾空格

    1.使用string的find_first_not_of,和find_last_not_of方法 #include <iostream> #include <string> s ...

  7. 空基类优化—— EBCO—— empty base class optimization

    完全参考自:<C++ Templates The Complete Guide>e_CN,p_281 16.2 空基类优化 最近周围有点吵,论文没看进去,随便翻了本书…… 下文没有多大意义 ...

  8. Java基础之深入理解Class对象与反射机制

    深入理解Class对象 RRIT及Class对象的概念 RRIT(Run-Time Type Identification)运行时类型识别.在<Thinking in Java>一书第十四 ...

  9. MongoDB的php可视化管理工具

    使用MongoDB命令查看很不方便 于是想把爬来的数据导出来,看爬来的数据是否正确 打开cmd,执行 mongoexport -d test -c blogs --csv -f title,link, ...

  10. C++标准命名空间std

    输入输出要用到这个. 标准C++库的所有的标识符都是在一个名为std的命名空间中定义的,或者说标准头文件(如iostream)中函数.类.对象和类模板是在命名空间 std中定义的.std是standa ...