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

http2 cleartext support #1170

Closed
wants to merge 2 commits into from
Closed

Conversation

kristophM
Copy link

This PR is in reference to this thread in the tus-js-client repository issues. @Acconut invited us to create a lightweight PR to solve this issue, on the tusd side.

PROBLEM

In GCP Cloud Run, HTTP/2 traffic is accepted but TLS is terminated at the load balancer and traffic is forwarded to the tusd container as cleartext (non-encrypted) http. This is problematic because tusd expects TLS for HTTP/2 traffic.

SOLUTION

Golang's net/http2 library allows for a drop in support of HTTP/2 in cleartext (h2c), with simultaneous capability for HTTP/1.1 cleartext. Meaning, if traffic is identified to be HTTP/1.1, the h2c handler will bypass HTTP/2 and serve based on HTTP/1.1.

This PR uses the newHandler() method to wrap the existing mux handler, such that no additional configuration is needed to handle either HTTP version. HTTP/2 encrypted traffic can also be handled as usual by making calls directly to tusd via https. If behind a load balancer such as Cloud Run, all that would be required in terms of configuration is the -behind-proxy flag.

TESTING
We built an image based on this PR and tested it for file uploads on Cloud Run with tus-js-client and it performed successfully.

@Acconut
Copy link
Member

Acconut commented Aug 21, 2024

Thank you for this PR! The use of h2c on its own looks good, but I would prefer if it sits behind a feature flag and is not enabled by default. The caveat about memory consumption from tus/tus-js-client#700 (comment) is concerning enough to let user opt into this behavior. I can imagine that in the future we have multiple flags to enable different HTTP versions, e.g. --enable-h2c and --enable-h3.

@kristophM
Copy link
Author

Thanks @Acconut good point - pushed a new commit. Let me know if it addresses your concern.

@Acconut
Copy link
Member

Acconut commented Aug 23, 2024

Thanks for the updates! I will try them out on my own in about two weeks

Acconut pushed a commit that referenced this pull request Sep 10, 2024
Squashed commit of the following:

commit 13957b3acc4cdfc0b3ec93d6eddf58bbaf00f4ad
Merge: 624a36b d613243
Author: Marius Kleidl <[email protected]>
Date:   Tue Sep 10 09:04:14 2024 +0200

    Merge branch 'main' into pr/1170

commit 624a36b1c8d55a8b823b4ea6558315208d2de2af
Author: Marius Kleidl <[email protected]>
Date:   Tue Sep 10 09:00:14 2024 +0200

    Improve documentation

commit 91b84a9
Author: Kristoph Matthews <[email protected]>
Date:   Wed Aug 21 12:00:31 2024 -0400

    explicit h2c flag

commit ad5774d
Author: Kristoph Matthews <[email protected]>
Date:   Tue Aug 20 15:52:02 2024 -0400

    http2 cleartext support
@Acconut
Copy link
Member

Acconut commented Sep 10, 2024

Merged in dfaf9f7, thank you very much for this!

@Acconut Acconut closed this Sep 10, 2024
@Acconut
Copy link
Member

Acconut commented Sep 10, 2024

This is released in https://github.com/tus/tusd/releases/tag/v2.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants