Forum Discussion

Vadiraj_95604's avatar
Vadiraj_95604
Icon for Nimbostratus rankNimbostratus
Apr 18, 2013

URI redirection

The traffic on http://url1.us.com:8443/Wireless/Wi...ageService should be forwarded to http://url22.us.com:8443/my/msg/out...ageService.

 

only host header needs to be changed

 

i tried the below but no luck

 

when HTTP_REQUEST {

 

if { ([HTTP::uri] equals "/Wireless/WirelessOutboundMessageService") } {

 

HTTP::uri "/my/msg/outbound/wireless/WirelessOutboundMessageService"

 

HTTP::header replace "Host" "url22.us.com:8443"

 

}

 

}

 

6 Replies

  • Hi,

     

    No both URLs are different VIPs.

     

     

    i am getting an additional / on the forwarded URI, hence a 404 error

     

  • Can you elaborate on what you're trying to do? I take it that you have two VIPs (url1 and url22) with the same iRule, doing essentially the same thing - changing the incoming URI and Host header? And that you appear to be getting an additional "/" in the URI arriving at the server(s)?
  • Hi,

     

     

    url1 is a old version of the app and url22 is new version, hence any traffic which will be hitting old version of app needs to be forwarded to new version of app

     

    yes url1 and url22 are different VIPs

     

    below is the log from web server, if you observe closely one additional / is getting added at the beginning of the uri

     

     

     

  • I have to say, unless there's a bug with HTTP::uri in your specific TMOS version, there has to be something else going on between the client and server. Lets try a little logging.

    
    when HTTP_REQUEST {
            log local0. "Incoming URI = [HTTP::uri]"
            if { ([HTTP::uri] equals "/Wireless/WirelessOutboundMessageService") } {
                log local0. "Caught URI and changing"
                HTTP::uri "/my/msg/outbound/wireless/WirelessOutboundMessageService"
                HTTP::header replace "Host" "url22.us.com:8443"
            }
    }
    when HTTP_RESPONSE {
         if { [HTTP::header exists Location] } {
              log local0. "redirect to [HTTP::header Location]"
         }
    }