https://bz.apache.org/bugzilla/show_bug.cgi?id=65881

            Bug ID: 65881
           Summary: HTTP2 module uses wrong port after upgrade in proxy
                    scenario
           Product: Apache httpd-2
           Version: 2.4.52
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_http2
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 38188
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38188&action=edit
HTTPD logs from proxy

I'm setting up a following configuration (note, this is not intended for
browser usage):

Client(curl) --h2c--> Proxy(httpd) --h2--> Server(httpd)

Proxy is set up as a gateway with dynamic detection of the host name for the
proxy target as follows:


<VirtualHost *:8181>

    Protocols h2c

    RewriteEngine On
    RewriteRule "^/(.*)$" "h2://%{HTTP_HOST}/$1" [NC,P]

    ProxyPassMatch / "h2://$1/"

</VirtualHost>

After executing this curl command I get 503 reply from the proxy:

curl -v --http2  --proxy localhost:8181  http://backend-http:443

>From the logs I can see that first request is processed correctly, e.g. Host
header is set to `backend:443`, as seen here:

[Mon Feb 14 10:58:43.891364 2022] [core:trace5] [pid 2413:tid 139733598463744]
protocol.c(711): [client 172.18.0.1:59934] Request received from client: GET
http://backend-http:443/ HTTP/1.1
[Mon Feb 14 10:58:43.891475 2022] [http:trace4] [pid 2413:tid 139733598463744]
http_request.c(438): [client 172.18.0.1:59934]   Host: backend-http:443

then, upgrade to HTTP/2 is happening, 

[Mon Feb 14 10:58:43.892103 2022] [http2:trace1] [pid 2413:tid 139733598463744]
h2_switch.c(150): [client 172.18.0.1:59934] switching protocol to 'h2c'


client confirms it, 

[Mon Feb 14 10:58:43.892333 2022] [http2:debug] [pid 2413:tid 139733598463744]
h2_session.c(339): [client 172.18.0.1:59934] AH03066: h2_session(66,INIT,0):
recv FRAME[SETTINGS[length=18, stream=0]], frames=0/0 (r/s)
[Mon Feb 14 10:58:43.892343 2022] [http2:trace2] [pid 2413:tid 139733598463744]
h2_session.c(420): [client 172.18.0.1:59934] h2_session(66,INIT,0): SETTINGS,
len=18

and then httpd tries to establish a connection to the target backend server,
but, the port number is switched from the original 443 to 8181 (which is of the
virtual host):

[Mon Feb 14 10:58:43.892407 2022] [http2:debug] [pid 2413:tid 139733598463744]
h2_stream.c(620): [client 172.18.0.1:59934] AH03058: h2_stream(66-1,IDLE):
set_request_rec GET host=http://backend-http:8181/

And this of course fails, as the target server is not listening on port 8181.

Expected behavior for this case would be that httpd uses the original port
number from the request.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to