Forum Discussion

Lark_53475's avatar
Lark_53475
Icon for Nimbostratus rankNimbostratus
Jun 14, 2007

HTTP Post Redirect getting changed to a GET...

Thanks for everyone's input, as I am very new to iRules. I have a need to redirect a request from http://server:2210 to https://server:2211. I am able to achieve this with the a simple rule:

 

 

HTTP::redirect "https://fstestora.hiw.com:2211[HTTP::uri]"

 

 

What I'm running into is that we have a custom client application that is doing a POST with xml data. When the POST hits the F5, it receives the redirect and response code, however the client resubmitts the request to the new location as a GET. The full rule I am using is:

 

 

when HTTP_REQUEST {

 

if {[HTTP::uri] contains "/xmllink"} {

 

HTTP::respond 307 Location "https://server.domain.com:2211[HTTP::uri]" replace HOST "server.domain.com:2211" "[HTTP::host][HTTP::uri]"

 

}

 

else{

 

HTTP::redirect "https://server.domain.com:2211[HTTP::uri]"

 

}

 

}

 

 

I've tried to change the HTTP Response to 301 and 302 as well with no difference. Reading the RFC on redirection, I see the following notation:

 

 

"Note: When automatically redirecting a POST request after receiving a 301 status code, some existing HTTP/1.0 user agents will erroneously change it into a GET request."

 

 

I believe I am running into this situation. Hope that explanation makes sense. Does anyone have any suggestions on how to address this situation using an iRule? I have not ruled out that this is just a function of the user agent/application and that there is no way to do this without simply getting the application to update it's URL. Thanks!

 

2 Replies

  • Hi,

     

     

    Could you avoid the redirect issue altogether by rewriting the URI and passing it to the pool?

     

     

    You can change the path in the request using HTTP::path. You can change the Host header value using:

     

     

    HTTP::header replace Host "new_host_header_value"

     

     

    Aaron
  • Thanks for the suggestion Aaron. A little more background... Ultimately, I'm trying to get SSL installed. I'm doing the simple redirection for my regular online traffic, but there is an application deployed globally with a hard coded URL (http://server:2210). The best option technically is to have all the users update their setup to reflect the new URL (https://server:2211). However, that is tough due to the distributed nature of the application. Communication to that community is a big challenge. So what I'm trying to do is redirect traffic from non-SSL port 2210 to SSL enabled port 2211 using an iRule. The simple redirect works for regular web traffic, but this application is causing some difficulties. It uses VBA and some other Excel macros to do an xml post to that hard coded URL. What I'm finding is for this application, when the HTTP Post occurs to http at port 2210, it catches the iRule and redirects to the https at port 2211. I do a host header rewrite at the virtual server defined for port 2211 as you suggested and I've done snoop captures at the web server to confirm that the header is indeed updated. The problem is the user agent (in this case the distributed app) is doing a POST initially, but when it encounters the 301 or 302, etc, it does a GET to the new location instead of resubmitting the POST to the new location. It would work for me to catch it at the Virtual server listening on port 2210 and passing it directly to the pool, the traffic in not encrypted.

     

     

    Hope that explanation isn't too convoluted...

     

     

    Lark