我正在尝试使用Apache2设置代理,以便对 http://myipaddress.com 的传入请求转到我正在运行Gitlab(rails应用程序)的http://localhost:3000/。以下是我在Ubuntu 10.04上的Apache配置文件中的内容。最初,我可以成功访问gitlab默认页面,但是在单击其他页面后,我执行的任何后续请求都将转到404 NOT FOUND页面。我可以在所有这些失败的重定向之前手动输入/gitlab/,它们可以正常工作。在首次请求后的每个重定向请求之后,如何不必重写/gitlab/就能完成这项工作?

## Setup a proxy which listens on the port that gitlabh does ( from start_server.sh )
ProxyRequests Off
ProxyPass /gitlab/ http://localhost:3000/
ProxyPassReverse /gitlab/ http://localhost:3000/
#DocumentRoot /home/gitlabhq/gitlabhq/public
<Proxy http://localhost:3000/>
  Order deny,allow
  Allow from all
</Proxy>

我了解我可以使用下面的代码来解决我的问题。但是我不知道如何修改gitlab rails服务的前缀。我真的很感谢您的帮助!
ProxyPass /gitlab/ http://localhost:3000/gitlab/
ProxyPassReverse /gitlab/ http://localhost:3000/gitlab/

更新:

感谢Friek的评论,我已经非常接近解决这个问题了。以下是我的http.conf文件的一部分。唯一的问题是,当我按下gitlab应用程序上的主页按钮或徽标时,它尝试重定向到gitlab/,这使我从Apache2获得了基本的index.html文件,说“行得通!”。我如何配置它以使我可以简单地获得/gitlab并将其带到gitlab的根主 View ?谢谢!
## For Gitlab using Apache2 Passenger
## Install on Ubuntu by:
## sudo gem install passenger && sudo passenger-install-apache2-module
## but only after running the install_and_configure_git.py script
## and creating a soft link to the rails gitlab /public directory like so:
## sudo ln -s /home/gitlabhq/gitlabhq/public /var/www/gitlab
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13
PassengerRuby /usr/local/bin/ruby
<VirtualHost *:80>

        ServerName gitlab

        ## Set the overall Document Root
        DocumentRoot /var/www
        <Directory /var/www>
                Allow from all
        </Directory>

        ## Set the Rails Base URI
        RackBaseURI /gitlab
        RailsBaseURI /gitlab
        <Directory /var/www/gitlab>
                Allow from all
                Options -MultiViews
        </Directory>

</VirtualHost>

最佳答案

我遇到了对我有用的this gist。万一它死了,我会重新发布它。

unicorn 配置文件

编辑文件/home/gitlab/gitlab/config/unicorn.rb
找到行监听"#{app_dir}/tmp/sockets/gitlab.socket"并对其进行注释。取消注释行监听"127.0.0.1:8080"
Apache所需的模块

  • sudo a2enmod代理
  • sudo a2enmod proxy_balancer
  • sudo a2enmod proxy_http
  • sudo a2enmod重写

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

    09-11 18:59
    查看更多