Forum Discussion

Jobin1's avatar
Jobin1
Icon for Altostratus rankAltostratus
Dec 18, 2019

F5 APM Custom Variable Assign

How can i extract mobile number which is the header and assign to a custom variable.

 

host header session.http.last.response_header.0 contains

 

X-MOBILE_PHONE: 012345678

 

I need to extract this and assign to session.custom.mobile

 

Can we do this with custom variable assign option in VPE

4 Replies

  • Hello Jobin.

    You can get that using an iRule event instead of a custom variable in your VPE.

    After doing that, you should configure a new iRule like next:

    when HTTP_REQUEST {
    	if { [HTTP::header exists "X-MOBILE_PHONE"] } {
    		set phone [HTTP::header values "X-MOBILE_PHONE"]
    	}
    }
     
    when ACCESS_POLICY_AGENT_EVENT {
    	if { [ACCESS::policy agent_id] eq "addPhone" } {
    			ACCESS::session data set "session.custom.mobile" $phone
    		}
    	}
    }

    Finally, you should associate this iRule with the VS.

    KR,

    Dario.

  • Dear Dario,

     

    Thank you for your suggestion. What i am trying to do is, we have a web application and i am trying to implement otp using apm. As APM doesn't have any option to do HTTP query to get mobile, we had created an api which will reply back with mobile number in the host header "X-MOBILE_PHONE" during the http auth call. I am trying to extract only mobile number from the session.http.last.response_header.0 and map it to a custom mobile attribute. I understand that we can do this with irule but i am not aware how to extract this field only.

  • Thanks Dario. That was my own post which i did several years back. I forgot about this, I had searched for this and couldn't find. Thanks for sending me this.