Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

invalid host specified (missed POST data/parameters) #576

Closed
minzak opened this issue Apr 10, 2018 · 7 comments
Closed

invalid host specified (missed POST data/parameters) #576

minzak opened this issue Apr 10, 2018 · 7 comments

Comments

@minzak
Copy link

minzak commented Apr 10, 2018

I have worked geth on debian 8.10 with run string in service:

ExecStart=/usr/local/bin/geth --datadir=/mnt/ethereum/eth --keystore=/mnt/ethereum/eth/keystore 
--verbosity 3 --syncmode=fast --cache=2048 --port 30303 --rpcapi=personal,eth,web3 --rpc
--rpcaddr=127.0.0.1 --rpcport=8545 --rpccorsdomain=*

Also i have nginx, works as proxy for geth with this vhost config:

server {
        listen 8500 default_server;
#       listen 8500;
        server_name ethereum.domain;
        error_log   /var/log/nginx/ethereum.error.log  warn;
        access_log  /var/log/nginx/ethereum.access.log ;

        proxy_http_version         1.1;
        proxy_connect_timeout      360;
        proxy_read_timeout         360;
        proxy_pass_header          Date;
        proxy_pass_header          Server;
        proxy_pass_header          Authorization;
        proxy_set_header           Accept-Encoding "";
        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_pass_request_headers on;
        proxy_buffering            off;
        proxy_set_header           Connection "Keep-Alive";
        proxy_redirect             off;

        location / {
#              allow   IP1;
#              allow   IP2;
#              deny    all;
              proxy_pass http://127.0.0.1:8545;
        }
}

And i have test CURLs that must work, but works only last 2 !

curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":2}' http://ethereum.domain:8500
curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":2}' http://207.154.212.228:8500
curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":2}' http://127.0.0.1:8500

DNS is OK ping inside host and outside host on dns name is work.
Even works with other Ethereum parity, bitcoin, litecoin, etc.
But not with geth on DNS name.
I can't use proxy nginx for geth, i think need some spesified parameters in nginx like
proxy_set_header Host $host;
But what exactly ?

Increase verbosity not helps - nothing about RPC requests in log. (
Also i can't use HTTPS (

It is very strange, because same config on other host with other blockchain is work.

@karalabe
Copy link
Member

What happens if you specify --rpcvhosts=* or --rpcvhosts=ethereum.domain?

@minzak
Copy link
Author

minzak commented Apr 11, 2018

hm, works only with *. but no wirk witn domain client name or server name.

@holiman
Copy link

holiman commented Apr 11, 2018

What does 'works' or 'not works' mean in this context? Geth provides error messages in response data, could you provide error message for --rpcvhosts=ethereum.domain and also the geth startup log messages where it says what vhosts it is running with?

@holiman
Copy link

holiman commented Apr 11, 2018

What would be really good would be to have a dump of what is passed to geth, exactly. Perhaps you could do this:
ncat -l 127.0.0.1 -p 8545 instead of running geth, and see exactly what the incoming request looks like when you do curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":2}' http://ethereum.domain:8500

@minzak
Copy link
Author

minzak commented Apr 11, 2018

Thanks for ncat -l 127.0.0.1 -p 8545.

When i Use in vhosts - DNS name of remore clients:

Apr 11 09:31:29 ethereum geth[5808]: INFO [04-11|09:31:29] IPC endpoint opened                      url=/mnt/ethereum/eth/geth.ipc
Apr 11 09:31:29 ethereum geth[5808]: INFO [04-11|09:31:29] HTTP endpoint opened                     url=http://127.0.0.1:8545      cors=* vhosts=gw.mydomain

I got this answer:

root@gateway:~# curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' https://ethereum.node.mydomain:8500
invalid host specified

And when use on RPC server, RPC domain name all is work.

Apr 11 09:33:17 ethereum geth[5897]: INFO [04-11|09:33:17] UDP listener up                          self=enode://ae8defabb0e515f6ac830e7caa0f6181dfc620a1a9dab96f0c54c3ab02271881f0897d4e193f1e46bda04b691f598bd2e4561297d5f8c8ed10ea2efdba89cf6f@0.0.0.0:30303
Apr 11 09:33:17 ethereum geth[5897]: INFO [04-11|09:33:17] HTTP endpoint opened                     url=http://127.0.0.1:8545 cors=* vhosts=ethereum.node.mydomain
Apr 11 09:33:17 ethereum geth[5897]: INFO [04-11|09:33:17] RLPx listener up                         self=enode://ae8defabb0e515f6ac830e7caa0f6181dfc620a1a9dab96f0c54c3ab02271881f0897d4e193f1e46bda04b691f598bd2e4561297d5f8c8ed10ea2efdba89cf6f@0.0.0.0:30303
Apr 11 09:33:17 ethereum geth[5897]: INFO [04-11|09:33:17] IPC endpoint opened                      url=/mnt/ethereum/eth/geth.ipc

I got good result:

root@gateway:~# curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' https://ethereum.node.mydomain:8500
{"jsonrpc":"2.0","id":1,"result":"Geth/v1.8.3-stable/linux-amd64/go1.10"}

Now all is work, thanks!

@minzak minzak closed this as completed Apr 11, 2018
@afterether
Copy link

Felt into this problem too. If you're redirecting from nginx, add --rpcvhosts '*' on the commandline

@TennisBowling
Copy link

now --http.vhosts

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants