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.

Answer from Konstantin Šuvakin on Stack Overflow
🌐
GitLab
docs.gitlab.com › gitlab docs › install › installation methods › linux package › package information › package defaults
Package defaults | GitLab Docs
Connection port - Port on which the component communicates. GitLab also expects a file system to be ready for the storage of Git repositories and various other files.
🌐
GitLab
forum.gitlab.com › how to use gitlab
Gitlab keeps using port 80 - How to Use GitLab - GitLab Forum
April 5, 2022 - I have an Nginx server installed, where I host some stuff, and a GitLab server. I configured Gitlab so, that it should use port 8081, but it keeps blocking port 80, which then prevents my Nginx installation from binding to port 80.
Discussions

Changing the default Gitlab port - Stack Overflow
I have installed the latest Gitlab-CE (8.10) on CentOS 7 (fresh install) via the Omnibus package as described here: https://about.gitlab.com/downloads/#centos7 Now, I would like to change the defa... More on stackoverflow.com
🌐 stackoverflow.com
How do I properly change the gitlab port in my case? - Infrastructure as Code & Cloud Native - GitLab Forum
I would like example.com to point to my website on port 80. I would also like gitlab.example.com to load the gitlab web app. Since gitlab by default also uses port 80 or 443, I need to change gitlabs port. I have not installed gitlab yet because I am unsure how I should accomplish this. More on forum.gitlab.com
🌐 forum.gitlab.com
0
August 20, 2020
Which ports must be open for firewall configuration
If we run self-hosted Gitlab EE, and we deploy it in a service like AWS or GCP. Which ports in our Gitlab instance need to be accessible for ingress and egress in firewall configuration? For instance, all services of Gitlab EE are active. Thank you. More on forum.gitlab.com
🌐 forum.gitlab.com
1
1
November 10, 2021
Some questions about the GitLab
Hello, I have GitLab installed on Debian 12.5 and have a few questions: 1- Which ports should be open on the server? 2- Can I protect GitLab with AppArmor? 3- Please introduce some tips to increase security? Thank you. More on forum.gitlab.com
🌐 forum.gitlab.com
19
0
March 4, 2024
🌐
Hoop
hoop.dev › blog › what-gitlab-port-actually-does-and-when-to-use-it
What GitLab Port Actually Does and When to Use It
October 17, 2025 - GitLab uses ports to control how its services communicate across environments. The GitLab Port defines how GitLab runners, web services, and CI pipelines route traffic. Whether you’re managing a self-hosted install on AWS or a managed cluster through Kubernetes, mapping the correct port keeps deployments predictable and your CI/CD pipeline alive.
Top answer
1 of 2
15

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.

2 of 2
1

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, changing X-Forwarded-Proto to http and removing X-Forwarded-Ssl) and suddenly it works!

🌐
Port
docs.port.io › install an integration › git › gitlab (deprecated)
GitLab | Port
Sync GitLab projects, merge requests, and pipelines into Port's software catalog.
🌐
GitLab
about.gitlab.com › blog › engineering › gitlab.com now supports an alternate git+ssh port
GitLab.com now supports an alternate git+ssh port
February 18, 2016 - You'd be happy to know that GitLab.com now runs an alternate git+ssh port (443) which you can use whenever you are in a place where port 22 is blocked.
🌐
GitLab
forum.gitlab.com › infrastructure as code & cloud native
How do I properly change the gitlab port in my case? - Infrastructure as Code & Cloud Native - GitLab Forum
August 20, 2020 - I would like example.com to point to my website on port 80. I would also like gitlab.example.com to load the gitlab web app. Since gitlab by default also uses port 80 or 443, I need to change gitlabs port.
Find elsewhere
🌐
GitLab
forum.gitlab.com › how to use gitlab
Which ports must be open for firewall configuration - How to Use GitLab - GitLab Forum
November 10, 2021 - If we run self-hosted Gitlab EE, and we deploy it in a service like AWS or GCP. Which ports in our Gitlab instance need to be accessible for ingress and egress in firewall configuration? For instance, all services of Git…
🌐
Commvault
documentation.commvault.com › saas › port_requirements_for_gitlab.html
Port Requirements for GitLab
&gt Commvault SaaS &gt DevOps Solutions &gt GitLab &gt Configure a GitLab App &gt Use Your Access Nodes · The access node must have internet access to download the repos and metadata. The following table contains network ports that must be opened for backing up GitLab.
🌐
Medium
pezhvak.medium.com › how-to-spin-up-gitlab-on-docker-reusable-host-ports-2cfd220c74b0
How to spin up GitLab on docker + reusable host ports | by Pezhvak IMV | Medium
November 4, 2021 - Here's docker-compose.yml file ... other gitlab.rb configuration here, each on its own line ports: - '8880:8880' - '4443:443' - '2222:22' - '5050:5050' volumes: - '$GITLAB_HOME/config:/etc/gitlab' - '$GITLAB_HOME/logs:/va...
🌐
Port
docs.port.io › backend types › gitlab pipeline › self-hosted
Self-hosted GitLab - Port Documentation
If you use the self-hosted version of GitLab in your organization, you will need to use the Port execution agent to trigger your pipelines from Port.
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › manage your organization › gitlab.com settings
GitLab.com settings | GitLab Docs
Host gitlab.com Hostname altssh.gitlab.com User git Port 443 PreferredAuthentications publickey IdentityFile ~/.ssh/gitlab
🌐
GitLab
forum.gitlab.com › general
Some questions about the GitLab - General - GitLab Forum
March 4, 2024 - Hello, I have GitLab installed on Debian 12.5 and have a few questions: 1- Which ports should be open on the server? 2- Can I protect GitLab with AppArmor? 3- Please introduce some tips to increase security? Thank y…
🌐
GitLab
forum.gitlab.com › how to use gitlab
On which port runner connects to the gitlab server - How to Use GitLab - GitLab Forum
July 21, 2020 - HI , i came across posts on forum that runner continuously polls the server over https for any details and not the other way around. In this case on which port does it poll the server 443 or any default port ? I have …
🌐
GitLab
docs.gitlab.com › gitlab docs › install › installation methods › docker › configure
Configure GitLab running in a Docker container | GitLab Docs
Additionally, if the NGINX listen ... the previous example, your web browser can reach your GitLab instance at <hostIP>:8929 and push over SSH on port 2424....
🌐
GitLab
docs.gitlab.com › gitlab docs › administer › secure gitlab › hardening › operating system recommendations
Hardening - Operating System Recommendations | GitLab Docs
By default, 5050 is open for remote access to the container registry, however in a hardened environment this would most likely exist on a different host, and in some environments not open at all. Hence, the recommendation is for ports 80 and 443 only, and port 80 should only be used to redirect ...
🌐
Reddit
reddit.com › r/gitlab › issue running gitlab ce selfhosted on a non standard port
r/gitlab on Reddit: Issue Running GitLab CE Selfhosted on a non standard port
July 17, 2018 -

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:

  1. I'm using the omnibus docker image (https://hub.docker.com/r/gitlab/gitlab-ce/)

  2. 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.

  3. 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

  4. 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.