How to change port GitLab on CentOS 6? - linux

I tried to change port number on these files. But when I run gitlab-ctl reconfigure for updating. I can't access my link (http://myaddress.example:8790) Those files which I changed are:
/var/opt/gitlab/gitlab-rails/etc/gitlab.yml
/opt/gitlab/embedded/conf/nginx.conf
/opt/gitlab/embedded/cookbooks/gitlab/attributes/default.rb
/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
/var/opt/gitlab/nginx/conf/gitlab-http.conf
In /etc/gitlab/gitlab.rb I change external_url "http://myaddress.example:8790"
How can I fix it?

Using GIT_LAB_PATH as you gitlab base directory (the root where is it installed)
Modify GIT_LAB_PATH/gitlab/gitlab.yml
## GitLab settings
gitlab:
## Web server settings
host: HOSTNAME
port: HTTP_PORT
https: false
If you use non-standard ssh port you need to specify it
ssh_port: SSH_PORT
Modify GIT_LAB_PATH/gitlab-shell/config.yml to use the new HTTP port:
Url to gitlab instance. Used for api calls. Should end with a slash.
gitlab_url: "http://HOSTNAME:HTTP_PORT/"
Modify /etc/nginx/sites-available/gitlab
listen *:HTTP_PORT default_server; # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
Modify /etc/ssh/sshd_config
What ports, IPs and protocols we listen for
Port SSH_PORT
Restart SSH, restart GitLab, restart nginx:
sudo service ssh restart
sudo service gitlab restart
sudo service nginx restart
Test GitLab:
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Update the remote origins for your repos to use the new port:
ssh://git#HOSTNAME:HTTP_PORT/repo_name

Dear all I missing open port in firewall
I type it on linu terminal
/etc/init.d/iptables stop
It worked

Related

Centos Docker : Connection reset by peer

I run nginx container on my azure Vm, centos 7 with this command:
docker run --name nginx2 --detach -p 0.0.0.0:90:80 nginx
Now If I run this command on the host machine: curl localhost:90 I got the error:
curl: (56) Recv failure: Connection reset by peer
What I tried:
On my local machine
I follow the same steps on my local machine and everything works like a charm. So the nginx image is not the problem
Inside the container
On my VM, I connect to the nginx container and run the command : curl localhost:80 and got the answer. So nginx listen on port 80.
From another container
If I create a second container and run the command curl <nginx-ip>:80. I got the result. So nginx not listen only on localhost, but on all ip.
host network
When I run the container using Host Newtork --network host, everything work fine. But I don't want to do that
Try with another container
I try using this container: docker run -p 8000:8000 -it python:3.7-slim python3 -m http.server --bind 0.0.0.0. But same error.
My question is what is the problem with bridge network on Centos ?
I had similar problem with CentOS 7.1 and latest Docker 19.03.
Only way I was able to resolve this was to revert to Docker 18.03 (other versions might also work). After uninstalling current Docker I installed earlier version:
yum install docker-ce-18.03.1.ce-1.el7.centos
After this curl localhost:<port> started to work ok with the nginx.
I faced the same problem with 3000 and 80 port, add your ports to the firewal records like that:
firewall-cmd --permanent --zone=trusted --change-interface=docker0
firewall-cmd --permanent --zone=trusted --add-port=80/tcp
firewall-cmd --permanent --zone=trusted --add-port=90/tcp
firewall-cmd --reload
also check if you have iptables - disable it
systemctl disable iptables.service

Amazon Linux cannot access nginx on port 80

I have installed nginx on my AMI by yum
sudo yum install nginx
And then, I open all port in my AMI security group
All traffic - All - All - 0.0.0.0/0
And then, I start nginx by command
sudo service nginx start
And then, I access my nginx web service by http://public-ip
but I cannot access by this way.
I try to check the connection in my server.
ssh my_account#my_ip
And then,
wget http://localhost -O-
And It worked fine.
I cannot figure out what is the root cause, and then I change nginx port from 80 to 8081 and I restart the nginx server.
And then, I try to access again. It worked fine. WTH...
http://public-ip:8081
I don't know exactly what is going on?
Could you tell me what is the problem.
I see a few possibilities:
You are blocking the connections with a firewall on the host.
Security Group rules disallow this access
You are in a VPC and have not set up an Internet Gateway or route to host
Your Nginx configurations are set to explicitly listen on host and port combinations such that it responds to "localhost" but not to the public IP or host name. You could post your Nginx configs and be more specific about how it doesn't work when you try remotely. It is timing out? Not resolving? Receiving an HTTP response but not what you expected?

GitLab API access failing after upgrade

I have recently updated GitLab to version 7.14, and when I run
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
I get the following error
Check GitLab API access: FAILED: Failed to connect to internal API
gitlab-shell self-check failed
Try fixing it:
Make sure GitLab is running;
Check the gitlab-shell configuration file:
sudo -u git -H editor /home/git/gitlab-shell/config.yml
Please fix the error above and rerun the checks.
I have gitlab running behind a reverse proxy with the following rules set up
DNAT net loc:192.168.122.38:22 tcp 2227 - <externalip>
DNAT net loc:192.168.122.38:80 tcp 2280 - <externalip>
DNAT net loc:192.168.122.38:443 tcp 2443 - <externalip>
and gitlab-shell/config.yml looks like
GitLab user. git by default
user: git
# Url to gitlab instance. Used for api calls
gitlab_url: "https://<external_url>:2443/"
# Repositories path
repos_path: "/home/git/repositories"
# File used as authorized_keys for gitlab user
auth_file: "/home/git/.ssh/authorized_keys"
ssh_port: 2227
self_signed_cert: true
Based on the configuration you have described the issue is that gitlab-shell is trying to access GitLab at https://:2443. However, you point out that only ports 22, 80 and 443 are proxied. You need to adjust your gitlab-shell configuration so it either points at localhost at an appropriate port or at port 443 on the external URL.

Gitlab on port 8080

I'm currently in the process of trying to get Gitlab omnibus installed on my private Debian server, and it works perfectly on port 80, the problem is I also have an Apache server listening on port 80. So I'm trying to get Nginx listening on port 8080 but for some reason I'm getting a
"502
Gitlab is not responding" Error
I have edited both "external_url" in gitlab.rb and also the port number under the server block in the nginx.conf file. and no joy.
If someone could help me that would be great!
Most likely you have another service listening on 8080, I think the omnibus install have some service hooking 8080 - just use 8081 instead.
Edit: I just did a quick search and found that it's the unicorn server that is listening to 8080 with the original omnibus installer.
Note: You will only need to change the external_url in gitlab.rb, no other config file should have to be edited for this.
Edit#2: As #emeraldjava stated there is an option in the configuration file for using another unicorn port: #unicorn['port'] = '8080'
I solved this for Gitlab Omnibus (Community Edition, version 10.1.4) by first setting these in /etc/gitlab/gitlab.rb:
unicorn['port'] = 8081
gitlab_workhorse['auth_backend'] = "http://localhost:8081"
Then running:
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
Additionally, if you are running GitLab behind an SSL reverse proxy, you may need to restart that service to get past the cached 502 error page.
Starting with GitLab 13.0, Puma is the default web server and Unicorn has been disabled by default(reference).
so you have to change following configs in /etc/gitlab/gitlab.rb :
external_url 'http://hostOrDomain:8080/'
puma['port'] = 8081
gitlab_workhorse['auth_backend'] = "http://localhost:8081"

Git hooks may need higher privileges

I'm using node.js for my webserver, and I would like forever (or something like it) to run the server.
I'm also using git to manage the website. I have a bare repository on the server that I can push to/pull from on my local machine. I would like the repository to do three things when I push to it.
CD to my working directory (on the server)
Have the working directory pull from the bare repo
Restart the running webserver.
The following script seems like it's what I should use as a post-receive hook in my bare repo.
cd ~/site
git pull
sudo forever stopall
sudo forever start main.js
However, I don't think it's smart to have the git hook use sudo like that. The script needs elevated to run on port 80.
How should I be doing this? What should my git post-receive look like?
Thanks!
Well, for my particular case, it turns out I shouldn't be running node as a super user for security reasons. I wanted it to be elevated to run on port 80, but it didn't need to be elevated to run on port 8000.
So I forwarded port 80 to port 8000, and now am running node on port 8000. It still works identically to how it did before.
The command that I used in particular to forward port 80 to 8000 is
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000

Resources