首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gitlab_ci重定向到gitlab

gitlab_ci重定向到gitlab
EN

Stack Overflow用户
提问于 2014-01-10 05:07:45
回答 1查看 2.2K关注 0票数 1

我刚刚用这个安装指南用nginx安装了安装指南(一步一步地遵循它,一切都很好)。

我在同一台机器( gitlab.loc )上运行了一个gitlab安装。我为gitlab_ci使用的域是"gitlab-ci.loc“。

我正在使用为nginx提供的配置(刚刚将server_name更改为gitlab-ci.loc)。

问题:当我试图在浏览器中打开gitlab-ci.loc时,它会给我gitlab页面,就像我已经调用了gitlab.loc而不是gitlab-ci.loc一样。浏览器地址会占用gitlab-ci.loc,所以我想我在nginx配置中做了一些工作。

用于gitlab_ci的nginx

代码语言:javascript
复制
# 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 # GITLAB #维护者的nginx conf:@ 5.0 # App版本:5.0

代码语言:javascript
复制
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;
  }
}

config/application.yml

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-11 18:33:59

不能将两个服务器定义为default_server。第二个将不会加载,而定义的第一个将接管所有请求。将listen行更改为

代码语言:javascript
复制
listen *:80;

再给Nginx装子弹。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21036584

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档