需要通過http來創(chuàng)建ejabberd賬號,查找了一些官方資料,記錄一下。
配置信息
參考mod_register_web設(shè)置,做一些自己的修改。
#官方教程的參考
hosts:
- "localhost"
- "example.org"
- "example.com"
listen:
...
-
port: 5281
module: ejabberd_http
register: true
certfile: "/etc/ejabberd/certificate.pem"
tls: true
...
modules:
...
mod_register_web: {}
...
這是我修改,不需要https,取消了證書的配置和tls,添加ip限制。
-
port: 5280
module: ejabberd_http
request_handlers:
"/websocket": ejabberd_http_ws
## "/pub/archive": mod_http_fileserver
web_admin: true
http_bind: true
## register: true
captcha: false
-
ip: "127.0.0.1"
port: 5281
module: ejabberd_http
register: true
配置之后,重啟一下服務(wù),登錄http://localhost:5281/register/new 看到下面的圖片,則成功了。

image1

image2
可能遇到的問題,點(diǎn)擊注冊出現(xiàn)404的界面,那可能是你請求的URL不正確,必須帶/才行,官方module說明給出的解釋。
In this example the page is served in https://example.org:5281/register/
Make sure to include the last / character in the URL.
Otherwise when you enter a subpage the URL will not be correct,
for example: http://localhost:5281/new ---> 404 Not Found
HTTP請求
配置之后,通過網(wǎng)頁請求并不是最終想要的結(jié)果,需要實現(xiàn)的是,通過HTTP請求來創(chuàng)建賬號。
- 通過CURL方式
curl -XPOST 127.0.0.1:5281/register/new -d 'username=lucky&host=localhost&password=test&password2=test'
- 通過Postman方式來創(chuàng)建

image3
需要這四個參數(shù)。
username:hello
host:localhost
password:123456
password2:123456
參考資料
create-ejabberd-user-with-http
docs.ejabberd.im/get-started
mod_register_web-README.txt