Gitlab 4.0-Stable on Ubuntu 12.04, SSL & Apache2

After a bunch of trial and error, I was able to get GitLab running on Apache2 supporting large payloads with SSL.
Special thanks to some pointers on the passenger module install from Nick Yeoman.

  • Configure gitlab.yml for SSL
## GitLab settings
  ## Web server settings
  host: gitlab.<your-domain>
  port: 443
  https: true
  • Install the passenger module for Ruby & Apache2:
sudo gem install passenger
sudo passenger-install-apache2-module

The passenger installer will note that these lines will need to be added to the Apache config:

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.15/ext/apache2/
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.15
PassengerRuby /usr/local/bin/ruby
  • Enable rewrite for http: -> https: (optional)
sudo a2enmod rewrite
  • Create the gitlab conf in apache2
sudo vim /etc/apache2/sites-available/gitlab
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.19/ext/apache2/
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.19
PassengerRuby /usr/local/bin/ruby

<VirtualHost *:80>
        ServerName gitlab.<your.domain>

        # Redirect from HTTP to HTTPS
        RewriteEngine   on
        RewriteCond     %{SERVER_PORT} ^80$
        RewriteRule     ^(.*)$ https://%{SERVER_NAME}$1 [L,R]
<VirtualHost *:443>
        ServerName gitlab.<your.domain>
        ServerAdmin gitlab@<your.domain>

        SSLEngine On
        SSLCertificateFile /etc/apache2/ssl/<cert.file>
        SSLCertificateKeyFile /etc/apache2/ssl/<cert.key>
        SSLCertificateChainFile /etc/apache2/ssl/<chain-file.crt>

        # Point this to your public folder of gitlab
        DocumentRoot /home/gitlab/gitlab/public
        <Directory /home/gitlab/gitlab/public>
                # This relaxes Apache security settings.
                AllowOverride all
                # MultiViews must be turned off.
                Options -MultiViews

        CustomLog /var/log/apache2/gitlab-access.log combined
        ErrorLog  /var/log/apache2/gitlab-error.log
  • Enable the site and restart Apache2
a2ensite gitlab
sudo service apache2 restart

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">