设定与目标

设定与目标

在 Debian 8.0 上,我尝试让 Apache 2.4.10 作为虚拟主机管理 GitLab CE 7.10 Omnibus 安装。

设定与目标

Apache 2 已经设置并运行几个看起来像的虚拟主机 vhost.example.com

我想要配置 Apache 和 GitLab,以便git.example.com由 Apache 处理并显示 GitLab Web 界面。

为此,我遵循了 https://stackoverflow.com/a/25809733/4352108

问题

我可以在 上访问 GitLab 主页git.example.com,但无法访问任何其他资源,例如 CSS 或图标。Apache 日志显示四个错误,如下所示:

[Sun May 10 20:24:57.146329 2015] [authz_core:error] [pid 4141] [client 1.2.3.4:80] AH01630: client denied by server configuration: /opt/gitlab/embedded/service/gitlab-rails/public/assets/application-TOKEN.css, referer: http://git.example.com/

在网上搜索并尝试了几种更改后,我还是卡在这里。有人知道如何解决这个问题吗?

配置文件

此外,这里还有一些我使用的“有趣”的配置文件:

/etc/apache2/sites-enabled/git.conf

<VirtualHost git.example.com:80>
    ServerAdmin [email protected]
    DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
    ServerName git.example.com
    ServerAlias git.example.com

    ProxyPreserveHost On

    <Location /opt/gitlab/embedded/service/gitlab-rails/public>

        Order deny,allow
        Allow from all
        Options FollowSymLinks
        Require all granted

        ProxyPassReverse http://localhost:8080
        ProxyPassReverse http://git.example.com
    </Location>

    RewriteEngine on
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule .* http://localhost:8080%{REQUEST_URI} [P,QSA]

    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  /${APACHE_LOG_DIR}/gitlab.error.log
    CustomLog /${APACHE_LOG_DIR}/gitlab.forwarded.log common_forwarded
    CustomLog /${APACHE_LOG_DIR}/gitlab.access.log combined env=!dontlog
    CustomLog /${APACHE_LOG_DIR}/gitlab.log combined
</VirtualHost>

/etc/gitlab/gitlab.rb

external_url 'http://git.example.com'
web_server['external_users'] = ['http']
nginx['enable'] = false

一些有趣的已启用 Apache 模块:

proxy
proxy_http

答案1

这对我有用:

<VirtualHost *:80>
  ServerName git.example.com
  ServerSignature Off
  DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
  ProxyPreserveHost On

  <Location />
    Require all granted
    ProxyPassReverse http://127.0.0.1:8080
    ProxyPassReverse http://git.example.com/
  </Location>

  RewriteEngine on
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA]

  # needed for downloading attachments
  DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public

</VirtualHost>

并尝试将用户从 http 更改为 www-data

答案2

在你的VirtualHost文件 :

代替

Order deny,allow
Allow from all

经过

Require all granted

你的问题已经解决了

相关内容