Gitlab与Apache代理

我有一台运行在Mac OS X机器上的apache2服务器,与在虚拟机上运行Gitlab的机器相同。

Mac IP:192.168.0.7

Ubuntu(虚拟)IP:192.168.0.12

我希望apache将gitlab.mydomain.com转到Ubuntu虚拟机,而anythingelse.mydomain.com转到Mac。

我添加了一个文件(gitlab.mydomain.conf)到/private/etc/apache2/other/ (在Mac上),内容如下

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

Ubuntu虚拟机文件中的gitlab.yml包含

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

当我去gitlab.mydomain.com我得到以下错误:

 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 

但是,如果我去192.168.0.12我得到Gitlablogin页面。

任何想法是什么错?

尝试

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

从mod_proxy ProxyPass文档

 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. 

我猜你没有足够的search。

  1. 您将需要编辑文件/home/gitlab/gitlab/config/unicorn.rb
  2. 查找线路"#{app_dir}/tmp/sockets/gitlab.socket"并对其进行注释。 取消注释listen "192.168.0.12:80"
  3. 使用sudo a2enmod proxy启用apache模块sudo a2enmod proxy
  4. 使用sudo a2enmod proxy_http启用apache模块sudo a2enmod proxy_http
  5. 将其添加到您的虚拟主机

     <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. 重新启动gitlab&apache

  7. 玩的开心。

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