Add nginx(8) server blocks

I want to manually add server blocks (vhost virtual hosts) to the nginx(8) configuration. I need to do this, because Gitlab is reserving all *.site.com domains for itself. My Gitlab host is called scm.site.com and I want to serve pages on www.site.com from the same host (with nginx.)

server {
  listen 80;
  root /var/www/scm.site.com;
  index.html index.htm;
  server_name scm.site.com;
  location / {
    try_files $uri $uri/ =404;
  }
}
server {
  listen 80;
  root /var/www/www.site.com;
  index.html index.htm;
  server_name www.site.com;
  location / {
    try_files $uri $uri/ =404;
  }
}

Can I put these lines in /etc/gitlab/gitlab.rb or configure nginx(8) in some other way, how do I achieve this?

Thanks!
Michael

Check out the custom nginx config setting in the gitlab.rb config.
https://docs.gitlab.com/omnibus/settings/nginx.html#inserting-custom-nginx-settings-into-the-gitlab-server-block

We used this for a number of custom sites on out gitlab server.

1 Like