@@ -981,7 +981,7 @@ async fn proxy_via_dfdaemon(
981981
982982/// proxy_via_http proxies the HTTP request directly to the remote server.
983983#[ instrument( skip_all) ]
984- async fn proxy_via_http ( request : Request < hyper:: body:: Incoming > ) -> ClientResult < Response > {
984+ async fn proxy_via_http ( mut request : Request < hyper:: body:: Incoming > ) -> ClientResult < Response > {
985985 let Some ( host) = request. uri ( ) . host ( ) else {
986986 error ! ( "CONNECT host is not socket addr: {:?}" , request. uri( ) ) ;
987987 return Ok ( make_error_response (
@@ -1006,14 +1006,26 @@ async fn proxy_via_http(request: Request<hyper::body::Incoming>) -> ClientResult
10061006 }
10071007 } ) ;
10081008
1009+ // Override Host header with full authority (including port) to handle
1010+ // containerd's behavior with non-443 HTTPS ports, which otherwise
1011+ // causes request failures.
1012+ let authority = request
1013+ . uri ( )
1014+ . authority ( )
1015+ . ok_or_else ( || ClientError :: Unknown ( "request uri authority is not set" . to_string ( ) ) ) ?
1016+ . as_str ( )
1017+ . parse ( )
1018+ . or_err ( ErrorType :: ParseError ) ?;
1019+ request. headers_mut ( ) . insert ( hyper:: header:: HOST , authority) ;
1020+
10091021 let response = client. send_request ( request) . await ?;
10101022 Ok ( response. map ( |b| b. map_err ( ClientError :: from) . boxed ( ) ) )
10111023}
10121024
10131025/// proxy_via_https proxies the HTTPS request directly to the remote server.
10141026#[ instrument( skip_all) ]
10151027async fn proxy_via_https (
1016- request : Request < hyper:: body:: Incoming > ,
1028+ mut request : Request < hyper:: body:: Incoming > ,
10171029 registry_cert : Arc < Option < Vec < CertificateDer < ' static > > > > ,
10181030) -> ClientResult < Response > {
10191031 let client_config_builder = match registry_cert. as_ref ( ) {
@@ -1038,8 +1050,20 @@ async fn proxy_via_https(
10381050 . https_or_http ( )
10391051 . enable_http1 ( )
10401052 . build ( ) ;
1041-
10421053 let client = Client :: builder ( TokioExecutor :: new ( ) ) . build ( https) ;
1054+
1055+ // Override Host header with full authority (including port) to handle
1056+ // containerd's behavior with non-443 HTTPS ports, which otherwise
1057+ // causes request failures.
1058+ let authority = request
1059+ . uri ( )
1060+ . authority ( )
1061+ . ok_or_else ( || ClientError :: Unknown ( "request uri authority is not set" . to_string ( ) ) ) ?
1062+ . as_str ( )
1063+ . parse ( )
1064+ . or_err ( ErrorType :: ParseError ) ?;
1065+ request. headers_mut ( ) . insert ( hyper:: header:: HOST , authority) ;
1066+
10431067 let response = client. request ( request) . await . inspect_err ( |err| {
10441068 error ! ( "request failed: {:?}" , err) ;
10451069 } ) ?;
0 commit comments