Running Gitlab on a subdomain under Apache on Ubuntu


Hey everyone,

I am trying to get gitlab running on my vps and previously this worked, but the problem is that the front-end ran on port 80.
I need this port for several other services, so i decided to use apache.

Here i found this topic, [SOLVED] Setting up Gitlab on Ubuntu 14.04 with Apache2 without owning a domain name. Which is similar to my problem but was no outcome for me. After a couple of hours of trying if find myself here without a single clue what to do next.

What i want:
Gitlab to run on using apache

What i did:
I installed Apache first and then installed gitlab.

Changes i made:
gitlab.rb, anything but below is commented out

  • external_url ‘
  • gitlab_rails[‘trusted_proxies’] = [‘’, ‘’, ‘2001:0db8::/32’]
  • gitlab_workhorse[‘enable’] = true
  • gitlab_workhorse[‘listen_network’] = “tcp”
  • gitlab_workhorse[‘listen_addr’] = “”
  • web_server[‘external_users’] = [‘www-data’]
  • nginx[‘enable’] = false

Furthermore i added this file to apache2/sites-available/ named

# This configuration has been tested on GitLab 8.2
# Note this config assumes unicorn is listening on default port 8080 and
# gitlab-workhorse is listening on port 8181. To allow gitlab-workhorse to
# listen on port 8181, edit or create /etc/default/gitlab and change or add the following:
# gitlab_workhorse_options="-listenUmask 0 -listenNetwork tcp -listenAddr -authBackend"
#Module dependencies
# mod_rewrite
# mod_proxy
# mod_proxy_http
<VirtualHost *:80>
ServerSignature Off

ProxyPreserveHost On

Ensure that encoded slashes are not decoded but left in their encoded state.

AllowEncodedSlashes NoDecode

# New authorization commands for apache 2.4 and up # Require all granted
#Allow forwarding to gitlab-workhorse

Apache equivalent of nginx try files

RewriteEngine on

#Don’t escape encoded characters in api requests
RewriteCond %{REQUEST_URI} ^/api/v3/.*
RewriteRule .*{REQUEST_URI} [P,QSA,NE]

#Forward all requests to gitlab-workhorse except existing files like error documents
RewriteCond %{REQUEST_URI} ^/uploads/.*
RewriteRule .*{REQUEST_URI} [P,QSA]

needed for downloading attachments

DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public

#Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
ErrorDocument 404 /404.html
ErrorDocument 422 /422.html
ErrorDocument 500 /500.html
ErrorDocument 503 /deploy.html

It is assumed that the log directory is in /var/log/httpd.

For Debian distributions you might want to change this to


LogFormat “%{X-Forwarded-For}i %l %u %t “%r” %>s %b” common_forwarded
ErrorLog /var/log/apache2/logs/YOUR_SERVER_FQDN_error.log
CustomLog /var/log/apache2/logs/YOUR_SERVER_FQDN_forwarded.log common_forwarded
CustomLog /var/log/apache2/logs/YOUR_SERVER_FQDN_access.log combined env=!dontlog
CustomLog /var/log/apache2/logs/YOUR_SERVER_FQDN.log combined

But when i go to the only page i see is the apache web server page.

Does anyone have a clue of what i can do to fix this?

thanks in advance.

PS: i am new to server thing and such but eager to learn, please explain your answer


what is your port on your named using

Normaly when you add a conf it would say

<VirtualHost *:80>

I would suggest, that you try change 80 to 8181.

Also when you wanna access your git website, then try using