Setting up Gitlab on Ubuntu 14.04 with Apache2 without owning a domain name

Hello,I’m relatively new to all of this server stuff (I’ve been with Linux for a while, but on the desktop), just a heads up. Also a heads up, I’ve done many searches on how to do this with still no solution.

Recently, I’ve been interested in moving my web services off of the web and to my own server, and Gitlab has appealed to me as a self-hosted alternative to Gitlab. A while back, I installed ownCloud (a Dropbox alternative) on a repurposed netbook running Ubuntu Server 14.04, and that set itself up with Apache as its web server. More recently, I installed Wallabag, (a self-hosted Pocket/read-it-later alternative) also under Apache. I access this Apache server set up through my router via port-forwarding to ports 80 and 443.

However, when I install Gitlab-omnibus, it installs itself with nginx, so it appears to be incompatible with the existing Apache set up I have, and appears to require owning a domain name (which I don’t have an interest in doing). I tried following tutorials online at how to set up Gitlab under Apache but to no avail.

How can I get Gitlab to play nice with Apache and my router/port-forwarding set up? Do I have to do some special config to get Gitlab to run under Apache? Or do I have to find a way to make nginx to operate in parallel Apache?

Thanks in advance for any help!


I brought back your post, why did you delete it in the first place? It’s pretty legit and others might benefit if you found any solution.

I don’t know, I have sort of given up on installing Gitlab with my seemingly unique setup (no domain name) and I didn’t want anyone wasting their time replying to something that I wasn’t going to use because I’d given up. But I do suppose it is worth it to keep it around, just in case someone does know.

No worries :smile:

If you ever feel to continue and include GitLab to your services, do let us know.

btw ever heard of project ?

Thanks :smile:

I’d really like use Gitlab, don’t get me wrong, but I’m just having a tough time with the setup. If I could get over that hurdle, I’d definitely use it.

I’ve already found something that works like Sovereign-- ownCloud. It handles file sync, calendars, contacts, etc. But thanks for the suggestion!

Erm, sovereign is a pack of hosted services, owncloud included.

So you reach all these services from the netbook only from within the internal network?

As for gitlab, you can use your own external web server and not the bundled nginx. See

If you find any difficulties let us know.

Oh! I did not realize that’s what sovereign was (I was in class when I replied to your post, so I only gave the github page a cursory glance) I’ll have to give that a closer look at some point. It seems appealing…

As for how I access those services, I use port forwarding on my router (80 and 443 for apache with ownCloud, 4040 for subsonic, a music streaming service). So I can access them away from home, but not directly through the netbook. Hopefully that help page you sent works with that setup- I’ll get back to you on that after I have time to try it. Thanks for all your help!

Ok, you have a static ip or are you using dynamic DNS? In any case, I guess you are reaching those services via a domain name. If that’s the case here’s some steps that might get you going:

In /etc/gitlab/gitlab.rb add:

external_url ""
# Disable nginx
nginx['enable'] = false
# Give apache user privileges to listen to GitLab
web_server['external_users'] = ['www-data']

Then run sudo gitlab-ctl reconfigure.

Then add the apache vhost along with the others, taken from this repo, download

The settings you need to replace are:

  • <VirtualHost *:80> - change the port to say 4554
  • ServerName - replace with the domain with which you reach from outside
  • ProxyPassReverse - replace with ProxyPassReverse
  • Change to DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
  • Fix the log paths at the end of this conf

Then as you already know, add Listen 4554 to /etc/apache2/ports.conf and restart apache.


I use DNS on the router, although I do not access the services through a domain name; I use the IP of the router (for example, to get to owncloud, I type in [No, my router IP is not, I’ve changed it for security[). Would that config work with that?

Ok, I’ve gone ahead and tried those steps, but when I try to restart Apache I get some errors:

* Restarting web server apache2                                         [fail] 
* The apache2 configtest failed.
Output of config test was:
AH00112: Warning: DocumentRoot [/home/git/gitlab/public] does not exist
AH00558: apache2: Could not reliably determine the server's fully qualified domain name,    using Set the 'ServerName' directive globally to suppress this message
(2)No such file or directory: AH02291: Cannot access directory '/var/log/httpd/logs/' for error log of vhost defined at /etc/apache2/sites-enabled/gitlab.conf:7
AH00014: Configuration check failed
Action 'configtest' failed.
The Apache error log may have more information.

I guess I could create the log directories, but what’s up with the DocumentRoot error? That I do not understand.

UPDATE: I’ve removed the log error, but I still don’t know where to direct DocumentRoot to. I’ve tried


(I picked that because it has an index.html file in it), but when I go to load IP.ADDRESS:4554 I get a generic “The connection timed out” error. Any ideas?

UPDATE 2: I’ve found out that the public DocumentRoot is


but I still get the time out error when I load it. Maybe I should just switch from apache to nginx…

Crap I forgot about the documentroot, fixed in my post above.

As for the timeout, can you try and do what is told in this issue?


I have tried your suggestions but I am still unable to access GitLab via port 80 with Apache 2.4. Optimally I would like the URL to access GitLab to be (I don’t require HTTPS), but I see most of the configuration indicates that GitLab will be available at a subdomain, namely so that is how I have been trying to get things to work.

As I mentioned in the issue I created here I have Tomcat running on port 8080 so I have changed my unicorn port to 8081. Here are my config files. These are the only files I have changed. Note that

1.) All the places you used port 4554 in your example I used port 81.
2.) Anywhere that port 8080 was referenced I changed it to port 8081 because that is what I changed my unicorn port to.
3.) I didn’t change the VirtualHost statement in /etc/apache2/sites-enabled/000-default.conf as suggested in the comment at the top of /etc/apache2/ports.conf.


external_url '' # I have also tried and

unicorn['port'] = 8081

git_data_dir "/mnt/tank/gitlab"

nginx['enable'] = false
web_server['external_users'] = ['www-data']


#This configuration has been tested on GitLab 6.0.0 and GitLab 6.0.1
#Note this config assumes unicorn is listening on default port 8080.
#Module dependencies
#  mod_rewrite
#  mod_proxy
#  mod_proxy_http
<VirtualHost *:81>
  ServerName # I have also tried
  ServerSignature Off

  ProxyPreserveHost On

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

  <Location />
    # New authorization commands for apache 2.4 and up
    Require all granted

    ProxyPassReverse # I have also tried and have also tried dropping the trailing slash

  #apache equivalent of nginx try files
  RewriteEngine on
  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

  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
  ErrorLog  /var/log/apache2/gitlab_error.log
  CustomLog /var/log/apache2/gitlab_forwarded.log common_forwarded
  CustomLog /var/log/apache2/gitlab_access.log combined env=!dontlog
  CustomLog /var/log/apache2/gitlab.log combined



# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 80
Listen 81
<IfModule ssl_module>
        Listen 443

<IfModule mod_gnutls.c>
        Listen 443
1 Like

Progress!! I’ve done all that was instructed, and now (after fixing a stupid Ubuntu firewall problem-- me forgetting to allow connections to port 4554 on my machine) I get… an error 500. Although, that error is thrown by Gitlab… so that’s something. It says (quite vaguely) “We’re sorry, but something went wrong. Please contact your GitLab administrator if this problem persists.” Thoughts? (Yes, I’ve rebooted)

Can you add TimeOut 600 in the gitlab vhost file? Also check the logs for any messages.

That is not supported by the omnibus package at the moment. You’d have to install from sources manually for that to work.

Since you have a subdomain to run to, you don’t have to make apache listen to port 81. GitLab’s app server (unicorn) which serves the whole application listens to 8080 by default. That you changed to 8081 and that’s that. Now you have to tell apache that whenever you hit proxy the request to where GitLab listens.

So to sum up.

  1. You don’t have to use port 81, remove it from your files
  2. Change to unicorn['port'] = 8081 in gitlab.rb, which you did
  3. Change 8080 to 8081 in apache vhost

Make sure that the dns for the subdomain is configured correclty. Also I don’t get why you keep saying # I have also tried

As I mentioned, if the dns is set up correclty it should point to the IP of the machine that hosts GitLab. From there apache takes care to properly route the requests.

What does /var/log/apache2/gitlab_error.log say?

And I have to say that I’ve been trying all the configurations prior to posting here :smile:

I’ve had TimeOut 600 in the vhost file, and that hasn’t made a difference. Also, I checked the logs and found this in the error log repeated a few times:

[Sun May 03 00:03:25.620758 2015] [proxy:error] [pid 1619] (111)Connection refused: AH00957: HTTP: attempt to connect to (*) failed
[Sun May 03 00:03:25.696748 2015] [proxy_http:error] [pid 1619] [client] AH01114: HTTP: failed to make connection to backend:

I’ve made sure that connections are allowed to port 8080 on my server, and that hasn’t made a difference. Is there something else I have to do? Thanks so much for your help thus far!

UPDATE: Well, thanks to the powers of deductive reasoning, I’ve figured out that the problem is caused by unicorn (because port 8080 is causing the problem). I’ve tried reinstalling ruby to no avail; when I run gitlab-ctl everything restarts fine except for unicorn, which times out. Investigating further…

UPDATE 2: It lives! After reinstalling ruby 2.1.3 and running a reconfigure, I can now get to the login screen. Now I need to figure out how to get my server to send me a confirmation email… Thanks so much once again!


Glad you got it working, but care to elaborate on this? You were using the package, right? If so, ruby is bundled in it, no need for manual install.

The server I’m running it on is using Ubuntu 14.04 LTS, which ships with Ruby version 1.9. I saw on some forum that Gitlab was designed to work with Ruby 2.0. I did use the package to install, however after installation the Ruby version was still at 1.9. So, using I managed to install Ruby 2.1.3 successfully, which got rid of the 500 error on the Gitlab page.

EDIT: While I’m here, is there anything you could direct me to to get email configuration working? I have set up a Gmail account to send email from and (I think) I’ve edited the configuration files correctly to use that email, but Gitlab just says it sent me an email to set up my account and yet I get nothing in my personal email inbox.

Aha! You should remove system ruby completely then. GitLab uses its own bundled version.

Can you open a new topic? Lots of questions to be answered :smile: