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. 初试PyOpenGL一 (Python+OpenGL)

    很早就一直想学Python,看到一些书都有介绍,不管是做为游戏的脚本语言,还是做为开发项目的主要语言都有提及(最主要的CUDA都开始支持Python,CUDA后面一定要学),做为先熟悉一下Python ...

  2. c 预处理的宏定义

    概念 以“#”号开头的都是预处理命令 例如 #include <stdio.h>宏定义 宏定义无参数的宏名后不带参数# 表示这是一条预处理命令, define 为宏定义命令.“标识符”为所 ...

  3. postman-记录cookies信息

    接口:赞我的列表,get请求,要登陆用户信息 http://v80.pcauto.com.cn/xsp/s/auto/info/nocache/club/getPraiseMyDynas.xsp?pa ...

  4. (笔记)Linux下的简单CGI编程

    为什么要进行CGI编程?  在HTML中,当客户填写了表单,并按下了发送(submit)按钮后,表单的内容被发送到了服务器端,一般的,这时就需要有一个服务器端脚本来对表单的内容进行一些处理,或者是把它 ...

  5. 2014年第五届蓝桥杯C/C++B组省赛题目解析

    一.啤酒和饮料 啤酒每罐2.3元,饮料每罐1.9元.小明买了若干啤酒和饮料,一共花了82.3元. 我们还知道他买的啤酒比饮料的数量少,请你计算他买了几罐啤酒. 注意:答案是一个整数.请通过浏览器提交答 ...

  6. C++编程基础练习

    注:本文练习题均出自<Essential C++>第一章 练习1,1 从一个简单程序开始 #include<iostream> #include<string> u ...

  7. 初识ZooKeeper与集群搭建实例

    原文链接:http://www.linuxidc.com/Linux/2015-02/114230.htm zookeeper是什么 Zookeeper,一种分布式应用的协作服务,是Google的Ch ...

  8. Python中的base64模块

    本文介绍Python 2.7中的base64模块,该模块提供了基于rfc3548的Base16, 32, 64编解码的接口.官方文档,参考这里. 该模块提供两套接口,传统接口基于rfc1521的Bas ...

  9. [原创] MSP430G2系列图形化编程相关资料

    1.TI官方工具GRACE以及CCS介绍以及下载地址:http://www.ti.com.cn/tool/cn/grace 2.教程资料: ①手把手教你使用GRACE:   http://www.do ...

  10. Dependency Scopes(maven)

    Dependency scope 是用来限制Dependency的作用范围的, 影响maven项目在各个生命周期时导入的package的状态. 自从2.0.9后,新增了1种,现在有了6种scope: ...