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的配置还是比较简单的, ...
随机推荐
- Java相对路径/绝对路径总结
Version:0.9 StartHTML:-1 EndHTML:-1 StartFragment:00000099 EndFragment:00019826 Java相对路径/绝对路径总结(2) 修 ...
- e839. 使JTabbedPane中的卡片可滚动
By default, all the tabs in a tabbed pane are displayed. When the tabs are wider than the width of t ...
- CI框架 -- URI 路由
一般情况下,一个 URL 字符串和它对应的控制器中类和方法是一一对应的关系. URL 中的每一段通常遵循下面的规则:example.com/class/function/id/ 但是有时候,你可能想改 ...
- image 和 barplot 的组合
代码示例: par(mfrow = c(1, 2)) par(mar = c(1, 10, 1, 0), las = 1, ann = F) image(1:10, 1:10, matrix(samp ...
- perl 中的引用
perl 语言中的引用共分为两类: 声明引用时只需要在对象的前面加上反斜杠 第一列是数组的引用: 代码示例: , , ); my $array_ref = \@array; 第二种是哈希的引用 代码示 ...
- 各种linux小操作
1.查看路由表 命令:route -n ; netstat -r 跟踪网络地址:traceroute www.16 3.com 2.查看一台机器IP地址和与其对应的域名 命令:nslookup; di ...
- log4net按照不同的【LEVEL】级别输出到不同文件
Log4net按照不同级别写入多个日志文件 2012-02-08 15:06 by Fred-Xu, ... 阅读, ... 评论, 收藏, 编辑 在一个Web应用项目中,我使用了Fluent NHi ...
- 《经久不衰的Spring框架:@ResponseBody 中文乱码》(转)
转载自:http://www.cnblogs.com/shanrengo/p/6429291.html 问题背景 本文并不是介绍@ResponseBody注解,也不是中文乱码问题的大汇总笔记,这些网上 ...
- Java常量池的理解
1.常量池的好处常量池是为了避免频繁的创建和销毁对象而影响系统性能,其实现了对象的共享.例如字符串常量池,在编译阶段就把所有的字符串文字放到一个常量池中.(1)节省内存空间:常量池中所有相同的字符串常 ...
- tftp + bras
Ubuntu 12.04 网卡设置 开发板ip时192.168.0.2,设置的服务ip是192.168.0.1 因此在主机上/etc/network/interfaces添加如下内容 auto eth ...