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. 【转】【MySQL】Mysql模糊查询like提速优化

    在使用msyql进行模糊查询的时候,很自然的会用到like语句,通常情况下,在数据量小的时候,不容易看出查询的效率,但在数据量达到百万级,千万级的时候,查询的效率就很容易显现出来.这个时候查询的效率就 ...

  2. 【转】【Html】Vuejs2.0学习之二(Render函数,createElement,vm.$slots,函数化组件,模板编译,JSX)

    1.Render函数 所以直接来到Render,本来也想跳过,发现后面的路由貌似跟它还有点关联.先来看看Render 1.1 官网一开始就看的挺懵的,不知道讲的是啥,动手试了一下,一开头讲的是Rend ...

  3. 简单入门dos程序

    --1.关机程序 注意:文件保存为.bat echo 晚安了,宝贝! @echo off shutdown -s -t exist --2.快捷/批量启动程序 title "程序系统启动&q ...

  4. Activiti5.16.4部署小记

    版本说明 OS:Win7 JDK:jdk1.6.0_45 Tomcat:apache-tomcat-7.0.62(解压缩版) 部署过程 1.安装JDK,配置环境变量,so easy,具体过程就不写了, ...

  5. Spring Cloud 微服务的那点事

    什么是微服务 微服务的概念源于2014年3月Martin Fowler所写的一篇文章“Microservices”. 微服务架构是一种架构模式,它提倡将单一应用程序划分成一组小的服务,服务之间互相协调 ...

  6. Bulestacks模拟器Bulestacks.prop文件里中英文对照表

    打开“Bulestacks.prop”文件后可以看到以下内容,根据中英文对照表来修改即可. # begin build properties (开始设置系统性能)# autogenerated by ...

  7. WPF TextBox属性IsReadOnlyCaretVisible

    纠结了半天WPF下只读的TextBox怎么显示输入焦点提示,发现wpf 4中已有新属性“IsReadOnlyCaretVisible”,大善^_^

  8. Struts2+Hibernate+Spring(SSH)三大框架整合jar包

    Struts2 + Spring3 + Hibernate3 框架整合 1. 每个框架使用 (开发环境搭建 )* 表现层框架 struts2 1) jar包导入: apps/struts2_blank ...

  9. JSTL时间格式化项目小试

    我在之前的博客中虽然详尽的介绍了JSTL在各个载体中的用法,也介绍了它和EL的共同使用的好处,但是只是顺便提了一下JSTL的格式化. 今天在项目中遇到了一个小问题,也就想到这,马上就开始实践了一下,效 ...

  10. 【WP8】富文本功能实现

    2014年8月1日更新:修复如果有多个相同链接解析失败的Bug,谢谢 @Walsh 提供的问题 富文本在移动APP上应用的最多的就是表情了,类似微博,QQ,微信都有对提供对表情和链接的支持,富文本一般 ...