n0-computer / iroh

A toolkit for building distributed applications
https://iroh.computer
Apache License 2.0
2.28k stars 147 forks source link

Feature request: support reverse proxy on direct address #2552

Open eldereal opened 1 month ago

eldereal commented 1 month ago

I searched many issues, but not found a solution.

Currently I can set bind port in builder. And it will auto bind to all interfaces. But it will be better if i can manually set one/some interfaces to bind. For example, I will run this service on a machine connected to 2 networks, one is public and one is private. I don't want to expose the port to public network. (This is original post. This feature request is moved to #2565 due to discussion.

And another useful feature is to set my local address. It's useful when I want to run it inside a docker container and expose the port. In this case peers can only connected with host IP addresses, but inside docker I can only got docker internal addresses. I tried use node.add_node_addr(NodeAddr::new(node_id).with_direct_addresses(addrs)) to add the host address. But it failed with message saying I cannot add an address for myself. It will be great to allow add/modify node addresses.

flub commented 1 month ago

@eldereal would you mind splitting this issue in two? one for the bind and one for better support for running inside docker? thanks

dignifiedquire commented 1 month ago

We are publishing Dockerfiles now and have support for exposing docker, you can see it here: https://github.com/n0-computer/iroh/blob/main/docker/Dockerfile this currently works well in all cases I have seen, can you explain where this fails?

eldereal commented 1 month ago

@eldereal would you mind splitting this issue in two? one for the bind and one for better support for running inside docker? thanks

Sure. I will separate [[set bind address]] feature to a new issue (see #2565) and keep this track for [[support reverse proxy]]

eldereal commented 1 month ago

We are publishing Dockerfiles now and have support for exposing docker, you can see it here: https://github.com/n0-computer/iroh/blob/main/docker/Dockerfile this currently works well in all cases I have seen, can you explain where this fails?

@dignifiedquire Thank you for reply. I will explain this. Firstly in my target environment there is no internet access. So setup a centralized relay node is not available. In this environment I want to deploy iroh on multiple machines with docker container. And I want to use LocalSwarmDiscovery to discover nodes in a local network.

I can expose service ports from docker container. But they cannot discover each other. LocalSwarmDiscovery is keep announce node address with DNS. But it comes with docker internal IP addresses. This IP is not accessible outside the container. So I think it needs some way to specify a public accessible address. And the LocalSwarmDiscovery should announce this address to make other ones discover it.