2

I have geth running in remote server and is protected using HTTP Basic Auth.

I tried the below two methods. both don't work:

let web3 = new Web3(
                new Web3.providers.HttpProvider(
                    'http://' + "username" + ':' + "password" + '@'+ "52.43.83.54/iimigdmb" + ':' + "31988"
                )
            )

As per official docs:

web3 = new Web3();
            web3.setProvider(new web3.providers.HttpProvider('http://' + "52.43.83.54/iimigdmb" + ':' + "31988", 5000, "sad", "asd"));

Is there any other way to achieve this:

Narayan Prusty
  • 2,501
  • 3
  • 22
  • 41
  • Your second usage is the correct way to do it. My guess is you have another issue, most likely in the way you have geth configured to receive requests (using the correct `--rpcaddr` and `--rpccorsdomain` options). If you think geth is running properly, make sure by allowing connections without authentication as a test. Opening up your geth node for remote RPC connections isn't very secure though. I'd recommend following the guidelines here: https://ethereum.stackexchange.com/questions/3163/how-can-i-expose-geths-rpc-server-to-external-connections – Adam Kipnis Apr 15 '18 at 16:19
  • I tried disabling Basic Auth and it works. Any idea what is the issue? – Narayan Prusty Apr 15 '18 at 19:18
  • 1
    Then the issue has to be with your auth setup. I don't know your specific setup, but most people who set up `geth` with auth use nginx. There are several helpful posts out there already that provide step-by-step guidelines. Here's one example: https://ethereum.stackexchange.com/questions/30357/restricted-access-authentication-for-a-remote-geth-node – Adam Kipnis Apr 17 '18 at 21:00

0 Answers0