Add a vhost to Nginx bundled with Omnibus


#1

I’d like to add a virtual host to my server running Gitlab. Googling suggests that I can run Apache instead, or switch to a stock version of Nginx (https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#using-a-non-bundled-web-server), but is it possible to just add another virtual host to the existing Nginx?

It looks like I would need to make some changes to /etc/gitlab/gitlab.rb so that they would end up in /var/opt/gitlab/nginx/conf/gitlab-http.conf.

Is this possible, or am I better off switching to Apache?

Thanks!

EDIT: looking at the Nginx documentation, it looks like I might just be able to change the existing server block so that it has:

server_name git.my_domain.com;

and then add a second server block that looks like this:

server {
    server_name www.my_domain.com;
    access_log  logs/www.access.log main;
    root /var/www.my_domain.com/htdocs;
}

But I’d have to somehow get that to be generated by /etc/gitlab/gitlab.rb, no?

EDIT2: Or can I just uncomment this line in /etc/gitlab/gitlab.rb:

# nginx['custom_nginx_config'] = "include /etc/nginx/conf.d/example.conf;"

and then create /etc/nginx/conf.d/example.conf and add another server block there?


#2

I’ve been trying to do the same thing, but I’m a bit concerned that you haven’t received a reply in 2 years :).

I’ve found 2 similar threads:


The stack overflow solution (by @Danny) seems to be the most complete, but I still can’t get it to work. Here’s the setup that I’ve tried:

gitlab.rb:

external_url '<OLD_URL>:30000'
gitlab_rails['gitlab_default_projects_features_builds'] = false
nginx['custom_nginx_config'] = "include /etc/nginx/conf.d/gitlab.conf;"

gitlab.conf

upstream gitlab {
  server <OLD_URL>:30000; 
}

server {
  listen *:80;
  server_name gitlab.lt.lab;
  server_tokens off;
  access_log  /var/log/gitlab_access.log;
  error_log   /var/log/gitlab_error.log;
  proxy_set_header Host      $host;
  proxy_set_header X-Real-IP $remote_addr;
  location / { proxy_pass  http://gitlab; }
}

Anyone know what I’m doing wrong?