简体   繁体   English

Jenkins / Apache 反向代理错误

[英]Jenkins / Apache Reverse Proxy Error

I am running into an issue that seems to be fairly common based off of my searches, however I've followed all the instructions and/or fixes I've run into but none have worked for me so I'm asking this hoping someone can guide me in the right direction.根据我的搜索,我遇到了一个似乎相当普遍的问题,但是我遵循了我遇到的所有说明和/或修复程序,但没有一个对我有用,所以我问这个希望有人可以引导我走向正确的方向。

I have Jenkins 1.644 installed on OS X 10.11.2 from Homebrew.我在 Homebrew 的 OS X 10.11.2 上安装了 Jenkins 1.644。 I followed these instructions on how to install and get it setup inside OS X Server 5.0.15 Websites (I believe this version of OS X server is running Apache 2.4.16.我跟着这些关于如何安装并把它OS X服务器5.0.15网站内设置说明(我相信这个版本的OS X服务器是运行Apache 2.4.16。

The problem: When I connect to the manage console in Jenkins, I get the error message "It appears that your reverse proxy set up is broken."问题:当我连接到 Jenkins 中的管理控制台时,我收到错误消息“您的反向代理设置似乎已损坏。” and a link to this jenkins doc .以及指向此 jenkins 文档的链接。

Hitting http://127.0.0.1:8080/manage does not produce the error.点击http://127.0.0.1:8080/manage不会产生错误。

I have added the proxy settings to my virtual host file like so:我已将代理设置添加到我的虚拟主机文件中,如下所示:

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"

When I do the test curl:当我做测试卷曲时:

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

I get the following results:我得到以下结果:

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>

Clearly that address is on this server because I can enter the management console by going to the correct address.显然,该地址在此服务器上,因为我可以通过转到正确的地址来进入管理控制台。

I'm stuck... Apache configuration is not my strong point.我被卡住了...... Apache 配置不是我的强项。 I'm looking for any help.我正在寻找任何帮助。

--EDIT More Info-- --编辑更多信息--

Adding the full virtual host file from the /Library/Server/Web/Config/apache2/sites directory for further detail.从 /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>

--EDIT 2 Another Finding-- ——编辑 2 另一个发现——

I have noticed by attempting to curl to the 'not found' url above that indeed the server is reporting it not found.我通过尝试 curl 到上面的“未找到”网址注意到服务器确实报告未找到它。 If I hit https://jenkins.exampledomain.com/manage/ I will get a 404. However, if I leave off the trailing /, it works.如果我点击https://jenkins.exampledomain.com/manage/我会得到一个 404。但是,如果我去掉尾随的 /,它就可以工作。 https://jenkins.exampledomain.com/manage is successful. https://jenkins.exampledomain.com/manage成功。 Hopefully this means something to someone!希望这对某人有意义!

Thanks谢谢

I know this is an old question, but I was having the same problem with the error:我知道这是一个老问题,但我遇到了同样的错误问题:

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

I was able to solve my problem by including the two lines from the author's question:我能够通过包含作者问题中的两行来解决我的问题:

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

So here is my relevant section from a working ssl.conf configuration in case it helps anybody.所以这是我从工作 ssl.conf 配置中获得的相关部分,以防它对任何人有帮助。 I am running Jenkins on port 8080 at the root context with http but reverse proxying it behind Apache enforcing https.我正在使用 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>

I hope this helps somebody who like me has spent way too much time trying to find a working configuration to resolve the error.我希望这可以帮助像我这样的人花了太多时间试图找到一个有效的配置来解决错误。

You need to add below to catalina.properties file.您需要在 catalina.properties 文件中添加以下内容。 Updating Apache configuration itself is not sufficient.更新 Apache 配置本身是不够的。

org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM