Moving GitLab to a non-standard port
We love GitLab and use it for a ton of our internal (and client) projects. We recently had to move it from HTTP port 80 and SSH port 22 to a non-standard ports and we were unable to find sufficient documentation on this process, causing us to waste more hours than I’d like to admit figuring it out.
We used port 8081 for the HTTP traffic and 2222 for SSH. Before doing these steps make sure you have the new ports open on your router if you need to access them from outside your local network, etc.
So for anyone who is interested here’s the skinny:
- Modify /home/git/gitlab/gitlab.yml
Add (or uncomment) the bold line below for your new HTTP port:
## GitLab settings
## Web server settings
Next, add (or uncomment) the line below for your new SSH port:
# If you use non-standard ssh port you need to specify it
- Modify /home/git/gitlab-shell/config.yml to use the new HTTP port:
# Url to gitlab instance. Used for api calls. Should end with a slash.
- Modify /etc/nginx/sites-available/gitlab
listen *:8081 default_server; # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
- Modify /etc/ssh/sshd_config
# What ports, IPs and protocols we listen for
- Restart SSH, restart GitLab, restart nginx:
sudo service ssh restart
sudo service gitlab restart
sudo service nginx restart
- Test GitLab:
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
- Update the remote origins for your repos to use the new port:
Hope this helps someone save a little time!