3

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?

slm
  • 7,615
  • 16
  • 56
  • 76
Isak T.
  • 151
  • 1
  • 2

3 Answers3

4

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.
R. S.
  • 1,714
  • 12
  • 19
0

For anyone coming from google this is what worked on Ubuntu 18.04, apache 2.4.2 and Gitlab enterprise edition 12.8.5. I followed the following link using-a-non-bundled-web-server

Skipped step 3 as my apache was on the same server and downloaded the correct vhost from Step 5 for Apache 2.4.

sb12
  • 101
  • 1
  • Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Gerald Schneider Apr 03 '20 at 12:40
0

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

tftd
  • 1,498
  • 7
  • 25
  • 40