@@ -6,9 +6,14 @@ use rama::{
66 error:: { BoxError , ErrorContext as _} ,
77 graceful:: { self , ShutdownGuard } ,
88 http:: { server:: HttpServer , tls:: CertIssuerHttpClient } ,
9+ layer:: AddExtensionLayer ,
910 net:: {
11+ Protocol ,
1012 socket:: Interface ,
11- tls:: server:: { CacheKind , ServerAuth , ServerCertIssuerData , ServerConfig } ,
13+ tls:: {
14+ ApplicationProtocol ,
15+ server:: { CacheKind , ServerAuth , ServerCertIssuerData , ServerConfig } ,
16+ } ,
1217 } ,
1318 proxy:: haproxy:: server:: HaProxyLayer ,
1419 rt:: Executor ,
@@ -59,7 +64,14 @@ async fn spawn_service_http(
5964 interface : Interface ,
6065 https_enabled : bool ,
6166) -> Result < ( ) , BoxError > {
62- let svc = self :: service:: load_https_service ( https_enabled) . await ?;
67+ let svc = AddExtensionLayer :: new ( Protocol :: HTTP ) . into_layer (
68+ self :: service:: load_http_service ( if https_enabled {
69+ self :: service:: ServiceMode :: Http
70+ } else {
71+ self :: service:: ServiceMode :: HttpOnly
72+ } )
73+ . await ?,
74+ ) ;
6375
6476 let http_server = HttpServer :: auto ( Executor :: graceful ( guard. clone ( ) ) ) . service ( svc) ;
6577 let tcp_server = HaProxyLayer :: new ( ) . with_peek ( true ) . into_layer ( http_server) ;
@@ -81,15 +93,22 @@ async fn spawn_service_https(guard: ShutdownGuard, interface: Interface) -> Resu
8193
8294 issuer. prefetch_certs_in_background ( & executor) ;
8395
84- let tls_server_config = ServerConfig :: new ( ServerAuth :: CertIssuer ( ServerCertIssuerData {
85- kind : issuer. into ( ) ,
86- cache_kind : CacheKind :: default ( ) ,
87- } ) ) ;
96+ let tls_server_config = ServerConfig {
97+ application_layer_protocol_negotiation : Some ( vec ! [
98+ ApplicationProtocol :: HTTP_2 ,
99+ ApplicationProtocol :: HTTP_11 ,
100+ ] ) ,
101+ ..ServerConfig :: new ( ServerAuth :: CertIssuer ( ServerCertIssuerData {
102+ kind : issuer. into ( ) ,
103+ cache_kind : CacheKind :: default ( ) ,
104+ } ) )
105+ } ;
88106
89107 let acceptor_data =
90108 TlsAcceptorData :: try_from ( tls_server_config) . context ( "create acceptor data" ) ?;
91109
92- let svc = self :: service:: load_https_service ( true ) . await ?;
110+ let svc = AddExtensionLayer :: new ( Protocol :: HTTPS )
111+ . into_layer ( self :: service:: load_http_service ( self :: service:: ServiceMode :: Https ) . await ?) ;
93112
94113 let http_server = HttpServer :: auto ( executor) . service ( svc) ;
95114 let tcp_server = (
0 commit comments