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 位址),例如:
<a href="http://my.oschina.net/moooofly/blog/407023#">?</a>
1
2
3
4
5
6
<code>[{rabbitmq_management,</code>
<code> </code><code>[{listener, [{port, 15672},</code>
<code> </code><code>{ip,</code><code>"127.0.0.1"</code><code>}</code>
<code> </code><code>]}</code>
<code> </code><code>]}</code>
<code>].</code>
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:
7
8
9
<code> </code><code>[{listener, [{port, 15672},</code>
<code> </code><code>{ssl, </code><code>true</code><code>},</code>
<code> </code><code>{ssl_opts, [{cacertfile,</code><code>"/path/to/cacert.pem"</code><code>},</code>
<code> </code><code>{certfile, </code><code>"/path/to/cert.pem"</code><code>},</code>
<code> </code><code>{keyfile, </code><code>"/path/to/key.pem"</code><code>}]}</code>