Home > Development Tools > git > body text

How to set IP correctly in gitlab

PHPz
Release: 2023-03-31 10:58:19
Original
2727 people have browsed it

Gitlab is a popular code hosting tool. It not only provides a version control system, but also provides its own unique CI/CD (continuous integration/continuous delivery) system, making it more convenient for developers to Manage code and projects. Among them, Gitlab's IP settings are also very important. If the IP is not configured correctly, it will cause a series of problems.

So, how to correctly set the IP of Gitlab? The following is divided into the following parts for introduction.

1. Prerequisites for setting Gitlab IP

Before setting Gitlab IP, the following conditions need to be met:

1. Gitlab has been installed.

2. Configure the domain name and IP address of the target server.

3. The corresponding port has been opened.

If the above conditions are not met, corresponding operations need to be performed first. After confirming that Gitlab is installed and the above conditions are met, you can start Gitlab IP setting.

2. Gitlab IP setting method

Gitlab IP setting can be divided into two methods: setting through DNS and setting through configuration file. They will be introduced separately below.

1. Setting through DNS

Setting Gitlab IP through DNS can make accessing Gitlab through the domain name instead of accessing through IP, which is more intuitive and easier to remember.

First, you need to edit the /etc/hosts file on the Gitlab server and add the corresponding IP address and domain name mapping, for example:

192.168.1.100 gitlab.example.com
Copy after login

This file can be accessed through the sudo vim /etc/hosts command Make edits.

Then, go to Management > Settings on the Gitlab management page, find the external URL, and change it to:

https://gitlab.example.com
Copy after login

Among them, gitlab.example.com was previously in /etc/hosts The domain name set.

After saving the settings, restart the Gitlab service:

sudo gitlab-ctl restart
Copy after login
Copy after login

Next, open the browser on the local machine and access it through gitlab.example.com.

2. Setting through the configuration file

Setting the Gitlab IP through the configuration file requires the following steps:

(1) Through the sudo vim /etc/gitlab/gitlab.rb command Edit the Gitlab configuration file.

(2) Find the following two lines:

#external_url 'GENERATED_EXTERNAL_URL'
# gitlab_rails['gitlab_ssh_host'] = 'ssh_host.example.com'
Copy after login

Change them to:

external_url 'http://192.168.1.100'
gitlab_rails['gitlab_ssh_host'] = '192.168.1.100'
Copy after login

Among them, 192.168.1.100 is the IP address of the Gitlab server.

(3) After saving the configuration file, restart the Gitlab service:

sudo gitlab-ctl restart
Copy after login
Copy after login

Now, it can be accessed through http://192.168.1.100.

3. Conclusion

Through the above introduction, we can find that how to correctly set the Gitlab IP is relatively simple. Whether it is set through DNS or through a configuration file, you only need to follow the process to set it up.

Finally, one thing to note is that incorrect Gitlab IP settings may cause problems accessing Gitlab, so we need to be particularly careful when setting up and adjust according to our own needs.

The above is the detailed content of How to set IP correctly in gitlab. 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