cancel
Showing results for 
Search instead for 
Did you mean: 

X-Forward-Proto for HTTP version identifier(1.0/2)

Pavan_Dhanushka
Altostratus
Altostratus

I recently created & applied a HTTP/2 profile to a virtual server and its working successfully. Stakeholder wants to distinguish the connections b/w HTTP1 and HTTP2. And I'm planning to create a iRule for that similar like mentioned below but I was unable to find a iRule/Policy to fix this. Please let me know if you feasible solution for this.

 

when HTTP_REQUEST {

  if { [TCP::local_port] == "80" } {

   HTTP::header insert Protocol http

  } elseif { [TCP::local_port] == "443" } {

   HTTP::header insert Protocol https

 

Currently my LTM working on 14.1.x version.

7 REPLIES 7

crodriguez
F5 Employee
F5 Employee

You might be able to use the HTTP2::active command in the iRule to determine if the client connected using HTTP/2 or not. For example:

when HTTP_REQUEST { if { [HTTP2::active] } { log local0. "Request from HTTP/2 client" } else { log local0. "Request from HTTP client" } }

You can find more information on HTTP2::active here. You can also check out the other HTTP2 commands here.

@crodriguez Thanks for info. Let me try in my test VIP.

Pavan_Dhanushka
Altostratus
Altostratus

 I guess this only logs in LTM local. Is there any way we can insert in header like X-Forward-Proto ? Where backend owner can distinguish the connections b/w HTTP/1 or HTTP/2 ??

crodriguez
F5 Employee
F5 Employee

Sure, just change the log commands to anything of your choice, such as inserting an HTTP header. The iRule I provided was simply an example of how you might use the HTTP2::active command to distinguish between HTTP and HTTP/2.

Pavan_Dhanushka
Altostratus
Altostratus

 I came up with below iRule. What do you think on this ?

 

ltm rule rule-http-protocol-version {

  when HTTP_REQUEST {

 if { [HTTP2::active] } {

  HTTP::header insert Version HTTP/2

 } else {

  HTTP::header insert Version HTTP

 }

}

Pavan_Dhanushka
Altostratus
Altostratus

 Thank you very much for your help on this. Its worked as expected.

Good to know!