ipfs-docs
ipfs-docs copied to clipboard
Explain how to set up IPFS behind a load balancer.
Should go in a section for production services or something like that, if we don't already have.
From @jacobheun in email:
You can set the addresses that IPFS announces in its configuration. This can be done manually in the config file or via the CLI. By default IPFS will announce the network addresses it can discover, this may include your public address if the AutoNat protocol or upnp are able to detect it.
You can set the config value for "Addresses.Announce" to any valid multiaddrs, and only those will be announced. You can use either dns or IP addresses for this, but you'll need to add multiaddrs for each transport you want to advertise. An example of setting this for TCP and QUIC via the CLI, assuming ports of 4001, would look like:
ipfs config --json Addresses.Announce '["/dns/example.com/tcp/4001", "/dns/example.com/udp/4001/quic"]'
I do have a question about your load balancer setup, are you planning to run multiple nodes at the same address/port? If so, this could cause problems if an inbound connection expects to connect to a peer with a different Peer Id than the one it ends up connecting to.
That last bit also probably needs a whole section - the whole "what is my app vs what is my peer id" problem.
This isn't so much to do with load balancers as it is external vs internal addresses. A common example of this for something like AWS might involve announcing an Elastic IP from your node, or a DNS address that's mapped to your Elastic IP, which would allow you to more easily perform maintenance on the underlying node without having to deal with changing container IPs.
Actually load balancing to multiple nodes gets complex because IPFS needs to know the ID of the node its dialing, as we don't do any blind multiaddr dials. This is probably a completely separate topic that I don't think we have a single recommended path to resolve.
Slapped the expert tag on there because I wouldn't know where to start with this one. @jacobheun do we have anything hidden away that touches on this? Failing that, would you or anyone else on the IPFS team be able to share a few notes about this topic?