【问题标题】:Some Manage Jenkins Links Don't Work - Nginx Reverse-Proxy, Tomcat一些管理 Jenkins 链接不起作用 - Nginx 反向代理、Tomcat
【发布时间】:2019-05-20 22:40:56
【问题描述】:

我在同一个 Windows 2012 R2 操作系统上设置了 2 个不同版本的 Jenkins。 Jenkins v1.590 在 Apache Tomcat Web 服务器后面运行,Jenkins 2.164 作为 Windows 服务运行。两个 Jenkins 实例都可以通过 HTTPS 访问。

为了完成这项工作,我将 Nginx 作为反向代理运行,它将所有对 https://jenkins.company.com/jenkins 的请求重定向到 Tomcat 服务器,并将 https://jenkins2.company.com 重定向到 Jenkins 2.164 Windows 服务。

除了 Jenkins v1.590 上的异常行为外,一切都运行良好。我遇到的问题是,当我访问 Manage Jenkins 下的 一些 链接时,它们会重定向到 localhost。

以下是可以正常工作的链接:

然后有一些链接不起作用:

还有很多其他的。

如果我复制到新窗口并在末尾添加 /,我仍然可以访问这些链接,例如:https://jenkins.company.com/jenkins/configureSecurity/ 工作正常。

我不确定为什么在 Jenkins v1.590 中会出现这些差异。请注意,我最近在安装 Nginx 之前进行了此更改,所有链接都可以正常工作。

以下是我的配置:

Nginx:

upstream tomcat_server {
    # Tomcat is listening on default 8080 port
    server 127.0.0.1:8080 fail_timeout=0;
}

server {
    listen       443 ssl;
    server_name  jenkins.company.com/jenkins;

    ssl_certificate C:/nginx1.15.12/certs/jenkins/server.crt;
    ssl_certificate_key C:/nginx1.15.12/certs/jenkins/server.key;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto https;
        proxy_redirect off;
        proxy_connect_timeout      240;
        proxy_send_timeout         240;
        proxy_read_timeout         240;
        # note, there is not SSL here! plain HTTP is used
        proxy_pass http://tomcat_server;

    }
}

Tomcat 配置:

<Connector executor="tomcatThreadPool"
    port="8080" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443" 
    proxyName="localhost"
    proxyPort="443"
    scheme="https"/>

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

【问题讨论】:

    标签: tomcat nginx jenkins nginx-reverse-proxy


    【解决方案1】:

    好的,我想通了。我不得不将 Tomcat 服务器上的 proxyName 更改为 url。这最终成为了解决方案:

    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" 
               proxyName="jenkins.company.com"
               proxyPort="443"
               scheme="https"/>
    

    【讨论】:

      猜你喜欢
      • 2017-10-22
      • 2019-06-15
      • 2020-06-23
      • 2019-06-05
      • 1970-01-01
      • 2018-01-20
      • 1970-01-01
      • 2020-08-30
      • 2017-06-29
      相关资源
      最近更新 更多