How to point subdomain to gitlab?

I’ve installed gitlab on my new vserver with no errors. The vserver runs Ubuntu 20.04 LTS and if I enter my IP address in the browser it shows me the Apache2 Ubuntu Default Page .

While installing gitlab I’ve set my subdomain like this:

sudo EXTERNAL_URL="" apt-get install gitlab-ee

The subdomain points to the IP address of the vserver with an A-record.

If I enter my subdomain in the browser it does not show me gitlab, but the Apache2 Ubuntu Default Page .

How can I achieve the expected behaviour? Do I have to point the domain elsewhere? Do I have to set a redirect?

The problem is not your domain, but Apache. Gitlab runs nginx as the webserver for ports 80 and 443, and since you have Apache installed it is causing problems. If you do not wish to use nginx because you are installing Gitlab on the same machine as a webserver which is already running, you have two solutions.

  1. Get your VPS a second IP address and bind Gitlab to this. Then nginx will work. Change your domain record for gitlab to use this second IP.
  2. On this forum there is already posts about configuring Apache as a reverse proxy for Gitlab, see this link: Gitlab Behind a Apache Revers proxy with SSL - #17 by julienrobin28
  3. If you don’t need Apache on this VPS then remove it. Then gitlab will work properly with the built-in nginx.

You can verify this by doing:

gitlab-ctl status

it will most likely show that nginx is stopped and not running. Alternatively, if you do need Apache on this machine, and don’t want to configure the reverse proxy, then install Gitlab on it’s own VPS which means there is no problem with other services conflicting like you have right now.

I only want to use gitlab on this vps.
If I ran gitlab-ctl status I will get

run: nginx: (pid 21091) 264s; run: log: (pid 1204) 3755s

so it seems like nginx is running.
As described above I’ve used a fresh Ubuntu install.

Or do I misunderstand you?

Did you install Apache on this VPS before installing Gitlab? What do you use Apache for? Or was it installed by mistake?

Please provide output of this command and remove from the output the IP address of your VPS - replace it with x.x.x.x:

netstat -tunlp

Thanks for your replies.
Well, installed Ubuntu via the admin panel of the server-provider. Maybe they install apache2 with it? I don’t know …

The output of netstat -tunlp is:
(could not find my vps-ip in here)

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0*               LISTEN      17085/node_exporter 
tcp        0      0*               LISTEN      17075/gitlab-workho 
tcp        0      0*               LISTEN      17102/ruby          
tcp        0      0*               LISTEN      17064/gitaly        
tcp        0      0 *               LISTEN      187/systemd-resolve 
tcp        0      0    *               LISTEN      270/sshd: /usr/sbin 
tcp        0      0*               LISTEN      17638/grafana-serve 
tcp        0      0    *               LISTEN      2295/master         
tcp        0      0  *               LISTEN      38913/nginx         
tcp        0      0*               LISTEN      17114/redis_exporte 
tcp        0      0*               LISTEN      17121/prometheus    
tcp        0      0*               LISTEN      17630/postgres_expo 
tcp6       0      0 ::1:9168                :::*                    LISTEN      17102/ruby          
tcp6       0      0 :::80                   :::*                    LISTEN      293/apache2         
tcp6       0      0 :::22                   :::*                    LISTEN      270/sshd: /usr/sbin 
tcp6       0      0 :::25                   :::*                    LISTEN      2295/master         
udp        0      0 *                           187/systemd-resolve 

OK, so simple thing will be to just remove apache since you are not using it for anything.

apt-get remove apache2

then do:

gitlab-ctl restart

nginx was running only on port 8060, so it didn’t attempt to start the others because of apache being in its place.

1 Like

thx a lot!

1 Like