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

穿精又带淫゛_ 提交于 2019-11-27 07:04:45

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 地址),例如:
[{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:
[{rabbitmq_management,
  [{listener, [{port,     15672},
               {ssl,      true},
               {ssl_opts, [{cacertfile, "/path/to/cacert.pem"},
                           {certfile,   "/path/to/cert.pem"},
                           {keyfile,    "/path/to/key.pem"}]}
              ]}
  ]}
].








易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!