Home > Article > Development Tools > How to modify GitLab’s HTTP or HTTPS port
GitLab is an open source code hosting platform that usually uses the HTTP protocol to listen to port 80 by default. However, there are cases where you need to deploy GitLab to a different port. This article will introduce how to modify GitLab's HTTP or HTTPS port.
First, enter the console of the GitLab server and execute the following command:
sudo vim /etc/gitlab/gitlab.rb
The editor will open the GitLab configuration file, Find the following line:
external_url 'http://example.com'
Modify it to:
external_url 'http://example.com:8080'
Save the modifications, and then execute the following command to make the configuration file take effect:
sudo gitlab-ctl reconfigure
GitLab will reload the configuration file and start Serve. Now, you can access GitLab by visiting http://example.com:8080.
If your GitLab uses the HTTPS protocol to listen on port 443, you need to do some extra work to modify the HTTPS port. First, make sure you have configured an SSL certificate, otherwise please refer to the official documentation for configuration.
Next, enter the console of the GitLab server and execute the following command:
sudo vim /etc/gitlab/gitlab.rb
The editor will open the GitLab configuration file and find the following lines:
nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt" nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/server.key"
Modify them Save the changes for:
nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt" nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/server.key" nginx['listen_port'] = 8443 nginx['listen_https'] = true
, and then execute the following command to make the configuration file take effect:
sudo gitlab-ctl reconfigure
Now, GitLab will listen on port 8443 using the HTTPS protocol. You can access GitLab by visiting https://example.com:8443.
Summary
You can easily modify GitLab's HTTP or HTTPS port by modifying the external_url and nginx options of the GitLab configuration file. It should be noted that before modifying the HTTPS port, make sure that the SSL certificate has been configured.
The above is the detailed content of How to modify GitLab’s HTTP or HTTPS port. For more information, please follow other related articles on the PHP Chinese website!