mod_rest Error: REST request is rejected by service

Hi

I am trying to control ejabberd from PHP and am having difficulties with all options. Current effort is to get mod_rest working. I have it installed and am able to make contact with ejabberd, but any command is rejected with 'Error: REST request is rejected by service'

Extracts from ejabberd.yml

    module: ejabberd_http
           "/rest": mod_rest

  mod_rest:
    allowed_ips:
      - "all"
    allowed_destinations:
      - "all"
    allowed_stanza_types:
      - "all"

Here is my php code:

      $headers = array();
      $request='<message to="admin@mydomain.org" from="rich@mydomain.org"><body>World</body></message>';
       $headers[] = 'Host: mydomain.org';
        $headers[] = 'Content-Type: text/html; charset=utf-8';
        $headers[] = 'Content-Length: '.strlen($request);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "http://"['jabberIP'].":5280/rest");
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_FAILONERROR, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        curl_setopt($ch, CURLOPT_HEADER, false);
        $response = curl_exec($ch);
        curl_close($ch);
        return $response;

Response is 'Error: REST request is rejected by service' - Nothing in the log..

Any thoughts?

You must configure mod_rest

You must configure mod_rest in old cfg settings format.

Thanks for that.. I have

Thanks for that..

I have added
include_config_file: /etc/ejabberd/additional.cfg

At the bottom of the modules section, pointing to file with this:

{mod_rest, [
              {allowed_ips, ['all']},
              {allowed_destinations, [ 'all' ]},
              {allowed_stanza_types, [ 'all' ]},
             ]
  },

Server won't start with error: CRASH REPORT Process <0.36.0> with 0 neighbours exited with reason: no function clause matching lists:map(#Fun, '/etc/ejabberd/additional.cfg')

Do you have any pointers on how to configure mod_rest when main config is in yml..

Huge thanks!

Not perfect but I found that

Not perfect but I found that this works for me:

mod_rest: {}

I am happy with default settings as I protect /rest through other means. Comment on the proper way of configuring would however be useful.

Thanks

Hi. how can i allow specific

Hi.
how can i allow specific ip? I use below comand but not working.

mod_rest:
access_commands:
- "all"
allowed_ips:
- "192.168.1.10"
allowed_destinations:
- "all"
allowed_stanza_types: "all"

default settings (mod_rest: {}) is working but I want allow specefic ip. how do that. I tested on ejabberd 15.06 and 15.09, but not working.
.

If I set this ooption with

If I set this ooption with wrong IP, then connection isn't allowed, if I set correct IP then all works correctly:

modules:
  mod_rest:
    allowed_ips:
      - "192.168.1.66"
Syndicate content