gitlab 使用现有 nginx 服务器
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 服务器的更多相关文章
- 2018.11.15 Nginx服务器的使用
Nginx简单教程 1.什么是Nginx? Nginx(engine x)是一款轻量级的Web服务器.反向代理服务器及电子邮件(IMAP/POP3)代理服务器 什么是反向代理服务器? 反向代理方式是指 ...
- 修改gitlab默认的nginx
目录 1. 修改gitlab的配置文件 2. nginx配置 3. 重载 前言: 本文将介绍,如何禁用gitlab自带的nginx,用已经安装的nginx提供web服务. 1. 修改gitlab的配置 ...
- Nginx 服务器 之Nginx与tomcat实现负载均衡
本文讲解我们如何使用Nginx做反向带服务器,实现nginx与tomcat服务器集群做负载均衡. 一.nginx与tomcat实现负载均衡 1.在/usr/local/ngnix/conf 创建 ...
- Nginx服务器 之反向代理与负载均衡
一.反向代理 正向代理: 客户端要获取的资源就在服务器上,客户端请求的资源路径就是最终响应资源的服务器路径,这就是正向代理.正向代理的特点:就是我们明确知道要访问哪个网站地址. 反向代理: 客户端想获 ...
- 把域名绑定到某个项目,以nginx服务器为例
一:登陆域名服务器平台,把域名解析到项目对应的IP上面. 二:配置nginx服务器 1./etc/nginx/conf.d/ 在服务器该目录下,添加.conf文件,如命名为:www.demo.com. ...
- 在阿里云服务器(ECS)上从零开始搭建nginx服务器
本文介绍了如何在阿里云服务器上从零开始搭建nginx服务器.阿里云服务器(ECS)相信大家都不陌生,感兴趣的同学可以到http://www.aliyun.com/product/ecs去购买,或到体验 ...
- nginx入门篇----nginx服务器基础配置
1.nginx.conf文件结构... #全局块 events{ ... } http #http块{ ...
- --with-http_realip_module选项(后台Nginx服务器记录原始客户端的IP地址 )
转自:http://blog.itpub.net/27043155/viewspace-734234/ 通过这个模块允许我们改变客户端请求头中客户端IP地址值(例如,X-Real-IP 或 X-For ...
- 【转】Nginx服务器的反向代理proxy_pass配置方法讲解
[转]Nginx服务器的反向代理proxy_pass配置方法讲解 转自:http://www.jb51.net/article/78746.htm 就普通的反向代理来讲Nginx的配置还是比较简单的, ...
随机推荐
- VMware Fusion 5 正式版序列号
HV4KJ-2X10K-VZ768-DRAGP-8CU2F MY63N-D0HE2-0ZXC1-HV954-937JL
- ubuntu 安装bazel
https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu
- 【转】【Python】Python3爬虫实现自动登录、签到
工具:Fiddler 首先下载安装Fiddler,这个工具是用来监听网络请求,有助于你分析请求链接和参数. 打开目标网站:http://www.17sucai.com/,然后点击登录 好了,先别急着登 ...
- 利用MATLAB进行曲线拟合
软件环境:MATLAB2013a 一.多项式拟合 多项式拟合是利用多项式最佳地拟合观测数据,使得在观测数据点处的误差平方和最小. 在MATLAB中,利用函数ployfit和ployval进行多项式拟合 ...
- Mybatis表关联一对多
有了前面几章的基础,对一些简单的应用是可以处理的,但在实际项目中,经常是关联表的查询,比如:最常见到的多对一,一对多等.这些查询是如何处理的呢,这一讲就讲这个问题.前面几篇教程中介绍的都是单表映射的一 ...
- 某软件大赛C#版考题整理——【编程题】
三.编程题(4小题共40.0分)程序及结果写入对应文框内 1. 孪生素数查找程序. 所谓孪生素数指的是间隔为2 的相邻素数,就像孪生兄弟.最小的孪生素数是(3, 5),在100 以内的孪生素数还有 ( ...
- Java虚拟机性能管理神器 - VisualVM(4) - JDK版本与VisualVM版本对应关系
Java虚拟机性能管理神器 - VisualVM(4) - JDK版本与VisualVM版本对应关系 JDK版本与VisualVM版本对应关系说明 JDK版本与VisualVM版本对应关系 参 ...
- php函数返回引用示例
<?php class Test { public $userCache; public function init() { for($i = 0; $i < 5; $i++) { $us ...
- vue的安装
第一步:环境的搭建 : vue推荐开发环境: Node.js: javascript运行环境(runtime),不同系统直接运行各种编程语言(https://nodejs.org/zh-cn/down ...
- Objective-C语法之扩展(Extension)的使用
Objective-C 2.0增加了Class Extension用于解决两个问题: 可声明私有可读写的属性,而在类的声明中是同名的公开只读属性,从而来支持公开只读.私有可读写的属性 可声明私有方法: ...