ActiveMQ 5.10:无法限制从远程客户端访问服务器

时间:2014-11-26 19:56:15

标签: security connection activemq restrict

我在MacOSX Yosemite上安装ActiveMQ 5.10。 我可以更改文件jetty-realm.properties以限制对localhost:8161的Web控制台的访问。

但是,当我编写Ruby代码以使用Stomp连接到ActiveMQ时:

require 'stomp'
client = Stomp::Client.new('any username', 'any password', 'localhost', 61613)

我可以使用客户端发布和订阅ActiveMQ服务器上的每个队列。

有人可以建议我可以限制远程连接对ActiveMQ服务器的访问。

我尝试了以下链接,但它们都不起作用:     https://security.stackexchange.com/questions/7989/how-to-secure-a-activemq     http://activemq.apache.org/version-5-getting-started.html#Version5GettingStarted-ConfiguringActiveMQ     http://activemq.apache.org/security.html

1 个答案:

答案 0 :(得分:0)

我玩了一段时间后找到了答案并阅读了整个代理文件。

在ActiveMQ 5.10中,代理直接放在 conf / activemq.xml 中。

首先,我解决了这样的问题:在activemq.xml中,在<broker>下,我把:

<plugins> 
  <simpleAuthenticationPlugin>
    <users>
      <authenticationUser username="admin" password="password" groups="admins,publishers,consumers"/>
    </users>
  </simpleAuthenticationPlugin>
</plugins>

因此,所有愚蠢的文档中缺少<plugins>使得配置无用。

更好的解决方案:

我复制 activemq.xml 中的整个<broker>部分,并将其放在名为 broker.xml 的文件中(您可以将其称为任何内容,例如 apache_dumb_documentation.xml ),在名为<bean>

的部分下
<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

  <broker>
    ... broker config here, including <plugins> ...
  </broker>

</beans>

然后在activemq中,在<broker>的前一个地方,我只写:

<import resource="broker.xml"/>