11

In the normal use case, Parity runs on localhost. However, I'm building a demo web site that uses Web3JS to connect to a public parity node running on port 8545.

I am publicly serving a Node/VueJS site using nginx. The client-side Web3 javascript is looking at localhost:8545 which implies that the users needs to run Parity on their local machine for the page to work.

It is a hassle for users to install parity and setup a config file just to view this web page.

One thought I had was to run a public parity node on port 8545 to circumvent these extra steps. However, I'm concerned about safety.

Is this safe, and what are the recommended best practices for accomplishing this?

3
  • You can also password protect both your demo site and JSON-RPC endpoint easily tokenmarket.net/blog/… Commented Apr 21, 2017 at 9:19
  • Password protecting your endpoint gives you resiliency against denial of service and such attacks that would otherwise hammer public API endpoints. Commented Apr 21, 2017 at 9:52
  • Also Nginx proxy instructions in the link above shows how you can run JSON-RPC in HTTPS port 443. Commented Apr 21, 2017 at 9:52

1 Answer 1

10

Let me walk you through the options.

  • I'm assuming you are only requiring the RPC for your users, so either run parity in --public-node mode which disables account storage and transaction signing on your server or disable the wallet with --no-ui.
  • If you really only want to serve RPC, you can not only disable --no-ui but also the websocket with --no-ws and the dapps server with --no-dapps.
  • To expose your RPC to the public, you have to set your --jsonrpc-interface to <your public ip> and allow --jsonrpc-hosts all.
  • And finally, to your initial question: To only expose safe APIs for your users, you can set --jsonrpc-apis safe.

So it looks something like that:

parity --no-ui --no-ws --no-dapps --jsonrpc-interface 133.3.3.37 --jsonrpc-hosts all --jsonrpc-apis safe

Please let me know if this is what you were looking for.

Disclosure: I work for Parity.

2
  • The --no-ws option gives me an unknown flag error. I also do not see it when I do --help. I get unknown api with the safe option. All other options are working great.
    – nu everest
    Commented Apr 21, 2017 at 14:40
  • Okay sorry, this both is available in 1.7 which is not released yet. If you want this feature now, you can build the latest master from source which enables you these features. The 1.7.0 release will be around end of april (probably).
    – q9f
    Commented Apr 21, 2017 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.