如何让Gitlab 6.5在Apache 2.4代理下显示其图标?

时间:2014-02-14 00:41:45

标签: ssl proxy gitlab apache2.4

我无法修复由Apache 2.4代理的Gitlab上的图标。我的失败可能是因为我没有使用乘客(乘客提供了更深层次的问题),但我采取了代理/gitlab下的所有步骤。我也跑了:

sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/gitlab

我也重启了Apache。没有得到改善。图标仍然缺失(或者我应该说字体woff文件返回status 200到浏览器,但大小为0)。这是Gitlab 6.5。在我的Apache SSL sites-enabled conf文件中,这是为我们的Gitlab提供通往世界的SSL路由:

<Proxy *>
      Require all granted
</Proxy>

<Location ~ /(gitlab|assets)>
    RequestHeader set X_FORWARDED_PROTO 'https'
    SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"
    Require all granted
    Options -Multiviews
    # apache equivalent of nginx try files
    # http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
    # https://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule .* http://127.0.0.1:8085/%{REQUEST_URI} [P,QSA]

    # needed for downloading attachments but does not work under Location directive
    #DocumentRoot /home/git/gitlab/public
</Location>

ProxyPass               /gitlab/ http://127.0.0.1:8085/gitlab/
ProxyPassReverse        /gitlab/ http://127.0.0.1:8085/gitlab/
ProxyPass               /gitlab http://127.0.0.1:8085/gitlab
ProxyPassReverse        /gitlab http://127.0.0.1:8085/gitlab
# SOme of the CSS assets were not being generated with "/gitlab", so I proxy those too.
ProxyPass               /assets http://127.0.0.1:8085/gitlab/assets
ProxyPassReverse        /assets http://127.0.0.1:8085/gitlab/assets

同样,大部分工作正常。只有字体资源以0大小返回浏览器。我应该将Location指令更新到目录吗?

注意:gitlab - icons replaced by rectangles没有帮助。是的,我的服务器上的443端口还有其他站点,所以我不能只在自己的端口/域上使用这个Apache配置,如果我不需要的话。我可能只需要一些帮助来理解Apache 2.4。我在Apache配置中遗漏了什么吗?

资源使用:https://github.com/gitlabhq/gitlab-recipes/commit/be95bd4f9bd3244641a4c7e55eb75fcc29129ffdhttps://github.com/gitlabhq/gitlabhq/issues/2365https://github.com/gitlabhq/gitlab-recipes/commit/c6c22b4fb68bbb6efb547cce6605dea4344ba9fe

替换Location指令也失败了: 试过这个,但没有成功:

Alias ^/(gitlab|assets) /home/git/gitlab/public
<Directory /home/git/gitlab/public>`
    RequestHeader set X_FORWARDED_PROTO 'https'
    SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"
    Require all granted
    Options -Multiviews
    # https://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule .* http://127.0.0.1:8085/%{REQUEST_URI} [P,QSA]
</Directory>

2 个答案:

答案 0 :(得分:3)

由于它位于相对根目录下,因此您仍需要运行以上所述的以下内容,以验证资产的正确映射(包括图标和CSS URL):

sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/gitlab

对于非相对网址用户,请不要使用额外的相对网址

sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

您也可以按@LpLrich所述重启:

sudo service gitlab restart

对于某些较旧的Linux设置,请使用:

sudo /etc/init.d/gitlab restart

然后刷新浏览器。

然而上述步骤都没有在我的系统上运行,因为,尽管我可以说,我在下面修复了不完善的Apache设置 - 包括它,以防你发现正确修复Gitlab但找到最终结果的相同问题在浏览器中失败。我确实改为不再使用相对URL根,但这并不重要。一旦gitlab步骤完成,这应该有助于Apache解决上述问题。抱歉, ProxyPassReverse 是您需要从问题的Apache设置中注意到的主要更改:

<IfModule mod_ssl.c>
<VirtualHost *:443>
  Servername gitlab.my_domain.com
  ServerAdmin my_admin@my_domain.com

  SSLCertificateFile /etc/apache2/ssl.crt/gitlab_my_domain.crt
  SSLCertificateKeyFile /etc/apache2/ssl.crt/gitlab_my_domain_private.key
  SSLCACertificateFile /etc/apache2/ssl.crt/gitlab.ca-bundle

  ##### All the other Apache SSL setup skipped here for StackOverflow ####

  ProxyPreserveHost On

  <Location />
    # New authorization commands for apache 2.4 and up
    # http://httpd.apache.org/docs/2.4/upgrading.html#access
    Require all granted

    # For relative URL root "host:your_gitlab_port/relative_root"
    #ProxyPassReverse http://127.0.0.1:8080/gitlab
    #ProxyPassReverse https://gitlab.my_domain.com/gitlab

    # For non-relative URL root
    ProxyPassReverse http://127.0.0.1:8080
    ProxyPassReverse https://gitlab.my_domain.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:8080%{REQUEST_URI} [P,QSA]
  RequestHeader set X_FORWARDED_PROTO 'https'

  # needed for downloading attachments
  DocumentRoot /home/git/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-ssl_error.log
  CustomLog /var/log/apache2/gitlab-ssl_forwarded.log common_forwarded
  CustomLog /var/log/apache2/gitlab-ssl_access.log combined env=!dontlog
  CustomLog /var/log/apache2/gitlab-ssl.log combined
</VirtualHost>
</IfModule>

(来自https://github.com/gitlabhq/gitlab-recipes/blob/master/web-server/apache/gitlab-ssl-apache2.4.conf

答案 1 :(得分:0)

这可能对您有帮助,

https://github.com/gitlabhq/gitlabhq/issues/3306#issuecomment-15971720

基本上它是说要运行rake assets:clean然后运行assets:precompile然后运行service gitlab restart

我已经预编译了我的资产,检查了public / assets文件夹并且可以看到它们已经存在但是有些图标没有显示所以我将它们清理干净,再次预编译并重新启动它然后它们开始显示。

运行

sudo -u git -H bundle exec rake assets:clean RAILS_ENV=production

然后

sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/gitlab

刷新页面,如果它不起作用,请尝试

sudo service gitlab restart

但是我现在查看了我的历史,我看不到自己重新启动它,所以我假设当发生这种情况时,我只是清理它们并再次预编译它们,我不必重新启动。