1.0.0 • Public • Published

HTTP Proxy Server

This is a small tool developed using Node native modules only (no dependencies) that connects to a TLS-based JSON-RPC server that does not serve a HTTP interface (e.g. ElectrumX) and provides a local HTTP interface you can send your requests to.

For the sake of concurrency, the remote JSON-RPC server must implement the message ID handling (request's and response's "id" property).

This is a command line tool. Not intended to be used as NodeJS library.

How to install

Download this repo and just use the tlsjsonproxy.js file in command line.

For a global install, run npm i -g tlsjsonproxy and use the "tlsjsonproxy" command instead.

How to use

First, try connecting to the remote server to check if it's up. Example:

openssl s_client -connect

Try pasting a command, e.g.:

{ "method" : "blockchain.block.header", "params": [ 1], "id": "msg_id"}

If everything is all ok, you'll get something like:

{"jsonrpc": "2.0", "result": "010000006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e857233e0e61bc6649ffff001d01e36299", "id": "msg_id"}

Now close the connection (Ctrl + C) and let's set up this script to allow us to perform the same request through a HTTP API. The usage is:

node tlsjsonproxy.js <remote server> <remote port> <local port> [<local server=>]
  • Remote server: the server to connect to
  • Remote port: the port in the remote server
  • Local port: local port in your machine where the HTTP server will listen at
  • Local server (optional): the local network interface ( for all, to accept loopback connections only or the interface's IP address)


node tlsjsonproxy.js 50002 8080

Now you can perform the same request we did before, but using HTTP.

Note: the examples below were generated by Insomnia

Example with cURL command:

curl --request POST \
  --url http://localhost:8081/ \
  --header 'content-type: application/json' \
  --data '{ "method" : "blockchain.block.header", "params": [ 1]}'

Example with Javascript's fetch:

fetch("http://localhost:8081/", {
  "method": "POST",
  "headers": {
    "content-type": "application/json"
  "body": {
    "method": "blockchain.block.header",
    "params": [
.then(response => {
.catch(err => {

Example with PHP cURL:

$curl = curl_init();
  CURLOPT_PORT => "8081",
  CURLOPT_URL => "http://localhost:8081/",
  CURLOPT_POSTFIELDS => "\"method\" : \"blockchain.block.header\"\"params\": [ 1]}",
    "content-type: application/json"
$response = curl_exec($curl);
$err = curl_error($curl);
if ($err{
  echo "cURL Error #:" . $err;
} else {
  echo $response;

Package Sidebar


DownloadsWeekly Downloads






Unpacked Size

5.67 kB

Total Files


Last publish


  • jesobreira