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

HTTP/2 - Enable H2 protocol #490

Merged
merged 7 commits into from
Jan 15, 2025
Merged

HTTP/2 - Enable H2 protocol #490

merged 7 commits into from
Jan 15, 2025

Conversation

NiccoMlt
Copy link
Contributor

@NiccoMlt NiccoMlt commented Aug 30, 2024

Closes #410 and, along with #409, closes #181
Closes #506

@NiccoMlt NiccoMlt linked an issue Aug 30, 2024 that may be closed by this pull request
@NiccoMlt NiccoMlt force-pushed the 410-http2-enable-http2-h2 branch from def579f to 12cdd0c Compare September 24, 2024 06:56
@NiccoMlt NiccoMlt force-pushed the 410-http2-enable-http2-h2 branch from 9fa84aa to c4903ab Compare October 3, 2024 13:18
@NiccoMlt NiccoMlt force-pushed the 410-http2-enable-http2-h2 branch from 16c6b5c to b9d4c7b Compare October 20, 2024 15:36
@NiccoMlt NiccoMlt changed the title 410 http2 enable http2 h2 HTTP/2 - Enable H2 protocol Oct 20, 2024
@NiccoMlt NiccoMlt self-assigned this Oct 20, 2024
@hamadodene
Copy link
Contributor

@NiccoMlt Take a look on this issue #506
I also get this error:

Oct 28, 2024 9:20:55 AM org.carapaceproxy.core.ListeningChannel map
SEVERE: Error booting certificate for SNI hostname cara17test.xxx.it, on listener NetworkListenerConfiguration[host=0.0.0.0, port=4089, ssl=true, sslCiphers=, defaultCertificate=*, sslProtocols=[TLSv1.3], soBacklog=128, keepAlive=true, keepAliveIdle=300, keepAliveInterval=60, keepAliveCount=8, maxKeepAliveRequests=10, forwardedStrategy=IF_TRUSTED, trustedIps=[127.0.0.1], protocols=[H2], group=DefaultChannelGroup(name: group-0x2, size: 0)]

The certificato of domain cara17test.xxx.it is available. I don't have the full stack. I will try to debug it later

@NiccoMlt NiccoMlt force-pushed the 410-http2-enable-http2-h2 branch from b9d4c7b to 9f8ad17 Compare October 28, 2024 16:32
@hamadodene
Copy link
Contributor

@NiccoMlt Reactor Netty 1.1.24 has been released with the fix for the issue we requested: https://github.com/reactor/reactor-netty/releases/tag/v1.1.24
After integrating the fix, could you please check my issue here as well: #506
Perhaps now we can move forward and finalize this PR.

@NiccoMlt
Copy link
Contributor Author

Sure

@NiccoMlt NiccoMlt force-pushed the 410-http2-enable-http2-h2 branch 5 times, most recently from db280cb to 2f96899 Compare December 10, 2024 16:25
@NiccoMlt NiccoMlt marked this pull request as ready for review December 10, 2024 17:08
@NiccoMlt NiccoMlt force-pushed the 410-http2-enable-http2-h2 branch from 2f96899 to 4c1bbf0 Compare December 23, 2024 08:51
@NiccoMlt NiccoMlt force-pushed the 410-http2-enable-http2-h2 branch from b52322b to e8d28b2 Compare January 14, 2025 08:22
@NiccoMlt NiccoMlt force-pushed the 410-http2-enable-http2-h2 branch from 12a23b7 to 215f5d1 Compare January 14, 2025 16:42
Copy link
Contributor Author

@NiccoMlt NiccoMlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of comments to help review @hamadodene @dmercuriali

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The modifications here come from the HostPort introduction and the NetworkListenerConfiguration transformation from a mutable class to a record.

This is a small building block in the larger plan to migrate to an immutable configuration, because right now it is a pain to track modifications for refreshes.

This was easy and was already done in the later months, so I kept it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listeners was pretty much rewritten from the ground up a couple of times in the later months, but I tried to strip most modifications and keep it simple.

ListeningChannel nested class made it hard to track the flow of the setup of the channel and was externalized. More aggressive refactors were tried but dropped. We still need to find a way to wrap the "concept of channel" inside of it, while keeping the common setup into Listeners.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behaviour wasn't changed much here: the SSL context setup was moved from reactor.netty.http.server.HttpServer#doOnChannelInit to reactor.netty.http.server.HttpServer#secure(java.util.function.Consumer<? super reactor.netty.tcp.SslProvider.SslContextSpec>).

This poses one major change: SslContexts are loaded once, and then the listener needs to be restarted to pick up changes into the certificate. Hooks are already in place to take care of that, we only added a check on changes on the certs in addition to listener confs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is not actually new but moved out of Listeners to track clearly the dependencies.
This class handles SSL contexts build, taking care of OCSP stapling (which is now done through a handlerConfigurator.

This class keeps some problems, that were not evident when it was a nested, non-static, class.
For example, different listeners will load pretty much the same certificates but with their own SSL ciphers and protocols. This might lead to tricky behaviors.
This was mitigated by not actually sharing the certs, but leads to duplication, and I think that these settings should simply be moved from listerners to certs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty much a glorified lambda that actually does the stapling.
The original beahviour (which I note that comes from the netty example and adjusted for ReactorNetty) was not changed in this PR, I think.

Comment on lines +120 to 122
public static Set<HttpProtocol> getDefaultHttpProtocols(final boolean ssl) {
return Set.of(HTTP11, ssl ? H2 : H2C);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we enable HTTP/2 by default with SSL, or HTTP/2 with cleartext if without

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was rewritten to debug a problem in the past, then merged to a refactor that was introduced with one of the previous PR.
Refactors were done and were kept.

@NiccoMlt NiccoMlt requested review from hamadodene and dmercuriali and removed request for hamadodene January 15, 2025 07:52
@NiccoMlt NiccoMlt force-pushed the 410-http2-enable-http2-h2 branch from dc4ab2c to f672658 Compare January 15, 2025 11:23
@NiccoMlt NiccoMlt force-pushed the 410-http2-enable-http2-h2 branch from f672658 to 1341fd3 Compare January 15, 2025 11:23
@dmercuriali dmercuriali merged commit e38d490 into master Jan 15, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants