[Solved] Gitlab can clone via SSH, cannot clone via HTTP, and cannot pipeline. Prompt port 80: connection rejected

Problem record: vm-ubuntu 20.04 used NAT mode to connect at the beginning, and later changed to bridge mode. After the change, the gitlab service originally started with docker could not be cloned. It always prompted: fatal… There was no remote library. It was not solved. Later, the mapped directory, container and image were deleted and a new container was restarted, After configuration, SSH cloning can be performed, but HTTP cloning cannot be performed. When performing gitlab CI pipeline, you will be prompted with failed to connect to 192.168.xx.83 port 80: connection rejected

By trying the command: git clone Unable to clone hint: failed to connect to 192.168.xx.83 port 80: connection rejected

By trying the command: git clone You can clone. Modify gitlab.yml under/SRV/gitlab/data/gitlab rails/etc, change port 80 to 9001, and restart gitlab service, which will change back to port 80

The problem is solved by modifying in the following ways

Custom port used

View the ID of the container

[email protected]:~$ sudo docker ps
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS                   PORTS                                                            NAMES
1132de0d1960        gitlab/gitlab-ce:latest   "/assets/wrapper"   19 hours ago        Up 2 minutes (healthy)   80/tcp, 443/tcp,>8081/tcp,>22/tcp   gitlab

Remember the container ID

In order to prevent accidents, stop the container and docker before operation

docker stop gitlab         
systemctl stop docker

We need to change the HTTP port to access 9001, and the address at the time of cloning is correct. The SSH port of gitlab is changed to 8022 of the host.

Modify host /Config.v2.json and hostconfig.json files under VaR/lib/docker/containers/container ID/

[email protected]:~# cd /var/lib/docker/containers/1132de0d1960e1049a3f1f014b2ba215442a6c7f23f4983b324e055306822c52/
[email protected]:/var/lib/docker/containers/1132de0d1960e1049a3f1f014b2ba215442a6c7f23f4983b324e055306822c52# ls
1132de0d1960e1049a3f1f014b2ba215442a6c7f23f4983b324e055306822c52-json.log  checkpoints  config.v2.json  hostconfig.json  hostname  hosts  mounts  resolv.conf  resolv.conf.hash



Tips: if VIM editing is not formatted, the readability will be very poor. I copied the file locally and changed it with Notepad + +

Modify the gitlab configuration file/etc/gitlab/gitlab.rb in the container

Because I mapped/etc/gitlab to/backup/gitlab/config, I went directly to this directory to modify the gitlab.rb file, with the following parameters

external ''
nginx['listen_port'] = 8081
gitlab_rails['gitlab_shell_ssh_port'] = 10022

After the change, just start the docker and container

systemctl start docker

docker start gitlab

Similar Posts: