Forum Discussion
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.
- crodriguezRet. 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.
- Pavan_DhanushkaAltostratus
@crodriguez Thanks for info. Let me try in my test VIP.
- Pavan_DhanushkaAltostratus
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 ??
- crodriguezRet. 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_DhanushkaAltostratus
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_DhanushkaAltostratus
Thank you very much for your help on this. Its worked as expected.
- crodriguezRet. EmployeeGood to know!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com