Forum Discussion

22 Replies

  • Thats what a LTM Policy would look like:

    ltm policy mycompany.com_policy {
        controls { forwarding }
        requires { http }
        rules {
            egift {
                actions {
                    0 {
                        http-reply
                        redirect
                        location https://456.mycompany.com[HTTP::uri]
                    }
                }
                conditions {
                    0 {
                        http-host
                        host
                        values { 123.mycompany.com }
                    }
                    1 {
                        http-uri
                        path
                        values { /egift.aspx }
                    }
                }
                ordinal 1
            }
        }
        strategy first-match
    }
    
    • Stanislas_Piro2's avatar
      Stanislas_Piro2
      Icon for Cumulonimbus rankCumulonimbus
      I agree with you, policy is the easiest solution to redirect, assign pools, rewrite headers... The problem is the irule does exactly the same as your policy and does not solve the issue. that's why I asked marv Williams to explain what are differences between the initial request and the redirect URL.
    • marv_Williams_5's avatar
      marv_Williams_5
      Icon for Nimbostratus rankNimbostratus
      The values and placement of tid and eid chnage. I was hoping at least tid and eid would remain static. The request uses a number that the user has and they enter the entire url with the dynamic number. The redirect then contains new dynamic information after egift.aspx?. Also I am using 11.5.0 currently and did not think of policy but could try it
  • Hi,

    You can use this irule to help you:

    when HTTP_REQUEST {
        if { ([string tolower [HTTP::host]] equals "mycompany.com") && ([HTTP::path] equals "/egift.aspx" ) } {
            set eidval [URI::query [HTTP::uri] eid]
            set tidval "b"
            HTTP::respond 302 Location "https://egiftpp.mycompany.com[HTTP::path]?eid=$eidval&tid=$tidval"
        }
    }
    

    As you can see, you can parse previous query to get parameters values and assign to parameters in redirect.

  • I have tried to get the redirect to work without any success. Here is a better idea of what we are trying to redirect and the I-Rule I have used:

     

    Here is what we are trying to do: 1.) https://www.mysite.com/egift.aspx?eid=&tid= - to be re-routed to https://egift.mysite.com/egift?eid=&tid=

     

    Here is the I-Rule I used to attempt the redirect:

     

    when HTTP_REQUEST { log local0. "Request [URI::query [HTTP::uri]eid]" if { ([string tolower [HTTP::host]] equals "mysite.com") && ([HTTP::path] equals "/egift.aspx" ) } { set eidval [URI::query [HTTP::uri] eid] set tidval [URI::query [HTTP::uri] tid] Log local0. "Request [HTTP::path]" HTTP::respond 302 Location "https://redirectsite.com[HTTP::path]?eid=$eidval&tid=$tidval" } }

     

    When I turned on logging I recieved this response: Mon Sep 14 21:20:52 PDT 2015 info sc-preprod-DMZ-lb tmm1[29803] Rule /Common/egift-redirect2 : Request:eid=DM67JKKM4DBLXPYDS88KDX8PL0&tid=VMH5N8QQJA87XCF6022YZHG724&template=basiceid

     

    The above I-Rule looks like it should work but it does not redirect correctly

     

  • Hi,

    I tried the iRule and the I got the expected result:

    $ curl -i "http://192.168.1.133/egift.aspx?eid=DM67JKKM4DBLXPYDS88KDX8PL0&tid=VMH5N8QQJA87XCF6022YZHG724&template=basiceid" -H "Host: mysite.com"
    HTTP/1.0 302 Found
    Location: https://redirectsite.com/egift.aspx?eid=DM67JKKM4DBLXPYDS88KDX8PL0&tid=VMH5N8QQJA87XCF6022YZHG724
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
  • Hi I'm kind of surprised there's no simple answer for this.

    We need to redirect (also see requirements below):

    https://foo.bar.com/authorize/aaa/bbb/someFile.jsp?response_type=<some_dynamic_value>&client_id=<some_dynamic_value>&scope=<some_dynamic_value>&redirect_uri=<some_dynamic_value>

    to 

    https://xxx.baz.com/authorize/aaa/bbb/someFile.jsp?response_type=<same_dynamic_value_from_request>&client_id=<same_dynamic_value_from_request>&scope=<same_dynamic_value_from_request>&redirect_uri=<same_dynamic_value_from_request>

    Requirement #1: we can't use pools or policies.

    Requirement #2: Only change requests coming into the path that starts with /authorize (e.g. https://foo.bar.com/authorize/etc. gets redirected). Other requests hitting the host with a different start to the path must remain unchanged (e.g. https://foo.bar.com/billling must stay the same).

    Requirement #2: With a simple redirect, we want to change the host name only, and keep the paths in the redirect  the same as in the request and keep all query params and their values in the redirect the same as in the request (values change dynamically with each request)