【原创】RabbitMQ 之 HTTP server 插件(翻译)

本文详细介绍了rabbitmq-mochiweb插件如何为其他具有HTTP接口的插件提供服务,包括配置HTTP监听端口、SSL设置以及使用示例。重点阐述了如何在不同场景下灵活配置插件,以实现高效安全的通信。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


HTTP server plugin  
HTTP 服务器插件  

The rabbitmq-mochiweb plugin provides hosting for other plugins that have HTTP interfaces. It allows these interfaces to co-exist on one or more HTTP listeners.  
rabbitmq-mochiweb 插件可以为其他拥有 HTTP 接口到插件提供 hosting 功能。允许这些接口并存与一个或者多个 HTTP listener。  

Configuration  
配置方式  

Plugins using rabbit   mq-mochiweb typically take a listener configuration item to configure their listening HTTP port. In this page we will give examples for the rabbitmq_management application, but the same configuration can be applied to rabbitmq_jsonrpc and rabbitmq_web_stomp_examples.  
使用 rabbitmq-mochiweb 的插件,典型配置为通过一个 listener 配置条目配置 HTTP 监听端口。在这里,我们将通过 rabbitmq_management 应用作为示例进行说明,同样的配置可以应用到 rabbitmq_jsonrpc 和 rabbitmq_web_stomp 到例子上。  

The listener configuration item can contain the following keys:  
listener 配置条目可以包含以下 key 值:  
  • port (mandatory)
  • ip (to listen on only one interface)
  • ssl (to enable SSL)
  • ssl_opts (to configure SSL)


Listening on a single interface  
仅监听单独一个接口  

Use ip to specify an interface for mochiweb to bind to (giving an IP address as a string or tuple). For example:  
可以使用 ip 来指定 mochiweb 要绑定的接口(以字符串或者元组的形式给出 IP 地址),例如:  
?
1
2
3
4
5
6
[{rabbitmq_management,
   [{listener, [{port, 15672},
                {ip, "127.0.0.1" }
               ]}
   ]}
].

SSL  

Set ssl to true to turn on SSL for a listener. Use ssl_opts to specify SSL options. These are the standard Erlang SSL options - see the main page on SSL for more information.  
设置 ssl 为 true 可以将一个 listener 设置为支持 SSL 。通过 ssl_opts 可以指定 SSL 选项。这些选项均为标准 Erlang SSL 选项 - 详见 SSL 的 man 页。  

For convenience, if you do not specify ssl_opts then rabbitmq-mochiweb will use the same options as the main RabbitMQ server does for AMQP over SSL, but with client certificate verification turned off. If you wish to use client certificate verification, specify ssl_opts explicitly.  
在简单使用时,如果你没有设置 ssl_opts,那么 rabbitmq-mochiweb 将使用和 RabbitMQ 服务器针对 AMQP over SSL 同样的选项,但是关闭了客户端证书验证机制。如果你希望使用客户端证书验证机制,可以显式设置 ssl_opts 内容。  

For example:  
?
1
2
3
4
5
6
7
8
9
[{rabbitmq_management,
   [{listener, [{port,     15672},
                {ssl,      true },
                {ssl_opts, [{cacertfile, "/path/to/cacert.pem" },
                            {certfile,   "/path/to/cert.pem" },
                            {keyfile,    "/path/to/key.pem" }]}
               ]}
   ]}
].



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值