-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Connection issue via Websocket to a node behind Nginx proxy #4181
Comments
Correct. The current websocket implementation does not support custom paths or HTTP headers. Can you load balance / multiplex based on different URLs, i.e. subdomains in your use-case? |
That could work. But not very scalable for us if we want to run some IPFS node in production. Normally in a mid-size to large-size company, the LB is maintained by a dedicated team and LB relies on the virtual host to dispatch request to different services. What we did is to have nginx to route traffic from example.com to a gateway service. The gateway service then dispatches the request further to the corresponding IPFS node based on the path "/p2p/XXXXX". When we start a new IPFS node, the node would register its peer id to the gateway service. This allows us to scale up/down the IPFS cluster automatically. Scaling would be more difficult with subdomains, because we would need to programmatically update DNS. This approach works with js-libp2p since the connection was established with "wss://example.com/p2p/XXXXX". |
yeah, I can try |
Seems we just need to pass the original "host_name" and "resource" param to the sokettio Client here:
Passing the correct "resource" param should fix the other issue #2708. However websocket transport is wrapped within the dns transport which removes the information about the hostname. I think we would need to refactor the code to stop treating DnsConfig as a Transport trait and use it as a helper function. Websocket crate can call dns library to resolve the IP address and pass the correct hostname and path to sokettio Client later. |
I don't think this will be an option, DNS resolution should be composable with any transport. |
Any suggestion how we can solve this? ( I am both very new to rust and rust-libp2p codebase :-) ). Other implementations like golang has this function to parse the original multiaddr to a URL that can be passed into net.Dial |
Unfortunately, the interface is constrained to just passing a multiaddr. @mxinden Do you know if we have the same problem in other transports? It seems worthwhile solving that each inner transport of DNS would want to know that we originally received a domain name as an argument. Can we (ab)-use the |
It should be the other way around. I.e. websocket should wrap DNSConfig. See below as an example @niczy: |
Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days. |
This issue was closed because it is missing author input. |
Description
When I try to connect my libp2p node to another libp2p node behind nginx proxy via websocket, I got following error:
Custom { kind: Other, error: Transport(Handshake("server rejected handshake; status code = 404"))
Seems the issue is that nginx depends on information of HTTP headers like host, path do decide which backed to route the traffic to. Current websocket transport impl doesn't send those information
See https://github.com/libp2p/rust-libp2p/pull/4180/files for the DNS/WS transport configuration.
Motivation
Allow us to run multiple libp2p node behind a nginx proxy over Websocket.
Current Implementation
Currently we won't be able to connect to libp2p node behind a nginx proxy with virtual host.
Are you planning to do it yourself in a pull request?
Maybe. Tried this, need to research more what we should send after a socket connection is established.
https://github.com/libp2p/rust-libp2p/pull/4180/files
The text was updated successfully, but these errors were encountered: