从头开始在 8.8.5 中设置 GitLab CI 的困难
Difficulties setting up GitLab CI in 8.8.5 from scratch
我很难获得 GitLab CI(版本 8.8.5)运行 单独的 nginx(nginx/1.10.0,Ubuntu 14.04)配置。我的 GitLab 实例 运行 很好,一切正常。我可以在 nginx 配置文件中引用的 gitlab-ci 套接字的正确路径是什么?我在gitlab目录下没有找到任何东西。
这是我设置的(我用example.com替换了我的真实域名):
GitLab 设置 /etc/gitlab/gitlab.rb
:
external_url 'http://git.example.com'
ci_external_url 'https://ci.example.com'
gitlab_rails['time_zone'] = 'Europe/Berlin'
web_server['external_users'] = ['www-data']
nginx['enable'] = false
ci_nginx['enable'] = false
GitLab nginx 配置文件/etc/nginx/sites-enabled/gitlab
:
upstream gitlab-workhorse {
server unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket fail_timeout=0;
}
server {
listen *:443;
ssl on;
ssl_certificate /etc/letsencrypt/live/git.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/git.example.com/privkey.pem;
server_name git.example.com;
server_tokens off;
root /opt/gitlab/embedded/service/gitlab-rails/public;
access_log /var/log/nginx/git.example.com/access.log;
error_log /var/log/nginx/git.example.com/error.log;
location / {
client_max_body_size 0;
gzip off;
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;
}
}
server {
listen 80;
server_name git.example.com;
return 301 https://$host$request_uri;
}
GitLab CI nginx 配置文件 /etc/nginx/sites-enabled/gitlab-ci
:
upstream gitlab_ci {
server unix:/var/opt/gitlab/gitlab-ci/sockets/gitlab.socket;
}
server {
listen *:443;
server_name ci.example.com;
server_tokens off;
ssl on;
ssl_certificate /etc/letsencrypt/live/git.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/git.example.com/privkey.pem;
root /opt/gitlab/embedded/service/gitlab-ci/public;
client_max_body_size 250m;
access_log /var/log/nginx/ci.example.com/access.log;
error_log /var/log/nginx/ci.example.com/error.log;
location / {
try_files $uri $uri/index.html $uri.html @gitlab_ci;
}
location @gitlab_ci {
proxy_read_timeout 300;
proxy_connect_timeout 300;
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_ci;
}
}
server {
listen 80;
server_name ci.example.com;
return 301 https://$host$request_uri;
}
nginx 错误日志会打印如下:
tail -f /var/log/nginx/ci.example.com/error.log
2016/06/17 11:07:31 [crit] 6192#0: *30 connect() to unix:/var/opt/gitlab/gitlab-ci/sockets/gitlab.socket failed (2: No such file or directory) while connecting to upstream, client: XX.XX.XX.XX, server: ci.example.com, request: "GET /robots.txt HTTP/1.1", upstream: "http://unix:/var/opt/gitlab/gitlab-ci/sockets/gitlab.socket:/robots.txt", host: "XX.XX.XX.XX"
检查 GitLab 目录时,我没有找到任何可以在我的配置中引用的套接字:
/var/opt/gitlab # ls -lF *
-rw------- 1 root root 38 Jan 19 14:57 bootstrapped
git-data:
drwxrws--- 11 git git 4096 Feb 24 16:26 repositories/
gitlab-ci:
drwx------ 2 git root 4096 Jan 19 14:56 builds/
gitlab-rails:
drwx------ 2 git root 4096 Jun 17 11:00 etc/
-rw-r--r-- 1 root root 8 Jun 15 16:42 REVISION
-rw-r--r-- 1 root root 58 Mar 22 16:41 RUBY_VERSION
drwxr-x--x 5 git gitlab-www 4096 Jan 19 14:56 shared/
drwxr-x--- 2 git gitlab-www 4096 Jun 15 16:42 sockets/
drwx------ 3 git root 4096 Jan 19 16:19 tmp/
drwx------ 2 git root 4096 Jun 15 16:42 upgrade-status/
drwx------ 7 git gitlab-www 4096 Feb 9 12:57 uploads/
-rw-r--r-- 1 root root 6 Jun 15 16:42 VERSION
drwx------ 2 git root 4096 Jan 19 14:56 working/
gitlab-shell:
-rw-r--r-- 1 root root 1823 Jun 17 10:51 config.yml
-rw-r--r-- 1 root root 129 Jan 19 14:56 gitlab_shell_secret
gitlab-workhorse:
srwxrwxrwx 1 git git 0 Jun 15 16:42 socket=
-rw-r--r-- 1 root root 40 Jun 15 16:42 VERSION
logrotate:
-rw-r--r-- 1 root root 425 Feb 24 22:18 logrotate.conf
drwx------ 2 root root 4096 Jun 17 11:00 logrotate.d/
-rw-r--r-- 1 root root 880 Jun 17 10:52 logrotate.status
nginx:
drwx------ 2 gitlab-www root 4096 Jan 19 14:57 client_body_temp/
drwxr-x--- 2 root gitlab-www 4096 Jun 17 11:00 conf/
drwx------ 2 gitlab-www root 4096 Jan 19 14:57 fastcgi_temp/
lrwxrwxrwx 1 root root 21 Jan 19 14:57 logs -> /var/log/gitlab/nginx/
drwx------ 8 gitlab-www root 4096 Jan 19 15:49 proxy_temp/
drwx------ 2 gitlab-www root 4096 Jan 19 14:57 scgi_temp/
drwx------ 2 gitlab-www root 4096 Jan 19 14:57 uwsgi_temp/
postgresql:
drwx------ 14 gitlab-psql root 4096 Jun 17 11:00 data/
redis:
-rw------- 1 gitlab-redis gitlab-redis 201024 Jun 17 11:10 dump.rdb
-rw-r--r-- 1 gitlab-redis root 29778 Mar 3 16:16 redis.conf
srwxrwxrwx 1 gitlab-redis gitlab-redis 0 Jun 15 16:41 redis.socket=
我错过了什么?有没有人可以给我提示如何正确设置我的 GitLab CI?提前感谢您的帮助。
从 8.0 版开始,GitLab CI 已完全集成到 GitLab 中。这实际上意味着不需要特定的 CI 配置,只需一个通用的 GitLab nginx 文件。
如果您的 external_url
是 http://gitlab.example.com
,那么您的 CI 已经可供 http://gitlab.example.com/ci
的跑步者使用。使用此 URL 为 GitLab CI.
注册您的跑步者
我很难获得 GitLab CI(版本 8.8.5)运行 单独的 nginx(nginx/1.10.0,Ubuntu 14.04)配置。我的 GitLab 实例 运行 很好,一切正常。我可以在 nginx 配置文件中引用的 gitlab-ci 套接字的正确路径是什么?我在gitlab目录下没有找到任何东西。
这是我设置的(我用example.com替换了我的真实域名):
GitLab 设置 /etc/gitlab/gitlab.rb
:
external_url 'http://git.example.com'
ci_external_url 'https://ci.example.com'
gitlab_rails['time_zone'] = 'Europe/Berlin'
web_server['external_users'] = ['www-data']
nginx['enable'] = false
ci_nginx['enable'] = false
GitLab nginx 配置文件/etc/nginx/sites-enabled/gitlab
:
upstream gitlab-workhorse {
server unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket fail_timeout=0;
}
server {
listen *:443;
ssl on;
ssl_certificate /etc/letsencrypt/live/git.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/git.example.com/privkey.pem;
server_name git.example.com;
server_tokens off;
root /opt/gitlab/embedded/service/gitlab-rails/public;
access_log /var/log/nginx/git.example.com/access.log;
error_log /var/log/nginx/git.example.com/error.log;
location / {
client_max_body_size 0;
gzip off;
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;
}
}
server {
listen 80;
server_name git.example.com;
return 301 https://$host$request_uri;
}
GitLab CI nginx 配置文件 /etc/nginx/sites-enabled/gitlab-ci
:
upstream gitlab_ci {
server unix:/var/opt/gitlab/gitlab-ci/sockets/gitlab.socket;
}
server {
listen *:443;
server_name ci.example.com;
server_tokens off;
ssl on;
ssl_certificate /etc/letsencrypt/live/git.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/git.example.com/privkey.pem;
root /opt/gitlab/embedded/service/gitlab-ci/public;
client_max_body_size 250m;
access_log /var/log/nginx/ci.example.com/access.log;
error_log /var/log/nginx/ci.example.com/error.log;
location / {
try_files $uri $uri/index.html $uri.html @gitlab_ci;
}
location @gitlab_ci {
proxy_read_timeout 300;
proxy_connect_timeout 300;
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_ci;
}
}
server {
listen 80;
server_name ci.example.com;
return 301 https://$host$request_uri;
}
nginx 错误日志会打印如下:
tail -f /var/log/nginx/ci.example.com/error.log
2016/06/17 11:07:31 [crit] 6192#0: *30 connect() to unix:/var/opt/gitlab/gitlab-ci/sockets/gitlab.socket failed (2: No such file or directory) while connecting to upstream, client: XX.XX.XX.XX, server: ci.example.com, request: "GET /robots.txt HTTP/1.1", upstream: "http://unix:/var/opt/gitlab/gitlab-ci/sockets/gitlab.socket:/robots.txt", host: "XX.XX.XX.XX"
检查 GitLab 目录时,我没有找到任何可以在我的配置中引用的套接字:
/var/opt/gitlab # ls -lF *
-rw------- 1 root root 38 Jan 19 14:57 bootstrapped
git-data:
drwxrws--- 11 git git 4096 Feb 24 16:26 repositories/
gitlab-ci:
drwx------ 2 git root 4096 Jan 19 14:56 builds/
gitlab-rails:
drwx------ 2 git root 4096 Jun 17 11:00 etc/
-rw-r--r-- 1 root root 8 Jun 15 16:42 REVISION
-rw-r--r-- 1 root root 58 Mar 22 16:41 RUBY_VERSION
drwxr-x--x 5 git gitlab-www 4096 Jan 19 14:56 shared/
drwxr-x--- 2 git gitlab-www 4096 Jun 15 16:42 sockets/
drwx------ 3 git root 4096 Jan 19 16:19 tmp/
drwx------ 2 git root 4096 Jun 15 16:42 upgrade-status/
drwx------ 7 git gitlab-www 4096 Feb 9 12:57 uploads/
-rw-r--r-- 1 root root 6 Jun 15 16:42 VERSION
drwx------ 2 git root 4096 Jan 19 14:56 working/
gitlab-shell:
-rw-r--r-- 1 root root 1823 Jun 17 10:51 config.yml
-rw-r--r-- 1 root root 129 Jan 19 14:56 gitlab_shell_secret
gitlab-workhorse:
srwxrwxrwx 1 git git 0 Jun 15 16:42 socket=
-rw-r--r-- 1 root root 40 Jun 15 16:42 VERSION
logrotate:
-rw-r--r-- 1 root root 425 Feb 24 22:18 logrotate.conf
drwx------ 2 root root 4096 Jun 17 11:00 logrotate.d/
-rw-r--r-- 1 root root 880 Jun 17 10:52 logrotate.status
nginx:
drwx------ 2 gitlab-www root 4096 Jan 19 14:57 client_body_temp/
drwxr-x--- 2 root gitlab-www 4096 Jun 17 11:00 conf/
drwx------ 2 gitlab-www root 4096 Jan 19 14:57 fastcgi_temp/
lrwxrwxrwx 1 root root 21 Jan 19 14:57 logs -> /var/log/gitlab/nginx/
drwx------ 8 gitlab-www root 4096 Jan 19 15:49 proxy_temp/
drwx------ 2 gitlab-www root 4096 Jan 19 14:57 scgi_temp/
drwx------ 2 gitlab-www root 4096 Jan 19 14:57 uwsgi_temp/
postgresql:
drwx------ 14 gitlab-psql root 4096 Jun 17 11:00 data/
redis:
-rw------- 1 gitlab-redis gitlab-redis 201024 Jun 17 11:10 dump.rdb
-rw-r--r-- 1 gitlab-redis root 29778 Mar 3 16:16 redis.conf
srwxrwxrwx 1 gitlab-redis gitlab-redis 0 Jun 15 16:41 redis.socket=
我错过了什么?有没有人可以给我提示如何正确设置我的 GitLab CI?提前感谢您的帮助。
从 8.0 版开始,GitLab CI 已完全集成到 GitLab 中。这实际上意味着不需要特定的 CI 配置,只需一个通用的 GitLab nginx 文件。
如果您的 external_url
是 http://gitlab.example.com
,那么您的 CI 已经可供 http://gitlab.example.com/ci
的跑步者使用。使用此 URL 为 GitLab CI.