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

Respect RFC 7239 (Forwarded header), X-Forwarded-For, and/or X-Real-IP #8193

Open
TheDiscordian opened this issue Jun 16, 2021 · 5 comments
Open
Labels
effort/days Estimated to take multiple days, but less than a week exp/intermediate Prior experience is likely helpful kind/enhancement A net-new feature or improvement to an existing feature P3 Low: Not priority right now

Comments

@TheDiscordian
Copy link
Member

Currently when using Nginx as a reverse proxy, go-ipfs seems list all peers connecting through the reverse proxy as 127.0.0.1 (ipfs swarm peers). I couldn't find a way to discover their actual IP address, which can be incredibly useful for tools like fail2ban. I'm hoping for go-ipfs to support RFC 7239 and/or the X-Forwarded-For, and/or X-Real-IP headers. These are documented quite well here.

My apologies if I missed the feature!

@TheDiscordian TheDiscordian added the kind/enhancement A net-new feature or improvement to an existing feature label Jun 16, 2021
@Stebalien
Copy link
Member

Given that you're saying ipfs swarm peers, I assume you're referring to the websocket transport. If so, we can't just blindly trust these headers.

However, I guess we could add a config option to trust certain proxies. We'd need to:

  1. Add a feature to the websocket libp2p transport to perform these translations.
  2. Add a "trusted proxies" config option to the go-ipfs config and pipe this information through to libp2p.

@Stebalien Stebalien added effort/days Estimated to take multiple days, but less than a week exp/intermediate Prior experience is likely helpful P3 Low: Not priority right now labels Jun 22, 2021
@fusetim
Copy link

fusetim commented Jun 23, 2021

linked to: libp2p/go-libp2p#1437

@fusetim
Copy link

fusetim commented Jun 25, 2021

Would it be possible to incorporate support for Proxy Protocol as well? I need for IPv6 compatibility, a relay before the connection reaches go-ipfs. At the moment, the IPs displayed for the connections going through this relay are therefore partly wrong, their IP being replaced by the TCP relay.

@Stebalien
Copy link
Member

See libp2p/go-libp2p#1065. As you can see, I have some objections to the entire concept of the "proxy protocol", but I'm not strictly opposed to a clean implementation.

However, the core team is unlikely to work either of these features in the near future.

@TheDiscordian
Copy link
Member Author

However, the core team is unlikely to work either of these features in the near future.

My use-case, and reason for opening this issue is I'm trying to blacklist a peer that floods my connections (I don't know why it's doing it, but it opens 5, closes 5, repeat). Is there any way to do that in go-ipfs currently? As I can't get the IP because go-ipfs doesn't support SSL or the headers I'd use to get the IP from a reverse proxy. Just having the IP allows me to chuck it into iptables and handle the rest myself, but currently I don't see any path to reliably retrieve the correct IP for a peer connecting over WSS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/days Estimated to take multiple days, but less than a week exp/intermediate Prior experience is likely helpful kind/enhancement A net-new feature or improvement to an existing feature P3 Low: Not priority right now
Projects
None yet
Development

No branches or pull requests

3 participants