Jenkins / Apache反向代理错误

时间:2016-01-22 06:59:59

标签: apache jenkins reverse-proxy

我遇到了一个基于我的搜索似乎相当普遍的问题,但是我已经遵循了我遇到的所有说明和/或修正,但没有一个对我有用,所以我和#39; m问这个希望有人可以指导我朝正确的方向发展。

我在Homebrew的OS X 10.11.2上安装了Jenkins 1.644。我按照these说明如何安装并在OS X Server 5.0.15网站内进行设置(我相信这个版本的OS X服务器正在运行Apache 2.4.16。

问题:当我连接到Jenkins的管理控制台时,我收到错误消息"看起来您的反向代理设置已损坏。"以及指向this jenkins doc的链接。

点击http://127.0.0.1:8080/manage不会产生错误。

我已将代理设置添加到我的虚拟主机文件中,如下所示:

ProxyRequests     Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass / http://localhost:8080/ nocanon
ProxyPassReverse / http://localhost:8080/
ProxyPassReverse / http://jenkins.exampledomain.com/

RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"

当我做测试卷曲时:

curl -iLk -e https://jenkins.exampledomain.com/manage \
   https://jenkins.exampledomain.com/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/test

我得到以下结果:

HTTP/1.1 302 Found
Date: Fri, 22 Jan 2016 06:30:57 GMT
Server: Jetty(winstone-2.9)
X-Content-Type-Options: nosniff
Location: https://jenkins.exampledomain.com/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/testForReverseProxySetup/https%3A%2F%2Fjenkins.exampledomain.com%2Fmanage/
Content-Length: 0
MS-Author-Via: DAV

HTTP/1.1 404 Not Found
Date: Fri, 22 Jan 2016 06:30:57 GMT
Server: Apache/2.4.16 (Unix) OpenSSL/0.9.8zg
Content-Length: 325
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/testForReverseProxySetup/https://jenkins.exampledomain.com/manage/ was not found on this server.</p>
</body></html>

显然,该地址位于此服务器上,因为我可以通过转到正确的地址进入管理控制台。

我被困了...... Apache配置不是我的强项。我正在寻找任何帮助。

- 编辑更多信息 -

从/ Library / Server / Web / Config / apache2 / sites目录添加完整的虚拟主机文件,以获取更多详细信息。

<VirtualHost 127.0.0.1:34543>
    ServerName https://jenkins.exampledomain.com:443
    ServerAdmin admin@example.com
    DocumentRoot "/Library/Server/Web/Data/Sites/jenkins.exampledomain.com"
    DirectoryIndex index.html index.php default.html
    CustomLog /var/log/apache2/access_log combinedvhost
    ErrorLog /var/log/apache2/error_log
    <IfModule mod_ssl.c>
        SSLEngine On
        SSLCipherSuite "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"
        SSLProtocol -ALL +TLSv1
        SSLProxyEngine On
        SSLCertificateFile "/etc/certificates/machine.local.certCA1FileLocation.pem"
        SSLCertificateKeyFile "/etc/certificates/machine.local.certCA2FileLocation.key.pem"
        SSLCertificateChainFile "/etc/certificates/machine.local.certCA3FileLocation.chain.pem"
        SSLProxyProtocol -ALL +TLSv1
        SSLProxyCheckPeerCN off
        SSLProxyCheckPeerName off
    </IfModule>
    <Directory "/Library/Server/Web/Data/Sites/jenkins.exampledomain.com">
        Options All -Indexes -ExecCGI -Includes +MultiViews
        AllowOverride None
        <IfModule mod_dav.c>
            DAV Off
        </IfModule>
        <IfDefine !WEBSERVICE_ON>
            Require all denied
            ErrorDocument 403 /customerror/websitesoff403.html
        </IfDefine>
    </Directory>

    ProxyRequests     Off
    ProxyPreserveHost On
    AllowEncodedSlashes NoDecode

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass / http://localhost:8080/ nocanon
    ProxyPassReverse / http://localhost:8080/
    ProxyPassReverse / http://jenkins.exampledomain.com/

    RequestHeader set X-Forwarded-Proto "https"
        RequestHeader set X-Forwarded-Port "443"
</VirtualHost>

- 编辑2另一个发现 -

我注意到试图卷曲到未找到的&#39;确定服务器报告未找到它的url。如果我点击https://jenkins.exampledomain.com/manage/我会得到一个404.但是,如果我放弃尾随/,它就可以了。 https://jenkins.exampledomain.com/manage成功。希望这对某人意味着什么!

由于

2 个答案:

答案 0 :(得分:3)

我知道这是一个老问题,但我遇到了同样的错误问题:

HTTP ERROR 404

Problem accessing /administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/testForReverseProxySetup/https%3A%2F%2Fbuild.scopeitconsulting.com%2Fmanage/. Reason:

http://build.domain.com/manage vs. https://build.domain.com/manage

我能够通过包含作者问题中的两行来解决我的问题:

RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"

所以这是我工作的ssl.conf配置中的相关部分,以防它对任何人有帮助。我在使用http的根上下文中在端口8080上运行Jenkins,但在Apache强制执行https后反向代理它。

ProxyPass               / http://localhost:8080/ nocanon
ProxyPassReverse        / http://localhost:8080/
ProxyPassReverse        / http://build.domain.com/
ProxyPassReverse        / https://build.domain.com/
ProxyRequests           Off
ProxyPreserveHost       On
AllowEncodedSlashes     NoDecode
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
<Proxy http://localhost:8080/>
 Order deny,allow
 Allow from all
</Proxy>

我希望这能帮助那些喜欢我的人花费太多时间来寻找可以解决错误的工作配置。

答案 1 :(得分:0)

您需要在catalina.properties文件中添加以下内容。仅更新Apache配置本身是不够的。

.gitlab-ci.yml