Running Gitlab on a subdomain under Apache on Ubuntu


#1

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 gitlab.jpbos.nl 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 ‘http://jpbos.nl
  • gitlab_rails[‘trusted_proxies’] = [‘192.168.1.0/24’, ‘192.168.2.1’, ‘2001:0db8::/32’]
  • gitlab_workhorse[‘enable’] = true
  • gitlab_workhorse[‘listen_network’] = “tcp”
  • gitlab_workhorse[‘listen_addr’] = “127.0.0.1:8181”
  • web_server[‘external_users’] = [‘www-data’]
  • nginx[‘enable’] = false

Furthermore i added this file to apache2/sites-available/ named git.jpbos.nl.conf

# 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 127.0.0.1:8181 -authBackend http://127.0.0.1:8080"
#
#Module dependencies
# mod_rewrite
# mod_proxy
# mod_proxy_http
<VirtualHost *:80>
ServerName git.jpbos.nl
ServerSignature Off

ProxyPreserveHost On

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

http://doc.gitlab.com/ce/api/projects.html#get-single-project

AllowEncodedSlashes NoDecode

# New authorization commands for apache 2.4 and up # http://httpd.apache.org/docs/2.4/upgrading.html#access Require all granted
#Allow forwarding to gitlab-workhorse
ProxyPassReverse http://127.0.0.1:8181
ProxyPassReverse http://jpbos.nl/

Apache equivalent of nginx try files

http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files

http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab

RewriteEngine on

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

#Forward all requests to gitlab-workhorse except existing files like error documents
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads/.*
RewriteRule .* http://127.0.0.1:8181%{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

/var/log/apache2.

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 git.jpbos.nl 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


#2

what is your port on your named got.jpbos.nl.conf 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 gitlab.jpbos.nl:8181