Forum Discussion

skarpovi_111573's avatar
skarpovi_111573
Icon for Nimbostratus rankNimbostratus
Mar 27, 2008

insert field to HTTP header

can Big IP insert field data into the HTTP header that the IIS server can then read and use to determine whether or not the user in question is coming from our internal environment or from the public networks

9 Replies

  • Hi,

     

     

    Yes it's possible with the HTTP::header insert command: Click here

     

     

    when HTTP_REQUEST {

     

    HTTP::header insert header_1 value_3

     

    log local0. "new header header_1 inserted with a value of [HTTP::header "header_1"]"

     

    }
  • Header_1 represents a header name such as "user" or "host"

     

    value_3 represents the actual value of "user" or "host"

     

    log local0. Tells the iRULE to log the message between quotes to the ltm log file within BIGIP.
  • Exactly

     

     

    I would strongly advise you to check how those commands work by looking at the wiki since you seem not to know much about iRules

     

     

    it will help you a lot
  • OK, i guess i have to reinstate the question and describe my situation.

     

     

    we have site: mycomany.com where IIS doing automaticaly redirect to the page

     

     

    when users go to this site on port 80, we use BigIP iRule & redirect to port 443

     

    Now, after we implemented trusted sign-on for internal users, based on source IP we want to redirect them to different authentication page.

     

    we can't use HTTP::redirect, since IIS doing some redirection automatacaly, in which case we will have mycomany.com/"BigIP-redirect""IIS redirect" as one string in URL

     

    We want to use HTTP header insert string, which vill be recognized by IIS and present different authentication based on the IP source.

     

    I guess: Header_1 represents a header name such as "user" or "host" value_3 represents the actual value of "user" or "host"

     

    not going to do much, since i don't care about "user" and "host" - destination will be the same.

     

    so, what are my options. where in this statement i can insert HTTP::header rule? and how does it going to look like?

     

    how will it come across i.e.( STRING=1, STRING=true, or just the mere existence of STRING, which will signifies different source IP)

     

     

    when HTTP_REQUEST {

     

    if {([TCP::local_port] eq "80") and ([IP::client_addr] eq "10.x.x.x/16")} {

     

    HTTP::redirect "https://[HTTP::host][HTTP::uri]"

     

    } elseif {[TCP::local_port] eq "80" } {

     

    HTTP::redirect "http://[HTTP::host][HTTP::uri]"

     

    } else {

     

    pool Servers-Pool

     

    }

     

    }
  • Hi,

    What we gave you is an example of the syntax -_- not the solution. It was to help you understand the syntax.

    You should have tried some search on this forum to find the answer by yourself...

    When you do a redirect you can insert anything in the header so in your iRule you can insert HTTP header only in your else statement

    If you had read the documentation about the HTTP::header insert you would have understand that header_1 would have been a new header created in the HTTP request which name would have been header 1 and its value would be the following data so in my example it would be value_3.

    So to make it easy to understand:

    
    when HTTP_REQUEST {
      if {([TCP::local_port] eq "80") and ([IP::client_addr] eq "10.x.x.x/16")} {
        HTTP::redirect "https://[HTTP::host][HTTP::uri]"
      } elseif {[TCP::local_port] eq "80" } {
        HTTP::redirect "http://[HTTP::host][HTTP::uri]"
      } else {
        HTTP::header insert STRING HERE_YOU_SPECIFY_THE_VALUE_YOU_WANT_STRING_TO_HAVE
        pool Servers-Pool
      }
    }

  • will it work this way???

     

    if comming from address, inseart string, then look for port and redirect. (server will see string and based on the string presence will provide different page)

     

     

     

    when HTTP_REQUEST {

     

    if {[IP::client_addr] eq "10.0.0.0/16"} {

     

    HTTP::header insert STRING MLint

     

    }

     

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

     

    HTTP::redirect "https://[HTTP::host][HTTP::uri]"

     

    } else {

     

    pool eRoom-Servers-Pool

     

    }

     

    }
  • When you do this the logic will be

    If client ip address equals 10.0.0.0/16 then insert or if the port = 80 then redirect, else go to pool.

    It sounds like you need it to get past the first IF statement, before it checks the port, which is what your example wouldn't do.

    In that case perhaps you might want to do it the following:

    
    when HTTP_REQUEST {
    if { [IP::addr 10.0.0.0/16 eq [IP::client_addr]] } { 
        HTTP::header insert STRING MLint 
        if { [TCP::local_port eq "80" } {
             HTTP::redirect "https://[HTTP::host][HTTP::uri]"
        } else {
        pool eRoom-Servers-Pool
        }
       }
    }

    Hope that helps

    /CB

  • tried to use this iRule, didn't get any errors, but at the same time didn't see any string incerted in Header. it does https redirect. Is there any other way to see that incert in header? i use ieHTTPheaders software to view. is anything else needs to be done on the BigIP side to enable this future.

     

    thanks in advance for your help.

     

     

     

    GET / HTTP/1.0

     

    Accept: */*

     

    Accept-Language: en-us

     

    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; MRA 5.0 (build 02094); .NET CLR 2.0.50727; IEMB3)

     

    Host: BigIP-VIP-IP

     

    Connection: Keep-Alive

     

    X-NovINet: v1.2

     

     

    HTTP/1.0 302 Found

     

    Location: https://BigIP-VIP-IP/

     

    Server: BIG-IP

     

    Connection: Keep-Alive

     

    Content-Length: 0