Apache2 ProxyPass for Rails App Gitlab

I came across this gist that worked for me. In case it ever goes dead, I’ll repost it.


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

/home/gitlab/gitlab/config/gitlab.conf

<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>

Leave a Comment