Forum Discussion

Pavan_Dhanushka's avatar
Pavan_Dhanushka
Icon for Altostratus rankAltostratus
Sep 23, 2020

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

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

  • 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.

  •  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 ??

  • 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.

  •  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

     }

    }