Set gitlab external web port number

Solution 1:

Chad Carbert answer still applies but just want to add extra for version 7.0.0.

Open "/etc/gitlab/gitlab.rb" in your text editor where currently I have external_url http://127.0.0.1/ or similar to that. I may need to change external_url with dns including port number (eg. 'http://gitlab.com.local:81/') then reconfigure using command "sudo gitlab-ctl reconfigure" Gitlab is now working on port 81.

Step by step:

  1. sudo -e /etc/gitlab/gitlab.rb
  2. Change external_url from yourdomain.com to yourdomain.com:9999
    9999 -> Port you want it to run
  3. sudo gitlab-ctl reconfigure

Solution 2:

Very Simple way to change defaults port number

gitlab-ctl stop

edit the file in centos or linux:- /var/opt/gitlab/nginx/conf/gitlab-http.conf

change listen *:80; to what you want Ex:- 90

then

Don't run the command- gitlab-ctl reconfigure

If gitlab-ctl reconfigure it configured gitlab by defaults and remove changes.

so only run- gitlab-ctl start


Solution 3:

I'm also having this same issue. I don't have my gitlab.rb in the same location as you, but do have it installed via dpkg at the /opt path you mentioned.

If you've installed it via the package, all self-contained in that /opt directory, then you might find changing the port at :

  • /opt/gitlab/embedded/conf/nginx.conf
  • /opt/gitlab/embedded/cookbooks/gitlab/templates/default/nginx-gitlab-http.conf.erb

Issue #6581: .deb package install on Ubuntu 12.04 - Port number in gitlab.yml file is ignored


Solution 4:

With Ubuntu 17.04 and gitlab-ce 9.2.2, on local network

These steps worked for me:

  1. Edit gitlab.rb file.

sudo nano /etc/gitlab/gitlab.rb

  1. Add your optional listen port to end of file.

nginx['listen_port'] = 8181

  1. Stop apache if needed, and reconfigure gitlab

sudo service apache2 stop sudo gitlab-ctl reconfigure

  1. Start apache if you stop that.

sudo service apache2 start

  1. Finished, now gitlab is available on your ip address with selected port.

'http://localhost:8181'


Solution 5:

My main issue was that new users were not getting the custom port number in the emails that the system sent. Otherwise, manually writing the custom port in the address bar led users to the Gitlab install.

I did this install on Ubuntu 14.04 instead of the Omnibus. So somehow I don't have gitlab-ctl. (It exists in /usr/bin, but the target of the symlink wasn't installed somehow. I'll fix that separately if I really have to.)

Anyway, I used a variant of the second approach, writing the correct port into /home/git/gitlab/config/gitlab.yml:

production: &base
  #
  # 1. GitLab app settings
  # ==========================

  ## GitLab settings
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: my.gitlab.host.com
    port: 3722

Since I don't have gitlab-ctl, I used service:

sudo service gitlab restart

That worked for me. New users that I sent the email to received a link which contained the correct URL.

Tags:

Gitlab