我正在尝试使用 apache 作为 Web 服务器来设置 gitlab。到目前为止,我还没有成功。sidekiq 和 unicorn 启动正常,但当我尝试访问根站点时,我被重定向到 /users/login 并陷入循环。
我使用 apache 2.2 和 gitlab 6.5。
我的Apache配置:
#This configuration has been tested on GitLab 6.0.0 and GitLab 6.0.1
#Note this config assumes unicorn is listening on default port 8080.
#Module dependencies
# mod_rewrite
# mod_proxy
# mod_proxy_http
<VirtualHost *:80>
ServerName gitlab.martijn.osbournia.com
ServerSignature Off
ProxyPreserveHost On
<Location />
Order allow,deny
Allow from all
ProxyPassReverse http://127.0.0.1:8081
ProxyPassReverse http://gitlab.martijn.osbournia.com/
</Location>
#apache equivalent of nginx try files
# http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
# http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:8081%{REQEST_URI} [P,QSA]
# needed for downloading attachments
DocumentRoot /home/gitlab_martijn/gitlab/public
#Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
ErrorDocument 404 /404.html
ErrorDocument 422 /422.html
ErrorDocument 500 /500.html
ErrorDocument 503 /deploy.html
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
ErrorLog /var/log/apache2/gitlab.martijn.osbournia.com_error.log
CustomLog /var/log/apache2/gitlab.martijn.osbournia.com_forwarded.log common_forwarded
CustomLog /var/log/apache2/gitlab.martijn.osbournia.com_access.log combined env=!dontlog
CustomLog /var/log/apache2/gitlab.martijn.osbournia.com.log combined
</VirtualHost>
Gitlab/unicorn 生产单页请求日志:
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:00 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:00 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:00 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:00 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:00 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:00 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:00 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:00 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 2ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 2ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 2ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 2ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 1ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:01 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 2ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:02 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 2ms
Started GET "/" for 77.168.84.58 at 2014-02-17 12:10:02 +0100
Processing by DashboardController#show as HTML
Completed 401 Unauthorized in 2ms
答案1
问题出在你的反向代理定义上。由于该语句,你有一个循环:
ProxyPassReverse http://gitlab.martijn.osbournia.com/
像这样修改您的配置:
<Proxy balancer://unicornservers>
BalancerMember http://127.0.0.1:8081
</Proxy>
ProxyPass / balancer://unicornservers/
ProxyPassReverse / balancer://unicornservers/
ProxyPreserveHost on