Forum Discussion

shashank_shetti's avatar
shashank_shetti
Icon for Nimbostratus rankNimbostratus
Feb 16, 2016

Redirect but keep the original url in the address bar

Given a domain hosted in our company orginalSite.com but this site should resolve to vendor site ex: vendorsite.com.

 

It can not be redirected because requirement is to keep orginalSite.com (original url) in the browser address bar.

 

Here are couple of I rules that I tried.

 

Try1: replacing host headers

 

when HTTP_REQUEST { HTTP::header replace Host "vendorsite.com" HTTP::uri "/UserAccount/Login" }

 

Try2:

 

when HTTP_REQUEST { set dest [lindex [RESOLV::lookup @8.8.8.8 -a "vendorsite.com"] 0] node $dest 443

 

}

 

Any help will greatly appreciated.

 

6 Replies

  • The first approach is likely what you need; that is, replace the Host header and request URI path before it is submitted to the server. If you're running 11.5+:

    when HTTP_REQUEST {
        HTTP::host "vendorsite.com"
        HTTP::path "/UserAccount/Login"
    }
    

    Is this not working as you expect?

    Incidentally, you can also use a Local Traffic Policy:

  • Vernon thanks for the response but it is not working.

     

    Here is the error message from httpfox: [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.

     

    Yes we are on Version 11.5.2

     

  • @shashank - Is there an error in /var/log/ltm that appears when you make a request? If not, then the server is probably unhappy with the modified request. You can do two tests:

    1. From the BIG-IP, use
      curl
      to make the modified request;
    2. Run
      tcpdump
      on the BIG-IP to verify the result.

    For the first:

     curl --resolve vendorsite.com:80: -V http:///UserAccount/Login 2>&1 | less
    

    where is the IP address of the server. This will return the HTTP response. If it tries without working, then there is a path problem.

    For the second:

     tcpdump -i 0.0 -s0 -w /var/tmp/dump.pcap host 
    

    If you are using SNAT, it must be:

     tcpdump -i 0.0 -s0 -w /var/tmp/dump.pcap host  or 'host  and host '
    

    Then retrieve the pcap file (/var/tmp/dump.pcap) and open it in Wireshark to see what's going on.

  • If the backend server is configured to serve content for vendorsite.com you may also want to consider rewriting the response header, incase the Location field exists it can also be changed. Something along these lines:

    when HTTP_RESPONSE {
    if {[HTTP::header value "Location"] contains "vendorsite.com"} {
        HTTP::header replace Location [string map {"vendorsite.com" "originalsite.com"} 
    }
    

    }

  • Here is the final solution that I got it working. Thanks Vernon, Josh Hill, Josh for your responses.

     

    when HTTP_REQUEST {

     

    HTTP::host "vendorsite.com"

     

    if { ([HTTP::uri] equals "/") } { HTTP::uri "/UserAccount/Login/" }

     

    set dest [lindex [RESOLV::lookup @8.8.8.8 -a "vendorsite.com"] 0]

     

    node $dest 443

     

    }