title: Enterprise XRouter Proxy description: This guide explains how to setup and configure your Service Node to utilize Blocknet's Enterprise XRouter Proxy.
This guide explains how to setup and configure your Service Node to utilize Blocknet's Enterprise XRouter Proxy (EXR).
The XRouter Proxy acts as a reverse proxy (similar to a load balancer) for all your XRouter services and oracles. The reverse proxy is comprised of an nginx web server and a uwsgi python handler.
XRouter Proxy is designed to work in Docker a environment, although this is not a mandatory requirement. This guide will be following a Docker environment and assumes you have Docker installed.
To setup your Enterprise XRouter Proxy, follow these steps:
- EXR Configuration File Setup
- Service Node Configuration File Setup
- Deploy EXR Container
- SPV Wallets Setup
- SPV RPC Type Plugins Setup
- URL Type Plugins Setup
- Domain Name Setup
A uwsgi.ini
configuration file is required to hook up the services and oracles that need to be exposed through the proxy.
Example uwsgi.ini
:
## SPV sample configuration file
[uwsgi]
processes = 8
threads = 2
# Place your Service Node private key here (this is not a wallet private key!)
# Allows the XRouter Proxy to sign packets on your Service Node's behalf
# DO NOT SHARE THIS KEY
set-ph = SERVICENODE_PRIVKEY=cV1bo3ME3qvw9Sxzo72skbFsAQ6ihyT6F8VXMe8mzv6EJoqFVXMV
# mainnet or testnet
set-ph = BLOCKNET_CHAIN=mainnet
# Handle XRouter payments
set-ph = HANDLE_PAYMENTS=true
set-ph = HANDLE_PAYMENTS_RPC_HOSTIP=192.168.1.25
set-ph = HANDLE_PAYMENTS_RPC_PORT=41419
set-ph = HANDLE_PAYMENTS_RPC_USER=user
set-ph = HANDLE_PAYMENTS_RPC_PASS=pass
set-ph = HANDLE_PAYMENTS_RPC_VER=2.0
# Sample SPV RPC configuration
set-ph = RPC_BLOCK_HOSTIP=192.168.1.25
set-ph = RPC_BLOCK_PORT=41419
set-ph = RPC_BLOCK_USER=user
set-ph = RPC_BLOCK_PASS=pass
set-ph = RPC_BLOCK_VER=2.0
# Sample XCloud plugin configuration
set-ph = URL_SomeCustomPlugin_HOSTIP=192.168.1.5
set-ph = URL_SomeCustomPlugin_PORT=8080
- Create a new directory and a
uwsgi.ini
file. This guide will use/xrproxy/uwsgi.ini
. - Adjust
processes
andthreads
related to your setup. - Change
SERVICENODE_PRIVKEY=
to your servicenode privkey.- On your Service Node client type
servicenodestatus
and retrieve yoursnodeprivkey
.
- On your Service Node client type
- Change
RPC_BLOCK_...=
HOSTIP/PORT/USER/PASS to your settings in your service nodeblocknet.conf
- Save and close the
uwsgi.ini
file. - Anytime you edit the
uwsgi.ini
file, you need to restart the container. (or justservice nginx restart
within the container??)
-
To use the XRouter Proxy you have to use a port that is not
port=41412
.- Set
port=80
or any other port you have designated Eg.port=9090
.
- Set
-
Set
host=
to the server IP or server domain name.host=10.0.0.1
orhost=api.domainnamehere.com
.
-
Save and close the file.
-
In your servicenode client type
xrReloadConfigs
for the settings to take.- Send the new information out to the network by using
servicenodesendping
.
- Send the new information out to the network by using
-
In a console where Docker is available type:
docker pull blocknetdx/xrouterproxy:latest
. -
Running the xrproxy in a container:
docker run -d --name xrproxy -p 80:80 -p 443:443 -v=/xrproxy:/opt/uwsgi/conf
--name xrproxy
names the container 'xrproxy'-p 80:80
exposes the container to port 80. Use this if you setport=80
in yourxrouter.conf
- Use
-p 9090:80
if you setport=9090
in yourxrouter.conf
- Use
- Optional: Add
-p 443:443
if you wish to provide a HTTPS API end point.- Note: This proxy does not support 443 through the Blocknet client.
-v=/xrproxy:/opt/uwsgi/conf
connects a host volume to the xrproxy container.-v=/dir/to/conf:/opt/uwsgi/conf
change/dir/to/conf
to where theuwsgi.ini
file is saved locally
-
To access inside the container type:
docker exec -it xrproxy /bin/bash
. -
To access xrproxy container logs type:
docker logs xrproxy
. -
Test to see if the XRProxy is working:
curl -X POST -H "content-type: application/json" --data-binary '[]' localhost:9090/xr/BLOCK/xrGetBlockCount
- Adjust
localhost:9090
to your settings- If you used
port=80
you can just use your IP.10.0.0.1/xr/BLOCK/xrGetBlockCount
orapi.domainnamehere.com/xr/BLOCK/xrGetBlockCount
- If you used
- Adjust
-
Any additional SPV wallets are added based on this SPV template. Use the asset's ticker for each additional SPV wallet you're adding.
set-ph = RPC_WALLET_...=
for HOSTIP, PORT, USER, PASS, VER
Litecoin example:
set-ph = RPC_LTC_HOSTIP=127.0.0.1 set-ph = RPC_LTC_PORT=9332 set-ph = RPC_LTC_USER=litecoin set-ph = RPC_LTC_PASS=litecoin1234 set-ph = RPC_LTC_VER=2.0
-
Add each asset's ticker in the
wallets=
section in yourxrouter.conf
.- For Litecoin add
LTC
in yourxrouter.conf
.wallets=BLOCK,LTC
- For Litecoin add
-
In your servicenode client type
xrReloadConfigs
for the settings to take.- Send the new information out to the network by using
servicenodesendping
.
- Send the new information out to the network by using
-
SPV RPC plugins are setup similar to SPV Wallets, but you state which RPC call to invoke with
set-ph RPC_..._METHOD=
.-
SPV RPC plugin for Litecoin's
getbestblockhash
example:uwsgi.ini
entry:
# Litecoin RPC SPV Services ## getbestblockhash set-ph = RPC_ltc_getbestblockhash_HOSTIP=127.0.0.1 set-ph = RPC_ltc_getbestblockhash_PORT=9332 set-ph = RPC_ltc_getbestblockhash_METHOD=getbestblockhash set-ph = RPC_ltc_getbestblockhash_USER=litecoin set-ph = RPC_ltc_getbestblockhash_PASS=litecoin1234 set-ph = RPC_ltc_getbestblockhash_VER=2.0
-
-
Add
ltc_getbestblockhash
to theplugins=
area of yourxrouter.conf
- You will need a
ltc_getbestblockhash.conf
entry for your Blocknet client to load the service.
- You will need a
-
In your servicenode client type
xrReloadConfigs
for the settings to take.- Send the new information out to the network by using
servicenodesendping
.
- Send the new information out to the network by using
-
Test to see if this XCloud RPC is working:
curl -X POST -H "content-type: application/json" --data-binary '[]' localhost:9090/xrs/ltc_getbestblockhash
-
You will need to setup a container or webserver for non-RPC based calls.
-
Currency Exchange plugin example:
set-ph = URL_CurrencyExchangeRate_HOSTIP=172.17.0.1 set-ph = URL_CurrencyExchangeRate_PORT=9195
-
The webserver needs to be setup so that you can cURL
172.17.0.1:9195/xrs/CurrencyExchangeRate
-
Add
CurrencyExchangeRate
to theplugins=
area of yourxrouter.conf
. -
You will need a
CurrencyExchangeRate.conf
entry for your Blocknet client to load the service:
parameters=string,string fee=0 clientrequestlimit=30000 disabled=0 help=Outputs the exchange rate between two currency pairs; CurrencyExchangeRate [currency_id1] [currency_id2]; Example: xrService xrs::CurrencyExchangeRate USD CAD; To see a list of currency ID's use xrService xrs::WorldCurrencyList private::type=rpc private::rpcip=172.17.0.1 private::rpcport=9195
-
-
In your servicenode client type
xrReloadConfigs
for the settings to take.- Send the new information out to the network by using
servicenodesendping
.
- Send the new information out to the network by using
-
Test to see if this XCloud plugin is working:
curl -X POST -H "content-type: application/json" --data-binary '["CAD","USD"]' localhost:9090/xrs/CurrencyExchangeRate
-
Allow
port 80
through your firewall. -
Register a domain name.
- Point the A record to your server IP (Note: this may take up to 24hrs for the change to happen).
- A record, @, Server IP address
- Point the A record to your server IP (Note: this may take up to 24hrs for the change to happen).
-
Enter the container by typing:
docker exec -it xrproxy /bin/bash
. -
Edit the
nginx.conf
file located at/etc/nginx/nginx.conf
.- Find the
server
block in thenginx.conf
. - Adjust
nginx.conf
to point to your domain name:
server { listen 80; server_name api.domainnamehere.com; ... }
- Find the
-
For the settings to take, while you're inside the container, restart nginx by typing:
service nginx restart
.- You should see a successfully restarted service response.
-
Adjust your
xrouter.conf
host=
to point to the domain name and setport=80
if you haven't already done so. -
In your servicenode client type
xrReloadConfigs
for the settings to take.- Send the new information out to the network by using
servicenodesendping
.
- Send the new information out to the network by using