docker安装部署gitlab,docker安装部署gitlab配置使用外部nginx
一、docker安装gitlab镜像
1,镜像信息
https://hub.docker.com/r/gitlab/gitlab-ce/
docker pull gitlab/gitlab-ce
2,启动镜像
sudo docker run --detach \ --hostname git.tmy.com \ --publish 8929:80 --publish 2289:22 \ --name gitlab \ --restart always \ --volume /data/gitlab/config:/etc/gitlab \ --volume /data/gitlab/logs:/var/log/gitlab \ --volume /data/gitlab/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest
文档地址:https://docs.gitlab.com/omnibus/docker/#run-the-image
3,访问本机安装的gitlab
127.0.0.1:8929 端口号为步骤2中设置的端口号。
此处不知何种原因,启动了需要等待几分钟才可以访问,知道的大神可以六个言交流下。
可以访问之后继续往下走。
二、配置使用外部的nginx服务器
1,关闭gitlab内部的nginx服务
官方文档地址:https://docs.gitlab.com/omnibus/settings/nginx.html#using-a-non-bundled-web-server
启动的时候映射出来的目录 vim /data/gitlab/config/gitlab.rb 在配置文件最末尾加上配置nginx['enable'] = false web_server['external_users'] = ['www-data'] 使配置生效 docker exec gitlab gitlab-ctl reconfigure
2,配置本机上的nginx
新nginx虚拟机配置文件,我的虚拟机配置文件在/usr/local/nginx/conf/vhost
vim /usr/local/nginx/conf/vhost/git.tmy.com.conf
下载官方的配置文件
https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/nginx
配置文件有http 和 https两个版本,这里我选择了http第一个
## GitLab 8.3+ ## ## Lines starting with two hashes (##) are comments with information. ## Lines starting with one hash (#) are configuration parameters that can be uncommented. ## ################################## ## CONTRIBUTING ## ################################## ## ## If you change this file in a Merge Request, please also create ## a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests ## ################################### ## configuration ## ################################### ## ## See installation.md#using-https for additional HTTPS configuration details. upstream gitlab-workhorse { server unix:/var/opt/gitlab/gitlab-workhorse/socket; } ## Normal HTTP host server { ## Either remove "default_server" from the listen line below, ## or delete the /etc/nginx/sites-enabled/default file. This will cause gitlab ## to be served if you visit any address that your server responds to, eg. ## the ip address of the server (http://x.x.x.x/)n 0.0.0.0:80 default_server; listen 0.0.0.0:80 default_server; listen [::]:80 default_server; server_name YOUR_SERVER_FQDN; ## Replace this with something like gitlab.example.com server_tokens off; ## Don't show the nginx version number, a security best practice root /opt/gitlab/embedded/service/gitlab-rails/public; ## See app/controllers/application_controller.rb for headers set ## Individual nginx logs for this GitLab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; location / { client_max_body_size 0; gzip off; ## https://github.com/gitlabhq/gitlabhq/issues/694 ## Some requests take more than 30 seconds. proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_http_version 1.1; 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-Forwarded-Proto $scheme; proxy_pass http://gitlab-workhorse; } }
将配置文件写入刚才创建的虚拟机文件配置文件中。修改
#找到 upstream gitlab-workhorse { server unix:/var/opt/gitlab/gitlab-workhorse/socket; } #修改为 upstream gitlab-workhorse { server unix:/data/gitlab/data/gitlab-workhorse/socket; } #找到 server_name YOUR_SERVER_FQDN; #修改为 server_name git.tmy.com 【域名是你自己配置好的域名】 #找到 access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; #改为 access_log /data/wwwlogs/gitlab_access.log; error_log/data/wwwlogs/gitlab_error.log; #上边是日志文件而已,改称你自己的就行
配置完成后检查nginx -t 是否正常,没问题重新载入配置即可。
三、修改目录权限
chown -R www:www /data/gitlab/data/gitlab-workhorse/
修改完成后访问git.tmy.com 即可进入gitlab的web界面了
点击链接加入群聊三群:751529538
点击链接加入群聊二群:376877156
点击链接加入群聊【路由器交流群:622891808已满】
本站附件分享,如果附件失效,可以去找找看
饿了么红包