0

我无法修复由 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-enabledconf 文件中,这为我们的 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 - 用矩形替换的图标没有帮助。是的,我的服务器上的 443 端口上还有其他站点,所以如果我不需要,我不能只在它自己的端口/域上使用这个 Apache 配置。我可能只需要一些帮助来理解 Apache 2.4。我的 Apache 配置中是否缺少任何内容?

资源使用: https://github.com/gitlabhq/gitlab-recipes/commit/be95bd4f9bd3244641a4c7e55eb75fcc29129ffd , https://github.com/gitlabhq/gitlabhq/issues/2365 , https://github.com/gitlabhq/gitlab -食谱/提交/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>
4

2 回答 2

3

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

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

对于非相对 URL 用户,请省略额外的相对 URL 部分

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

于 2014-03-13T20:47:07.643 回答
0

这可能对你有帮助,

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

基本上它是说运行 arake assets:clean然后 aassets:precompile然后 aservice 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

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

于 2014-03-13T14:28:41.417 回答