How to enable jsonrpc in confd

Is there any specific steps that need to be done (e.g. confd.conf settings) to enable ‘http:///jsonrpc’ interface?

I have webui enabled via confd.conf

  <webui>
    <enabled>true</enabled>

    <transport>
      <tcp>
        <enabled>true</enabled>
        <ip>0.0.0.0</ip>
        <port>8008</port>
      </tcp>

      <ssl>
        <enabled>true</enabled>
        <ip>0.0.0.0</ip>
        <port>8888</port>
      </ssl>
    </transport>

    <cgi>
      <enabled>true</enabled>
      <php>
        <enabled>true</enabled>
      </php>
    </cgi>
    <useForwardedClientIp>
      <proxyHeaders>X-Real-IP</proxyHeaders>
      <allowedProxyIpPrefix>169.254.0.0/24</allowedProxyIpPrefix>
    </useForwardedClientIp>

  </webui>

With the above

$ curl \
        -X POST \
        -H 'Content-Type: application/json' \
        -d '{"jsonrpc": "2.0", "id": 1, \
        "method": "login", \
        "params": {"user": "root", \
        "passwd": "root"}}' \
        http://127.0.0.1:8008/jsonrpc

<!DOCTYPE html>
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
The requested URL /jsonrpc was not found on this server.
<hr>
<address> undefined Server at localhost:8008 </address>
</body>

In examples/json_rpc/common_flow I see following files are present in docroot

$ tree docroot/
docroot/
___ confd
___ ___ Comet.js
___ ___ example.js
___ ___ index.js
___ ___ JsonRpc.js
___ ___ lib
___     ___ bluebird
___     ___ ___ bluebird.js
___     ___ jquery
___     ___ ___ jquery.js
___     ___ lodash
___         ___ lodash.js
___ index.html
___ login
___ ___ lib
___ ___ ___ jquery.js
___ ___ login.css
___ ___ login.js
___ login.html

Are these files needed in target also to support jsonrpc?

Hello,

docroot files are an example implementation of “web-app/stack” that uses JSON-RPC, but as such are NOT required for JSON-RPC API to work e.g. via using curl client to talk to JSON-RPC ConfD server…
When you see sibling directory examples.confd/json_rpc/webui, it contains completely different web-app stack in docroot (after build).

Hard to say what’s wrong in your case, i dont have experience w.g. with proxy settings - what other parts you do (not) have e.g. regarding AAA? Try building from the codebase/confd.conf off of existing examples (common_flow of webui) and see what change causes it to break…
(you can ignore/skip docroot for either example, just start confd with the confd.conf, and try using curl e.g. according to ConfD user guide’s JSON-RPC chapter.

Thanks @josephm . Actually the file name docroot/confd/JsonRpc.js was throwing me off. And my js skills are too poor to make an informed judgement.

Anyways now I would try to create a minimal working example with confd for json rpc.

Regards,

No worries, sometimes the names of files might not be very descriptive, and can easily lead to confusion :slight_smile:

ConfD’s examples are sort of “full stack”, including ConfD as JSON-RPC server, but also JS files/frontend web files as JSON-RPC client (docroot). Funnily both are served by ConfD’s web server in the examples.