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

标签 ssl proxy gitlab apache2.4

我无法修复由 Apache 2.4 代理的 Gitlab 上的图标。我的失败可能是因为我没有使用 passenger(passenger 提供了自己的一系列更深层次的问题),但我采取了在代理 /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 大小返回给浏览器。我应该将位置指令更新为目录吗?

备注:gitlab - icons replaced by rectangles没有帮助。是的,在我服务器的 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-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>

最佳答案

由于它位于相对根目录下,您仍然需要如上所述运行以下命令以验证 Assets 的正确映射(包括图标和 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)

关于ssl - 如何让 Gitlab 6.5 在 Apache 2.4 代理下显示其图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21768703/

相关文章:

asp.net - Forms Auth requireSSL 和 Https

linux - gpg key 请求在 dockerfile 中失败但在 bash 中失败

docker - 使用同一作者从 gitlab CI 下载另一个私有(private)存储库

http - 阻止在反向代理模式下通过 http 端口访问 rocket.chat

java - Spring Boot 中的 SSL 证书

email - 在代理后面使用 Powershell 发送邮件

firefox - SSL 错误 : illegal parameter alert

git - 无法从 Gitlab : Permission denied, 克隆存储库,请重试

docker - 如何查找在gitlab中运行的docker-in-docker的URL

java - 在 soapUI Pro 中启用 TLS 1.2