Forum Discussion

Gill_32697's avatar
Gill_32697
Icon for Nimbostratus rankNimbostratus
Sep 06, 2013

iRules and Post redirects.

So let me ask this iRule question. My I rules works internaly with Gets no problem. But when a request is made to the VIP from another Server, the redirects do not work. I get a Page Cant Be Displayed. Web Dev team says Redirects are failing when doing a Post, but work when going a get internally. So can the LTM iRule handle Uri Redirects when doing a Post?

 

6 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Gilbert, so this is because a redirect will use a Get request and ignore that it was an initial Post. In the iRule you could use a HTTP status code 307 instead. This tells the browser to use the original request type. Use the http::respond command. Hope this helps, N

     

  • Reference: https://devcentral.f5.com/questions/redirects-with-get-post

    So can the LTM iRule handle Uri Redirects when doing a Post?

    As mentioned in the other post, a 302 redirect will cause the client to perform a GET to the redirected URL.

    CLIENT                                                     VIP1    VIP2
      | -------------------> POST ----------------------------->|
      | <------------------Redirect to VIP2 --------------------|
      | -------------------> GET -------------------------------------->|
    
  • Nathen, we tried your example we did a little further. Below is what we have nor, is there anything in our irule that is missing or that you can add.

     

    when HTTP_REQUEST { if { ([string tolower [HTTP::host]]) contains "b-unitynet.swbc.com" } { switch -glob -- [string tolower [HTTP::uri]] { "meridianlinkws.asmx" { HTTP::respond 307 Location "https://b- webservices.swbc.com/Unity[HTTP::uri]" } "weblet.asmx" { HTTP::respond 307 Location "https://b-webservices.swbc.com/Unity/Weblet.asmx" } } } }

     

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Think that looks ok, you're on the right lines. I've not done a full check on the syntax though. Good luck with this.

     

  • So we have been trying different irules. We can verify the the iRule and URI string is correct. From all the logging, tcpdumps and httpwatch data, it is being redirect correctly. It seems the data is not making its was back to the client after the post. How can we verify and capture the retuning data after the post? below is out rule so fare. !

     

  • text
    when HTTP_REQUEST { log local0. "HTTP::uri is [HTTP::uri]"

    if { ([string tolower [HTTP::host]]) contains "b-unitynet.swbc.com" } { switch -glob -- [string tolower [HTTP::uri]] {

       "*meridianlinkws.asmx*" { HTTP::respond 307 Location "https://b-webservices.swbc.com/Unity[HTTP::uri]" }
       "*unityweblet.asmx*" { HTTP::redirect "https://b-webservices.swbc.com/Unity/Weblet.asmx" }
       "*weblet.asmx*" { HTTP::respond 307 Location "https://b-webservices.swbc.com/Unity/Weblet.asmx" }
       "weblet.asmx" { HTTP::redirect "https://b-webservices.swbc.com/Unity/Weblet.asmx" }
    

    } log local0. "HTTP::uri is [HTTP::uri]" } }