Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Insert custom HTTP header determined by VS protocol

Dear all,

I have two VS sending the traffic to the same pool server. The idea was to be able to identify from the log server from which VS (HTTP or HTTPS) the traffic was coming from.

So I implemented this irule but it's not working.

Does anyone has an idea of what is wrong with ths irule ?

when CLIENT_ACCEPTED {
   switch [TCP::local_port] {
      "443" {
         set proto "https"
      }
      "80" {
         set proto "http"
      }
   }
}


when HTTP_REQUEST {
HTTP::header insert VS_HTTP_PROTO $PROTO
}

Thank you a lot for your help !!

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

There are potentially two problems:

  1. You've defined a local variable called "proto", but then accessing it as "PROTO". TCL is case sensitive.

  2. I've found that many versions of IIS don't like headers with underscores in them. It will natively replace dashes with underscores, but doesn't seem to like it when the header names arrive with underscores.

Try this:

when CLIENT_ACCEPTED {
    switch [TCP::local_port] {
        "443" {
            set proto "https"
        }
        "80" {
            set proto "http"
        }
    }
}
when HTTP_REQUEST {
    HTTP::header insert VS-HTTP-PROTO $proto
}
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hello Kevin,

It works perfectly.

Thank you very much

0