我刚刚使用此gitlab_ci在nginx上安装了installation guide(一步一步跟着它,一切正常)。
我在同一台机器上运行gitlab安装(gitlab.loc)。 我将用于gitlab_ci的域是“gitlab-ci.loc”。
我正在使用nginx提供的配置(刚刚将server_name更改为gitlab-ci.loc)。
问题:当我尝试在浏览器中打开gitlab-ci.loc时,它会向我发送gitlab页面,就像我调用gitlab.loc而不是gitlab-ci.loc一样。 浏览器地址schows gitlab-ci.loc,所以我想我在nginx配置中做了一些wrog。
nginx conf for gitlab_ci
# GITLAB CI
# Maintainer: @randx
# App Version: 2.0
upstream gitlab_ci {
server unix:/home/gitlab_ci/gitlab-ci/tmp/sockets/gitlab-ci.socket;
}
server {
listen *:80 default_server; # e.g., listen 192.168.1.1:80;
server_name gitlab-ci.loc; # e.g., server_name source.example.com;
root /home/gitlab_ci/gitlab-ci/public;
access_log /var/log/nginx/gitlab_ci_access.log;
error_log /var/log/nginx/gitlab_ci_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_pass http://gitlab_ci;
}
# adjust this to match the largest build log your runners might submit,
# set to 0 to disable limit
client_max_body_size 10m;
}
gitlab的nginx conf #GITLAB #Maintainer:@randx #App版本:5.0
upstream gitlab {
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}
server {
listen *:80 default_server; # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
server_name gitlab.loc; # e.g., server_name source.example.com;
server_tokens off; # don't show the version number, a security best practice
root /home/git/gitlab/public;
# Set value of client_max_body_size to at least the value of git.max_size in gitlab.yml
client_max_body_size 5m;
# individual nginx logs for this gitlab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/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 {
proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
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_pass http://gitlab;
}
}
配置/ application.yml
defaults: &defaults
allowed_gitlab_urls:
- 'https://dev.gitlab.org/'
- 'https://staging.gitlab.org/'
## Gitlab CI settings
gitlab_ci:
## Web server settings
host: gitlab-ci.loc
port: 80
https: false
## Email settings
# Email address used in the "From" field in mails sent by GitLab-CI
email_from: gitlab-ci@localhost
# Email address of your support contact (default: same as email_from)
support_email: support@localhost
# Send emails for all failing builds
# all_broken_builds: true
# Add committer to recipients list
# add_committer: true
gravatar:
enabled: true
plain_url: "http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm"
ssl_url: "https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm"
development:
<<: *defaults
neat_setting: 800
test:
<<: *defaults
allowed_gitlab_urls:
- 'http://demo.gitlab.com/'
production:
<<: *defaults
答案 0 :(得分:2)
您不能将两台服务器定义为default_server
。第二个不会加载,首先定义的那个将接管所有请求。将其中一个listen
行更改为
listen *:80;
并重新加载Nginx。