[Ethereum] How to one secure Web3 JSON-RPC API endpoint

dapp-developmentgo-ethereumprivate-blockchainSecurityweb3js

When using geth as client and web3(javascript api) to interact with it through a web browser, other nodes in the network can access the client given the IP and the port on which the client is running.

How can this be prevented?

How can the access be restricted to the node(computer) running the client and not the others in the same network?

the flow is as follows

Browser(user)—–>Server(running the node)——>GETH

the first link is http and the second link is rpc. the http link makes it possible for other computers to access my node which is to be stopped.

Only the node(computer) running the geth client should access the geth client.

Best Answer

This can be prevented by introducing a middleware, which will talk to your geth node and let your UI talk to the middleware instead of talking to geth node directly.

I faced a similar issue and I solved it by creating a middleware in Node.js

With this, your geth node won't be exposed to the public and that saves us from some security issues.

enter image description here You can check this project for reference - https://github.com/Imaginea/lms