Forum Discussion

Lon_bale_55412's avatar
Lon_bale_55412
Icon for Nimbostratus rankNimbostratus
Nov 06, 2009

URI redirection https to an external http URL

Currently we are trying to redirect a to an external URL from one that sits behind the F5 with no luck.

 

 

The user hits the site via https://myserver/spaces and we are trying to redirect the user to an external source http://myserver1/spaces. If we turn off rewrite/redirect then it works, but can't do this so does anyone have any idea how to redirect a user from https:// to an external http:// url?
  • So you are trying to redirect from the VIP to the specific server behind the load balancer?

     

     

    CB
  • we are redirecting from the VIP to an external URL at a different location. We have asp.net code that looks for a specific URL, and redirects the user to the correct url in a different city. The code redirects the user to http://newserver and the F5 is appending https://newserver when the redirection happens.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    You could replace the HTTP profile functionality for rewriting redirects with an iRule that inspects the Location header in redirects and only rewrites to https:// for your specific scenarios. If you have a lot of URIs to check you could add them to a datagroup. In this example, I've used a class named locations_to_preserve_class

     
     when HTTP_RESPONSE { 
      
         Check if response is a redirect 
        if {[HTTP::is_redirect]}{ 
      
            Save the Location header value to lowercase 
           set location [string tolower [HTTP::header Location]] 
      
            Check if the Location header value starts with http:// and is not one to preserve as http:// 
           if {$location starts_with "http://" \ 
              and not ([matchclass $location starts_with $::locations_to_preserve_class])}{ 
      
               Replace http:// with https:// in the Location header 
              HTTP::header replace Location [string map "http:// https://" $location] 
           } 
        } 
     } 
     

    Aaron