Forum Discussion

Aditya_Mehra's avatar
Aug 31, 2018

iRule help for

I have a virtual server and need to modify the traffic via an iRule Requirement:

 

1. Need to add authorization via static credential

 

2. Request comes in as POST , should go as POST from the F5, but server sees as GET from the F5

 

3. Redirect to redirect to another url via an iRule

 

I have using the below but it is not working.

 

when HTTP_REQUEST {

 

set logindata [b64encode "usermane:password"]

 

HTTP::header insert Authorization "Basic $logindata"

 

HTTP::redirect "https://www.abc.com[HTTP::uri]"

 

} '

 

17 Replies

  • That's fine. So,

    when HTTP_REQUEST {
        if { ( [HTTP::url] equals "/a/b/c/d/e/v2" ) and ( [HTTP::method] equals "POST" ) } {
            set logindata [b64encode "username:password"]     
            HTTP::header insert Authorization "Basic $logindata"
            pool vip2_pool
        }
    }
    
  • Hey Kevin,

     

    Just tried the above suggestion, but for some reason the F5 does not keep the uri while forwarding to the pool.

     

    Also i changed the [HTTP::url] to [HTTP::uri] -> is that fine?

     

    Thanks, Aditya

     

  • Yes, minor type. It should be [HTTP::uri].

    But on the other point, there's nothing in the iRule that would be changing the URI, and the VIP wouldn't touch it either.

    Not sure if you're re-encrypting between the two BIG-IPs, but you may need to capture traffic between to see what's going on.

    You can also set up logging on VIP2 to report the inbound URI.

    when HTTP_REQUEST {
        log local0. "Incoming method: [HTTP::method]"
        log local0. "Incoming URI: [HTTP::uri]"
        foreach x [HTTP::header names] {
            log local0. "Incoming header ($x): [HTTP::header $x]"
        }
    }
    
  • Thanks Kevin,

     

    I will try the option with VIP2 to insert the static credentials and also log it.

     

    Will update here once that is done as it may require a few approvals.

     

    As of now we are only redirecting traffic from External F5 1 to External F5 2 from https to https, and we have a client ssl and and the default 'serverssl' in place so no encryption is there.

     

    So now flow will be:

     

    Client --> External F5 1 (iRule redirection to VIP_A) --> External F5 2 VIP_A (iRule auth header and logging) here pool member as Internal F5 VIP_B --> Internal F5 VIP_B (pool as the final server) --> Server

     

    Thanks,Aditya

     

  • Hi Kevin,

     

    We could not make the changes on the second F5, but we are trying an alternative way.

     

    So I had another query, if we do not offload the SSL on the F5, can we still add the authorization header and forward it to the back end server where the SSL terminates.

     

    Thanks, Aditya