2014-01-10 46 views
1

我剛剛安裝了gitlab_ci與nginx使用此installation guide(按照它一步一步,所有工作正常)。gitlab_ci重定向到gitlab

我有一個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爲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; 
} 

nginx的CONF爲gitlab #GITLAB #維護者:@randx #應用版本: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: [email protected] 

    # Email address of your support contact (default: same as email_from) 
    support_email: [email protected] 

    # 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 

回答

2

你不能有兩個s錯誤定義爲default_server。第二個不會加載,首先定義的將接管所有請求。將其中一個listen行改爲

listen *:80; 

並重新加載Nginx。

+0

完美地工作,謝謝。 :) – DasBaconfist