Forum Discussion

5 Replies

  • Untested:

    when HTTP_REQUEST { 
    if { ([HTTP::host] equals "site1.domain.com") } { 
    HTTP::host [string map {site1.domain.com site2.subdomain.com} [HTTP:host]]
    } 
    } 
    when HTTP_RESPONSE {
    if { [HTTP::header values Location] contains "site2.subdomain.com" } {
    HTTP::header replace Location [string map {site2.subdomain.com site1.domain.com} [HTTP::header value Location]]
    }
    }
    
  • Fortunately in v12, an iRule is no longer needed for this type of translation. The rewrite profile is what you would use, especially if you used the proxy-pass iRule in the past.

    Simply rewriting the Host header in the request and Location headers in the response will not address URLs that exist in HTML content.

    Simply create a uri-translation rewrite profile and add a URL rule:

    Client URL: https://site1.domain.com/
    Server URL: https://site2.sub.domain.com/widget/
    

    Notice the URLs end in a

    /
    .

  • I tried the rewrite profile, but I'm still seeing the hosts field come up as site1.domain.com as opposed to site2.sub.domain.com in my packet captures. For me, I don't need the uri replaced, I want that to go through.

     

    My rewrite profile is set for client url: https://site1.domain.com/ Server url: https://site2.sub.domain.com/

     

    Any idea why the host headers wouldn't be re-written?

     

    • Vijay_E's avatar
      Vijay_E
      Icon for Cirrus rankCirrus

      From the client device, perform a curl to site1.domain.com and from the F5, perform a curl to site2.domain.com just to see the response from server. This will help you to isolate the problem and troubleshoot further.