我很难让GitLab CI(8.8.5版)在单独的nginx(nginx/1.10.0,Ubuntu 14.04)配置下运行。我的GitLab实例运行良好,一切正常。什么是我可以在我的nginx配置文件中引用的gitlab-ci套接字的正确路径?我在gitlab目录中找不到任何东西。从零开始在8.8.5中设置GitLab CI的困难
以下是我设置(我代替我与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?提前谢谢你的帮助。
根据我自己的经验设置'ci_external_url'完全不做任何事情,无论 – Fairy
如何,CI已经可以从'http:// git.example.com/ci'获得不幸的是,网址'https://git.example.com/ci'重定向到我的GitLab仪表板。 –
它将您重定向到仪表板,但CI运行器将通过此URL与GitLab进行通信。使用URL https://git.example.com/ci注册跑步者适用于此。 – Fairy