Forum Discussion

Souravpcs_14061's avatar
Souravpcs_14061
Icon for Nimbostratus rankNimbostratus
Jun 24, 2014

Server Response Rewriting

Hi Guys,

 

I have scenario that the ERP application to be accessed via https but at the server level port 8008 is hardcoded to the url and the server will redirect the url,Please help me in getting this work. How can i adapt an irule for this kind of situation.

 

2 Replies

  • If you simply need to rewrite the redirect Location header, then perhaps something like this will work:

    when HTTP_RESPONSE {
        if { [HTTP::header exists Location] } {
            HTTP::header replace Location [string map {"int.domain.com" "ext.domain.com"} [HTTP::header Location]]
        }
    }
    
  • Understood, but is it JUST the host name that needs to changed?

     

    http://xxx.com:8008 to https://xxx.com

    Or does the URI path also have to change?

     

    http://xxx.com:8008/yyyy/rrr to https://xxx.com

    If the former, then the Location header replacement code above should work for redirects.

     

    HTTP::header replace Location [string map {"http://xxx.com:8008" "https://xxx.com"} [HTTP::header Location]]

    If the latter, then the solution is a bit more complex. Also, if the offending URL is buried in the payload anywhere, perhaps as references to document objects,

     

    src=http://xxx.com:8008/images/my_cat.png

    then you'll also want a STREAM profile to rewrite these links in the response traffic. Again though, if it's just the host name that has to be changed, the iRule can be fairly simple. If you need to alter URI paths, that gets a bit trickier and starts getting into the realm of things like the ProxyPass iRule or Rewrite profiles in 11.5.

     

    Perhaps the best first thing to do is to analyze a client side capture with a tool like Fiddler or HTTPWatch. Look at the URLs that the browser is trying to access and potentially breaking on and see where those addresses are coming from.