Forum Discussion
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
Cirrocumulus
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
- Kevin_Stewart
Employee
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 -------------------------------------->| - Gill_32697
Nimbostratus
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
Cirrocumulus
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.
- Gill_32697
Nimbostratus
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. !
- Gill_32697
Nimbostratus
when HTTP_REQUEST { log local0. "HTTP::uri is [HTTP::uri]"textif { ([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]" } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com