gitlab 使用现有 nginx 服务器
2017-10-30 18:53
260 查看
gitlab 安装自带 nginx,如果想利用原有 nginx,可按如下操作:
8.0 版本 socket 文件位置有变动,感谢评论区的同学。
nginx 增加虚拟主机配置
禁用自带 nginx
加入
重启 nginx, 重启gitlab
权限配置
访问会报502。原本是 nginx 用户无法访问gitlab用户的 socket 文件,用户权限配置,因人而异。粗暴地:
点击打开链接
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 s 4000 econds. 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
点击打开链接
相关文章推荐
- gitlab 使用现有 nginx 服务器
- gitlab 使用现有 nginx 服务器
- 使用nginx做为rails的服务器
- 解决无法使用http访问安装好nginx和ftp的图片服务器的问题
- 轻松使用Nginx搭建web服务器 推荐
- 服务器文件[置顶] nginx的配置和使用
- ubuntu下使用nginx搭建流媒体服务器,实现视频点播
- GitLab 服务器下客户端TortoiseGit配置和使用教程
- rails应用在passenger + nginx服务器下使用proxy_cache及proxy_cache_purge模块的方法
- Git使用教程(4)-搭建GitLab服务器
- Ubuntu 使用apt-get安装nginx服务器
- 使用VMware虚拟机迁移现有的服务器
- 使用nginx搭建简单的文件服务器
- 使用 Nginx 创建服务器的负载均衡
- 使用NGiNX_HTTP_Push_Module实现简单的服务器推送
- 使用 nginx 和 rtmp 插件搭建视频直播和点播服务器
- Nginx服务器的配置,使用Lua语言在MySQL数据交互
- 使用nginx搭建https服务器(转)
- web服务器使用HTTPS,基于tomcat :nginx配置
- 使用Nginx反向代理tomcat服务器