我很难让GitLab CI(版本8.8.5)运行单独的nginx(nginx / 1.10.0,Ubuntu 14.04)配置。我的GitLab实例运行良好,一切正常。 gitlab-ci套接字的正确路径是什么,我可以在我的nginx配置文件中引用它?我在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?感谢您的帮助。
答案 0 :(得分:0)
从8.0版开始,GitLab CI完全集成到GitLab中。这实际上意味着不需要特定的CI配置,只需要一般的GitLab nginx文件。
如果您的external_url
为http://gitlab.example.com
,那么您的CI已经可用于http://gitlab.example.com/ci
上的参赛者。使用此URL为GitLab CI注册您的跑步者。