无法从 Hawtio 仪表板连接到远程服务器

Unable to connect to remote server from Hawtio dashboard

我在 remote-server-1 上有一个 camel web 应用程序 运行,它是一个 tomcat 8 服务器。我在这个 tomcat 上附加了一个 jolokia jvm 代理,如下所示-

java -jar jolokia-jvm-1.3.5-agent.jar start <PID>

我通过访问 http://remote-server-1:port/jolokia-

在我的本地计算机上得到以下响应
{
    "request": {
        "type": "version"
    },
    "value": {
        "agent": "1.3.5",
        "protocol": "7.2",
        "config": {
            "maxDepth": "15",
            "discoveryEnabled": "true",
            "maxCollectionSize": "0",
            "agentId": "***.***.***.**-16224-35a7a114-jvm",
            "debug": "false",
            "agentType": "jvm",
            "historyMaxEntries": "10",
            "agentContext": "\/jolokia",
            "maxObjects": "0",
            "debugMaxEntries": "100"
        },
        "info": {
            "product": "tomcat",
            "vendor": "Apache",
            "version": "8.0.35"
        }
    },
    "timestamp": 1491307702,
    "status": 200
}

我还在本地 tomcat8.5 上部署了 hawtio.war。当我尝试连接到此远程代理时,我被重定向到登录页面。我无法弄清楚我哪里出错了。谁能帮我解决这个问题?

从 2.10.1 开始: 使用 hawtio.proxyAllowlist 而不是 hawtio.proxyWhitelist。 (感谢 rastadrian 指出。)


从 hawtio 1.5.0 开始,您需要将远程主机添加到 hawtio.proxyWhitelist 系统 属性。

http://hawt.io/docs/configuration/#configuration-properties

hawtio.proxyWhitelist - Comma-separated whitelist for target hosts that the hawtio-jmx Connect plugin can connect to via ProxyServlet (default localhost, 127.0.0.1). All hosts that are not listed in this whitelist are denied to connect for security reasons. This option can be set to * to restore old behavior and whitelist all hosts. Prefixing an element of the list with "r:" allows to define a regexp (example: localhost,r:myservers[0-9]+.mydomain.com)

如果您使用的是 hawtio.war,请像这样修改它的 WEB-INF/web.xml

  <servlet>
    <servlet-name>jolokia-proxy</servlet-name>
    <servlet-class>io.hawt.web.ProxyServlet</servlet-class>
    <!--
      Comma-separated list of allowed target hosts. It is required for security.
      '*' allows all hosts but keep in mind it's vulnerable to security attacks.
    -->
    <init-param>
      <param-name>proxyWhitelist</param-name>
      <param-value>
        localhost,
        127.0.0.1,
        remote-server-1
      </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

如果您使用的是 Hawtio 的可运行 JAR 版本,您也可以在启动应用程序时传递参数 hawtio.proxyWhitelist:

java -Dhawtio.proxyWhitelist=SERVERNAME -jar hawtio-app-1.5.3.jar