Forum Discussion

Sander_-_Portaa's avatar
Sander_-_Portaa
Icon for Nimbostratus rankNimbostratus
Jun 28, 2018

Intenal server responds internal url to external clients

Hi, we have an internal server that sould be accessed from the internet. External url is something like testapp.testdomain.fake The F5 receives the request, and sends it to the internal server. But the internal server responds to the client with an internal URL :s (e.g. internalapp.local.domain) The application provider says it is not their problem (I think it is, but hey who am i..) Is there any way to build a url rewrite for the response to the external client?

 

thanks for your help.

 

1 Reply

  • Hi,

    I think that you application owner use absolute paths, absolute paths always include the domain name of the website.

    He should have used Relative path.

    For more information: https://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/

    You can solve this behavior, for this you have to rewrite header response and contente response (Body).

    Devcentral already addressing the subject, you can use this irule:

    https://devcentral.f5.com/questions/hostname-rewrite

    I adapt the rule for you, let me know if you need more details. don't forget to change hostname (internal external)

     when HTTP_REQUEST { 
    
        set external_hostname "aaa.company.com"         
        set internal_hostname "bbb.company.net"    
         Enable debug logging to /var/log/ltm.  1 = yes, 0 = no 
        set hostname_rewrite_debug 0 
    
        if {$hostname_rewrite_debug}{log local0. "Original URL: [HTTP::host][HTTP::uri]"} 
    
        HTTP::header replace "Host" $internal_hostname        
    
        if {$hostname_rewrite_debug}{log local0. "New URL: [HTTP::host][HTTP::uri]"} 
     }    
    
    
     when HTTP_RESPONSE {         
        if { [HTTP::header value "Location"] starts_with "$internal_hostname" }{ 
    
            if {$hostname_rewrite_debug}{log local0. "Inside of HTTP::header location, orig HTTP location equals: [HTTP::header location]"} 
    
            set location [HTTP::header location] 
    
            HTTP::header replace location $external_hostname 
    
            if {$hostname_rewrite_debug}{log local0. "Inside of HTTP::header location, new HTTP location equals: [HTTP::header location]"} 
        } 
     }   
    

    But more simple for you is to use a rewrite profile. It work fine for me and it simple to maintain.