Forum Discussion

jeffrey1984's avatar
Aug 05, 2019

URL Header rewrite question

We are working on an irule where we want to achieve a specific outcome. If the client access abc.example.com , the header rewrites and change it to xyz.apps.example.com . That actually works , but we wanted to see abc.example.com on the client's view and not the xyz.apps.example.com , so it looks like transparent . We added http_response but seems like its not working . I would appreciate any help. Thanks

 

when HTTP_REQUEST {

 if { [HTTP::header "Host"] equals "abc.example.com" } {

    HTTP::header replace Host "xyz.apps.example.com "

 }

}

when HTTP_RESPONSE {

 if { [HTTP::header "Host"] equals "xyz.apps.example.com " } {

    HTTP::header replace Host "abc.example.com"

 }

}

1 Reply

  • The browser address bar depends on what links are followed as the page loads - I can only guess, but I expect that there is a redirect somewhere that redirects the page to xyz.apps.example.com, so that is what is shown in the browser address bar.

     

    You need to add a Rewrite profile to rewrite xyz.apps.example.com to abc.example.com in http responses

     

    https://techdocs.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/ltm-profiles-reference-13-1-0/2.html

    -----

    About Rewrite profiles

    For environments that use web servers, you might want your websites to appear differently on the external network than on the internal network. For example, you might want the BIG-IP® system to send traffic destined for www.company.com/usa/ to the internal server usa.company.com instead. Normally, this translation could cause some issues, such as the web server expecting to see a certain host name (such as for name-based virtual hosting) or the web server using the internal host name when sending a redirect to client systems.

    You can solve these problems by configuring a Rewrite profile, which causes the BIG-IP system to act as a reverse proxy server. As a reverse proxy server, the BIG-IP system offloads the URI translation function from web servers enabled with features such as Apache's ProxyPass module. With a Rewrite profile, the BIG-IP system can perform URI scheme, host, port, and path modifications as HTTP traffic passes through the system. The feature also provides reverse translation for the Location,Content-Location, and URI headers in the server response to the client.

    -----