Forum Discussion

JoergK's avatar
JoergK
Icon for Nimbostratus rankNimbostratus
Mar 12, 2019

How to make a branch decsision based on HTTP header in an Access Policy?

Hello everyone,

 

I have to make a branch decision in an Access Policy based on the value in the HTTP header field 'host'. For example, if [HTTP::host] matches foo.example.com a given branch (like passway) should be followed. Otherwise 'fallback' should be used.

 

I'm not trained in creating iRules and do not know how to make this branch decsision otherwise. It would be great if someone could give an example on which item in the access policy to use and could provide a sample snippet explaining how the above decsision could be made.

 

Thanks in advance,

 

Joerg

 

1 Reply

  • Hi,

     

    HTTP Host header is already provisioned in a Access variable:

     

    session.server.network.name

    You van use this branch expression:

     

    expr { [mcget {session.server.network.name}] == "foo.example.com" }

    if you want to collect another HTTP header, don't use iRule Event but this irule code:

     

    when ACCESS_SESSION_STARTED {
        ACCESS::session data set session.custom.myHeader [HTTP::header myHeader]
    }

    This ACCESS_SESSION_STARTED raise just before Access session redirect to /my.policy

     

    This event is the best time to catch first request content (HTTP headers, URI, query string, HTTP Method, ...)