Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP client doesn't automatically include the Host header #357

Open
mprakhov17 opened this issue May 16, 2024 · 8 comments
Open

HTTP client doesn't automatically include the Host header #357

mprakhov17 opened this issue May 16, 2024 · 8 comments

Comments

@mprakhov17
Copy link

I'm using test_against_node.rs example
When I set up my URL (as an example http://bitcoin.test.node), DNS name during request converted to 11.11.11.11 and I', getting 400 response due to Host header is not added (Cloudflare 1003 error)

Is it possible to automatically include the Host header or do it manually?

@apoelstra
Copy link
Member

Which version of rust-bitcoincore-rpc are you using?

This header was added to rust-jsonrpc in http://github.com/apoelstra/rust-jsonrpc/pull/85 which appeared in jsonrpc 0.14.1 used by this library.

Or is this a new issue introduced by our switch to minreq (but which has not been released yet)?

@mprakhov17
Copy link
Author

mprakhov17 commented May 16, 2024

@apoelstra
The issue is observed on bitcoincore-rpc = "0.14.0"
Today I clone bitcoincore-rpc repo (version = "0.19.0") - the same problem
Are there any ad-hoc solutions? It is blocking our development now 😢

@apoelstra
Copy link
Member

0.17 or 0.18 will definitely work because they have a fix for this particular issue.

0.19 possibly reintroduced it when we switched the underlying HTTP transport to minreq.

@mprakhov17
Copy link
Author

it seems the problem is that rust-jsonrpc convert domain name to IP address and as a result we got request like:
curl -X POST --user user:pass
http://11.11.11.11
-H 'Content-Type: application/json' -H 'Host: 11.11.11.11'
-d '{"method":"getblockchaininfo","params":[],"id":1,"jsonrpc":"2.0"}'

Which will be blocked by cloudflare with a 1003 error because host contains IP too instead domain name

@apoelstra
Copy link
Member

Is this on 0.19 or pre-0.19? The rust-jsonrpc simple_http backend uses whatever hostname you provide when constructing the client, and will not do any DNS lookups. The minreq backend is not really in our control. Possibly this is a bug for them. Or possibly a bug for cloudflare.

@mprakhov17
Copy link
Author

0.17, 0.18, 0.19
I think it is jsonrpc bug... will create a ticket there

@spartucus
Copy link

@mprakhov17 Any progress on this?

@mubarak23

This comment was marked as spam.

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

No branches or pull requests

4 participants