actix-web icon indicating copy to clipboard operation
actix-web copied to clipboard

Add support for Proxy Protocol v1 & v2 for HTTP/1.x

Open veeshi opened this issue 1 year ago • 7 comments

PR Type

Feature

PR Checklist

  • [x] Tests for the changes have been added / updated.
  • [x] Documentation comments have been added / updated.
  • [ ] A changelog entry has been made for the appropriate packages.
  • [x] Format code with the latest stable rustfmt.
  • [ ] (Team) Label with affected crates and semver status.

Overview

This PR adds support for Proxy Protocol v1 & v2 for HTTP/1.x

Closes #1751

veeshi avatar Feb 03 '24 21:02 veeshi

I really appreciate your work on this feature. As it happens I'm actually working on this at the lower level with the ambition to introduce a generic stream wrapper as part of the HttpServer builder that allows both more flexible TLS config as well as PROXY protocol.

See https://github.com/actix/actix-net/pull/469

With more eyes on this feature, I'm definitely motivated to pick this up again.

robjtede avatar Feb 03 '24 21:02 robjtede

Ah! I searched across the actix-web repo but didn't think to look in actix-net! At the moment I added in support for HTTP/1.x only as that is what we use for our platform but HTTP/2 still needs some work. I'm happy to contribute to implementing this properly in actix-net as it is something we rely on. What is remaining from that PR to be implemented?

veeshi avatar Feb 03 '24 22:02 veeshi

I can probably clean it up as-is. I remember leaving it unfinished in terms of the PP2 extensions but it's likely that an MVP will be useful for most people.

robjtede avatar Feb 03 '24 23:02 robjtede

The main TLV is the authority one that people seem to use and that is implemented. If I get some time I can try completing the rest.

veeshi avatar Feb 03 '24 23:02 veeshi

The main TLV is the authority

This is great info. I actually don't have significant practical experience using PROXY yet.

robjtede avatar Feb 03 '24 23:02 robjtede

It isn't widely used but should be. At the moment in Rust there isn't a lot of support for it in web frameworks. The only web server I've found support is an axum-server fork https://github.com/valorem-labs-inc/hyper-server/ . It is especially useful in those platforms which allow HTTP Host spoofing etc.

veeshi avatar Feb 04 '24 00:02 veeshi

Yea for sure. I have a medium term need for it at work for exactly that reason.

robjtede avatar Feb 04 '24 00:02 robjtede