Home > Development Tools > git > How to modify GitLab's HTTP or HTTPS port

How to modify GitLab's HTTP or HTTPS port

PHPz
Release: 2023-03-31 15:43:27
Original
4210 people have browsed it

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.

  1. Modify HTTP port

First, enter the console of the GitLab server and execute the following command:

sudo vim /etc/gitlab/gitlab.rb
Copy after login
Copy after login

The editor will open the GitLab configuration file, Find the following line:

external_url 'http://example.com'
Copy after login

Modify it to:

external_url 'http://example.com:8080'
Copy after login

Save the modifications, and then execute the following command to make the configuration file take effect:

sudo gitlab-ctl reconfigure
Copy after login
Copy after login

GitLab will reload the configuration file and start Serve. Now, you can access GitLab by visiting http://example.com:8080.

  1. Modify the HTTPS port

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
Copy after login
Copy after login

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"
Copy after login

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
Copy after login

, and then execute the following command to make the configuration file take effect:

sudo gitlab-ctl reconfigure
Copy after login
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template