Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an apache2 server running on a Mac OS X machine with the same machine running Gitlab virtually in Ubuntu.

Mac IP: 192.168.0.7

Ubuntu (virtual) IP: 192.168.0.12

I would like apache to make gitlab.mydomain.com to go to the Ubuntu virtual machine while anythingelse.mydomain.com go to the Mac.

I added a file (gitlab.mydomain.conf) to /private/etc/apache2/other/ (on the Mac) with the following contents

<VirtualHost *:80>
  ServerName gitlab.mydomain.com
  ProxyPass / http://192.168.0.12
  ProxyPassReverse / http://192.168.0.12
  ProxyPreserveHost On

</VirtualHost>

The gitlab.yml on the Ubuntu virtual machine file contains

##Gitlab settings
gitlab:
  ## Web server settings
  host: gitlab.mydomain.com
  port: 80
  https: false

When I go to gitlab.mydomain.com I get the following error:

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /users/sign_in.

Reason: DNS lookup failure for: 192.168.0.12users

But if I go to 192.168.0.12 I get the Gitlab sign in page.

Any ideas on what is wrong?

share|improve this question
    
Can someone with enough reputation add a Gitlab tag to this question? –  Michael Frost Jun 1 '13 at 15:25
add comment

2 Answers 2

I guess you haven't searched enough.

  1. You will need to edit file /home/gitlab/gitlab/config/unicorn.rb
  2. Find line listen "#{app_dir}/tmp/sockets/gitlab.socket" and comment it. Uncomment line listen "192.168.0.12:80"
  3. Enable the apache module proxy with sudo a2enmod proxy
  4. Enable the apache module proxy_http with sudo a2enmod proxy_http
  5. Add this to your virtual host

    <VirtualHost *:80>
    ServerName gitlab.mydomain.com
    
    # Custom log file locations
    ErrorLog /var/log/apache2/gitlab_error.log
    CustomLog /var/log/apache2/gitlab_access.log combined
    
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / http://192.168.0.12/
    <Location />
        ProxyPassReverse /
        Order deny,allow
        Allow from all
    </Location>
    

  6. Restart gitlab & apache

  7. Have fun.

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

share|improve this answer
    
Awesome answer. Thanks for posting that. –  Sebastian Sastre Feb 12 at 10:33
add comment

try

<VirtualHost *:80>
  ServerName gitlab.mydomain.com
  ProxyPass / http://192.168.0.12/
  ProxyPassReverse / http://192.168.0.12/
  ProxyPreserveHost On
</VirtualHost>

From mod_proxy ProxyPass docs

If the first argument ends with a trailing /, the second argument
should also end with a trailing / and vice versa. Otherwise the
resulting requests to the backend may miss some needed slashes and
do not deliver the expected results.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.