public
Last active

Apache vhost config for gitlab

  • Download Gist
README.md
Markdown

unicorn config file

Edit file /home/gitlab/gitlab/config/unicorn.rb

Find line listen "#{app_dir}/tmp/sockets/gitlab.socket" and comment it. Uncomment line listen "127.0.0.1:8080"

required modules for apache

  • sudo a2enmod proxy
  • sudo a2enmod proxy_balancer
  • sudo a2enmod proxy_http
  • sudo a2enmod rewrite
gitlab.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
<VirtualHost *:80>
ServerName git.domain.com
 
# Point this to your public folder of teambox
DocumentRoot /home/gitlab/gitlab
 
RewriteEngine On
 
<Proxy balancer://unicornservers>
BalancerMember http://127.0.0.1:8080
</Proxy>
 
# Redirect all non-static requests to thin
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://unicornservers%{REQUEST_URI} [P,QSA,L]
 
ProxyPass / balancer://unicornservers/
ProxyPassReverse / balancer://unicornservers/
ProxyPreserveHost on
 
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
 
# Custom log file locations
ErrorLog /var/log/apache2/gitlab_error.log
CustomLog /var/log/apache2/gitlab_access.log combined
</VirtualHost>

You do not need a load balancer to make this work.
You can simply use proxy pass:

<VirtualHost *:80>
    ....
    ProxyRequests     Off
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:8080/
    <Location />
        ProxyPassReverse /
        Order deny,allow
        Allow from all
    </Location>
    ....
</VirtualHost>

(https://gist.github.com/steve-todorov/4758707)

I'm just only make correct Apache route for Gitlab with this configure:

https://gist.github.com/carlosjrcabello/5486422

Puma replaced unicorn, does anything need to be changed in puma for this to work correctly?

Thanks a lot. This is my gitlab.conf that did the trick (note the different version numbers in /gems/ lines):

   LoadModule passenger_module /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.25/buildout/apache2/mod_passenger.so
   PassengerRoot /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.25
   PassengerDefaultRuby /usr/local/bin/ruby

<VirtualHost *:80>
        ServerName gitlab
        # Point this to your public folder of teambox
        DocumentRoot /home/git/gitlab/public
        ProxyPass /gitlab/ http://127.0.0.1:8081/
        ProxyPassReverse /gitlab/ http://127.0.0.1:8081/
        ProxyPreserveHost On

        # Custom log file locations
        ErrorLog /var/log/apache2/gitlab_error.log
        CustomLog /var/log/apache2/gitlab_access.log combined
</VirtualHost>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.