23-Sep-2020 00:41
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.
24-Sep-2020 15:12
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.
27-Sep-2020 06:40
@crodriguez Thanks for info. Let me try in my test VIP.
28-Sep-2020
21:20
- last edited on
24-Mar-2022
01:16
by
li-migration
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 ??
29-Sep-2020 07:20
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.
29-Sep-2020
10:12
- last edited on
24-Mar-2022
01:16
by
li-migration
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
}
}
29-Sep-2020
19:30
- last edited on
24-Mar-2022
01:16
by
li-migration
Thank you very much for your help on this. Its worked as expected.
29-Sep-2020 19:37