Solve the problem that RabbitMQ cannot be accessed remotely

  RabbitMQ-Server-3.3.5 has just been installed, and the web management function has also been turned on, but now there is a problem:
for security reasons, the default user of guest can only log in through http://localhost:15672, You cannot use the IP address to log in, that is, you cannot access it remotely, which cannot be managed and maintained if there is no desktop installed on the server.





To solve this problem, you need to configure remote login permissions. Here, remote access is achieved through configuration files.
    This section mainly introduces configuration file modification for Unix and Windows.

1.

The default configuration file in Windows Windows environment is the rabbitmq.config.example file in the directory /%RabbitMQ Server%/rabbitmq_server-3.3.5/etc. We can modify it directly in this file (you don’t need to set environment variables) , you can also create a new rabbitmq.config file by yourself, and then configure the file path to the environment variable. Here, you can directly modify the rabbitmq.config.example file.
    Note: Before modifying, you need to stop the RabbitMQ service! ! Otherwise, it cannot be saved! ! !
Before configuration, you need to add users for access to the external network. You can use the command line to add users. You need to execute in the sbin directory of the RabbitMQ installation directory:
quote
duanwf@master:/opt/rabbitmq_server-3.3.5/sbin$ rabbitmqctl add_user admin admin


You can also add users and passwords through the web management page. Use the guest to log in to the web management page http://localhost:15672, enter the "admin" tab, and then click "Add a user", enter the correct account and password, and then select User role (must be selected):



In order to authorize the user to access VirtualHost "/", after the user is added, the user needs to be authorized, otherwise an error will occur during operation

quote
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=403, reply-text=ACCESS_REFUSED - access to queue 'hello' in vhost '/' refused for user 'admin', class-id=50, method-id=10), null, ""}


The detailed error log is:
java.io.IOException
 at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
 at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
 at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124)
 at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:766)
 at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:61)
 at com.asiainfo.mq.rabbitmq.rabbitmqtest.SendTest.main(SendTest.java:29)
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=403, reply-text=ACCESS_REFUSED - access to queue 'hello' in vhost '/' refused for user 'admin', class-id=50, method-id=10), null, ""}
 at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
 at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
 at com.rabbitmq.client.impl.AMQChannel $ BlockingRpcContinuation.getReply (AMQChannel.java:343)
 at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216)
 at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)
 ... 3 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=403, reply-text=ACCESS_REFUSED - access to queue 'hello' in vhost '/' refused for user 'admin', class-id=50, method-id=10), null, ""}
 at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:473)
 at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:313)
 at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:144)
 at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:91)
 at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:533)


The operation process is: Click the new user "admin" under the Admin tab to enter the authorization page. By default, click "set permission" directly:



After the user and authorization are added, in the rabbitmq.config.example file, add the following After saving the content, restart the RabbitMQ service:

……
[
 {rabbit,
  [%%
   %% Network Connectivity
   %% ====================
   %%
   %% By default, RabbitMQ will listen on all interfaces, using
   %% the standard (reserved) AMQP port.
   %%
   {tcp_listeners, [5672]},
   {loopback_users, ["admin"]},
……
  ]}
].

Enter http://192.168.0.124:15672 in the browser to access through the IP address and log in successfully:



Reference: http://dwf07223.blog.51cto.com/8712758/1547226

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326939815&siteId=291194637