Skip to content

Instantly share code, notes, and snippets.

@atd-schubert
Last active February 26, 2024 12:14
Show Gist options
  • Save atd-schubert/d30998e5d245e993c264 to your computer and use it in GitHub Desktop.
Save atd-schubert/d30998e5d245e993c264 to your computer and use it in GitHub Desktop.
gitlab with own nginx

How to setup gitlab without embedded nginx

Install via omnibus-package

install the normal way:

wget https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.7.2-omnibus.5.4.2.ci-1_amd64.deb & > /dev/null

sudo apt-get update
sudo apt-get upgrade

sudo apt-get install -y vim openssh-server postfix

# When download has finished:
sudo dpkg -i gitlab_7.7.2-omnibus.5.4.2.ci-1_amd64.deb

Edit the /etc/gitlab/gitlab.rb-file. Configure only the following settings:

  • external_url: http://{your-hostname}
  • ci_external_url: http://{your-hostname}:3000

Run gitlab-ctl reconfigure.

Open a browser and open your gitlab and your gitlab-ci-page.

Copy the url-callback from ci webpage

Go to the gitlab page and login with

  • Username: root
  • Password: 5iveL!fe

and create your own password and login again.


Go to Admin-Area -> Applications -> New Application and setup something similar to:

  • Name: gitlab-Ci
  • Redirect URI: {the url that was passed on gitlab-ci page as callbackurl}

You got an application id and a Secret. You have to copy this in your /etc/gitlab/gitlab.rb-file on:

  • gitlab_ci['gitlab_server'] = { "url" => '{gitlab-url}', "app_id" => '{app-id}', "app_secret" => '{app-secret}' }

and uncomment this line and save the document.


Run gitlab-ctl reconfigure again.


Now login on gitlab ci and authorize with oauth.

Change to unbundled nginx

"Everything should work"


Call gitlab-ctl stop


Install nginx

# maybe uninstall existing first: sudo apt-get purge nginx nginx-common nginx-full

sudo apt-get install -y nginx

cp /var/opt/gitlab/nginx/conf/gitlab* /etc/nginx/sites-enabled/

service nginx restart

Open /etc/gitlab/gitlab.rb-file again and set:

  • web_server['external_users'] = ['www-data']
  • nginx['enable'] = false

and call

gitlab-ctl reconfigure
gitlab-ctl start

"Everything should work... again"

With unbundled nginx


@zackify
Copy link

zackify commented Aug 30, 2015

I love you 🙏 was looking everywhere for how to do this.

@CanRau
Copy link

CanRau commented Aug 25, 2017

thanks! :) 👍 💯 🥇

@melroy89
Copy link

So how about Gitlab pages??

@rachitharoun
Copy link

Thanks, thanks

@michelk
Copy link

michelk commented Jul 17, 2018

Gitlab pages??

@Incanus3
Copy link

Incanus3 commented Mar 5, 2020

Hi folks,
I just spent most of the day finding out how to do this, so I thought I'd share. If you want to regenerate the nginx config files without running the whole cookbook, you can reenable the nginx['enable'] option, run

/opt/gitlab/embedded/bin/chef-client -z -c /opt/gitlab/embedded/cookbooks/solo.rb -o 'recipe[gitlab::config],recipe[gitlab::nginx]'

copy the files from /var/opt/gitlab/nginx/conf/, than disable the option again and run

/opt/gitlab/embedded/bin/chef-client -z -c /opt/gitlab/embedded/cookbooks/solo.rb -o 'recipe[gitlab::config],recipe[gitlab::nginx_disable]'

. NOTE: if you don't want chef to start the embedded nginx service during the first run, you should also set the bootstrap['enable'] option to false beforehand and possibly reenable it afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment