0

i have setup my geth private node on my ubuntu server and sofar so good localhost running perfectly. and now i really want to use my domain http://rpc.example.com instead of http://localhost:8545. and i have been read the docs how to use http interface, and a couple tutorial like https://www.nginx.com/resources/wiki/start/topics/recipes/geth/ but got no luck. i guest i miss some configuration in here, and need more info from you guys what i doing wrong.

/etc/nginx/conf.d/geth.conf

server {
  listen 8545; //80 does not work
  listen [::]:8545; //80 does not work
  server_name rpc.domainname.com;

  location / {
    if ($request_method = OPTIONS) {
        return 204;
     }

    auth_basic          off;

    add_header          Access-Control-Allow-Origin  "$http_origin";
    add_header          Access-Control-Allow-Headers "authorization, content-type";
    add_header          Access-Control-Allow-Methods "DELETE, GET, OPTIONS, POST, PUT, UPDATE";

    proxy_hide_header   Access-Control-Allow-Origin;

    proxy_set_header    Host                $host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto   $scheme;
    proxy_set_header    Upgrade             $http_upgrade;
    proxy_set_header    Connection          "upgrade";
    proxy_pass http://172.0.0.1:5469/;
  }
}

geth

geth --datadir node1/ --syncmode 'full' --http --http.addr '0.0.0.0' --http.port 8545 --http.corsdomain "http://rpc.domainname.com" -http.api 'eth,net,web3,txpool,personal' --bootnodes 'enode://[email protected]:8545?discport=30310' --networkid 119 --miner.gasprice '1' -unlock '0x6e...' --password node1/account/password.txt --mine --allow-insecure-unlock --snapshot=false

Thank you for anykind of suggestion.

1 Answer 1

0

Should be use parameter --http.vhosts "rpc.domainname.com"

Reference https://geth.ethereum.org/docs/interface/command-line-options

Your Answer

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

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