1

i just installed gitlab_ci with nginx using this installation guide (followed it step-by-step and all worked fine).

I have a gitlab installation running in the same machine ( gitlab.loc ). The Domain I wnat to use for gitlab_ci is "gitlab-ci.loc".

I'm using the provided configuration for nginx (just changed server_name to gitlab-ci.loc).

The Problem: When I try to open gitlab-ci.loc in my Browser it delivers me the gitlab page, like if i had called gitlab.loc instead of gitlab-ci.loc. The Browser address schows gitlab-ci.loc, so i think i done something wrog in nginx configuration.

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;
}

nginx conf for gitlab # GITLAB # Maintainer: @randx # App Version: 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;
  }
}

config/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

1 Answer 1

2

You cannot have two servers defined as default_server. The second one will not load, and the one defined first will take over all requests. Change one of the listen lines to

listen *:80;

and reload Nginx.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.