Forum Discussion

Greg_Hooper_370's avatar
Greg_Hooper_370
Icon for Nimbostratus rankNimbostratus
Nov 17, 2010

iRule to replace http:// ipaddress for https://fqdn

Hi,

 

 

Apologies for asking this question but as a complete newbie to the F5 some guidance would be most helpful. We have the following problem

 

 

User sends the following request to Business Objects Infoview

 

 

https://fqdn/InfoViewApp/Logon4.jsp?CMS=123.123.123.123

 

 

Once the logon has occurred which works correctly, the application returns the following.

 

 

http://123.123.123.123/OpenDocument/opendoc/openDocument.jsp.

 

 

This obviously fails as the user in an internet based user running via HTTPS so obviously has no route to the local servers via their IP or HTTP. What I need to do is replace

 

 

http://123.123.123.123/OpenDocument/opendoc/openDocument.jsp with https://fqdn/OpenDocument/opendoc/openDocument.jsp

 

 

I am assuming an iRule is the way to go does anybody have any advice or examples?

 

 

Many Thanks,

 

 

Greg.

 

3 Replies

  • have u tried this solution? didn't it work?

     

     

    SOL6912: Configuring an HTTP profile to rewrite URLs so that redirects from an HTTP server specify the HTTPS protocol

     

    http://support.f5.com/kb/en-us/solutions/public/6000/900/sol6912.html
  • If you need to use the hostname that resolves to the virtual server instead of the IP, you could use an iRule like this:

    
    http://devcentral.f5.com/wiki/default.aspx/iRules/RewriteHTTPRedirectHostname.html
    
    when HTTP_REQUEST {
    
        Save host name (use VS IP if no HTTP host header was found
       if {[HTTP::host] eq ""}{
          set host [IP::local_addr]
       } else {
          set host [HTTP::host]
       }
    }
    when HTTP_RESPONSE {
    
        Check if server response is a redirect
       if { [HTTP::header is_redirect]} {
    
           Log original and updated values
          log local0. "Original Location header value: [HTTP::header value Location],\
             updated: [string map -nocase "http:// https:// [IP::server_addr] $host" [HTTP::header value Location]]"
    
           Do the update, replacing http:// with https:// and the server IP with the host or VS IP
          HTTP::header replace Location [string map -nocase "http:// https:// [IP::server_addr] $host" [HTTP::header value Location]]
       }
    }
    

    Aaron