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:
sudo -e /etc/gitlab/gitlab.rb- Change external_url from
yourdomain.comtoyourdomain.com:9999
9999-> Port you want it to run sudo gitlab-ctl reconfigure
Changing the default Gitlab port - Stack Overflow
How do I properly change the gitlab port in my case? - Infrastructure as Code & Cloud Native - GitLab Forum
Which ports must be open for firewall configuration
Some questions about the GitLab
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:
sudo -e /etc/gitlab/gitlab.rb- Change external_url from
yourdomain.comtoyourdomain.com:9999
9999-> Port you want it to run sudo gitlab-ctl reconfigure
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
Issue here: https://gitlab.com/gitlab-org/gitlab-ce/issues/20131
Workaround:
add this line to /etc/gitlab/gitlab.rb:
nginx['proxy_set_headers'] = { "X-Forward-Port" => "8080", "Host" => "<hostname>:8080" }
replace port and hostname with your values, then as root or with sudo:
gitlab-ctl reconfigure
gitlab-ctl restart
It helps me on Debian 8.5, gitlab-ce from gitlab repo.
In addition of external_url, the documentation also suggests to set a few NGiNX proxy headers:
By default, when you specify
external_url, omnibus-gitlab will set a few NGINX proxy headers that are assumed to be sane in most environments.For example, omnibus-gitlab will set:
"X-Forwarded-Proto" => "https",
"X-Forwarded-Ssl" => "on"
(if you have specified https schema in the
external_url).However, if you have a situation where your GitLab is in a more complex setup like behind a reverse proxy, you will need to tweak the proxy headers in order to avoid errors like The change you wanted was rejected or Can't verify CSRF token authenticity Completed 422 Unprocessable.
This can be achieved by overriding the default headers, eg. specify in
/etc/gitlab/gitlab.rb:
nginx['proxy_set_headers'] = {
"X-Forwarded-Proto" => "http",
"CUSTOM_HEADER" => "VALUE"
}
Save the file and reconfigure GitLab for the changes to take effect.
This way you can specify any header supported by NGINX you require.
The OP ewcz confirms in the comments:
I just uncommented the default settings for
nginx['proxy_set_headers']in/etc/gitlab/gitlab.rb(also, changingX-Forwarded-Prototohttpand removingX-Forwarded-Ssl) and suddenly it works!
I am trying to run gitlab over HTTPS on a non standard port (8443 instead of the standard 443).
I am running a reverse proxy, for SSL termination and running gitlab locally using port 3001. So for example, locally I can go to http://192.168.1.31:3001 and I will get to the login page.
What I want is to be able to do https://git.example.com:8443 to access my gitlab.
I followed the gitlab documentation for proxied SSL termination (https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#supporting-proxied-ssl) and it almost works exactly as I need it to, except sometimes the internal links don't add the port 8443 at the end of URL, the page will timeout and if I manually add the 8443 to the URL bar, then it will go to the correct page.
I have setup my configuration as follows:
I'm using the omnibus docker image (https://hub.docker.com/r/gitlab/gitlab-ce/)
I'm using port 3001 mapped to 80 locally for HTTP. I don't need to use the HTTPS locally. I'm not using SSH at all.
In gitlab.rb, I've added:
external_url 'https://git.example.com:8443'
nginx['listen_addresses'] = ['*', '[::]']
nginx['listen_port'] = 80
nginx['listen_https'] = false
nginx['real_ip_trusted_addresses'] = ['192.168.1.0/24', '192.168.1.31']
nginx['real_ip_header'] = 'X-Real-IP'
nginx['real_ip_recursive'] = 'on
My NGINX Reverse proxy config is nothing special. The server definition is here: https://pastebin.com/4rXQcFFC.
The Issue: If I go to the URL, https://git.example.com:8443 it will give a 502 error and times out. The 8443 disappears. If I manually type it in the login page appears. I put in the login information, but then when I press the login button, it times out again and I have to manually add the 8443, this does work and it brings me to the dashboard. Here, many of the links work correctly, they show the correct port number however some links don't, if I create a new repository, the project path by default will not have the port number in the URL field. If I create the project, again the 8443 will not be added to the URL. That being said, I can navigate around the website dashboard without any issues since the URLs have the correct port number.
tl;dr: Is there some other variable I need to set in the config file to have the port number appended to all the URLs or is this a bug? Or maybe something else I didn't think of.
Thanks!
EDIT: If I type https://git.example.com:8443 into an private firefox browser, it will time out after 30s trying to go to https://git.example.com/users/sign_in. Somewhere along the line, the 8443 is not appended correctly into the URL. If I type https://git.example.com:8443/users/sign_in directly, it works right away. The issue seems to be anytime it needs to dynamically append something to the end of the URL, it does not take the port into account whereas static URLs on the dashboard such as Groups, activities, milestones, etc at the top nav bar.