Forum Discussion

Steve_89474's avatar
Steve_89474
Icon for Nimbostratus rankNimbostratus
Aug 17, 2009

host header redirect (?) and hide URI

I have a request coming in for: www.trees.somedomain.com

 

 

and I want the request to be handled by www.outdoor.somedomain.com/trees

 

 

but all I want the user to see is the www.trees.somedomain.com

 

 

How can this be done?

 

 

Thanks,

 

Steve

4 Replies

  • If you want to mask if from the end user, you can just change the "Host" header value in the HTTP_REQUEST event.

     when HTTP_REQUEST { 
       if ( [HTTP::host] eq "www.trees.somedomain.com" ) { 
         HTTP::header replace "Host" "www.outdoor.somedomain.com" 
         HTTP::uri "/trees" 
       } 
     }

    Now, keep in mind that this will direct ALL requests to domain "www.trees.somedomain.com" to the backend server in the form of "http://www.outdoor.somedomain.com/trees". You will likely need to modify this a bit if you want to retain any portion of the original Uri in the request.

    Hope this helps...

    -Joe
  • I get file not found.

     

    I can request www.outdoor.somedomain.com/trees from my browser, and I can redirect to it using:

     

    when HTTP_REQUEST {

     

    if { ([HTTP::host] starts_with "www.trees.somedomain.com")} {

     

    HTTP::redirect "http://www.outdoor.somedomain.com/trees"

     

    }

     

    }

     

    But this doesn't work:

     

    when HTTP_REQUEST {

     

    if {[string tolower [HTTP::header "Host"]] eq "www.trees.somedomain.com"}{

     

    HTTP::header replace "Host" "www.outdoor.somedomain.com"

     

    HTTP::uri "/trees"

     

    }

     

    }

     

    I just get a 404 file not found error
  • Silly question, but is the "www.trees.somedomain.com" virtual the same one that handles "www.outdorr.somedomain.com"? The reason I ask is to make sure that the pool of servers that is currently targeted from

     

    "www.trees.subdomain.com" will get the request and need to be able to handle the other domain. If you have different pools for the two domains, then you'll likely need to assign the traffic to that pool from within the iRule with the "pool" command.

     

     

    If they are both configured under the same pool of servers, then can you look at the web server logs and see what the request is going in as to make sure the changes are taking hold?

     

     

    -Joe
  • Thanks Joe. The header and URI replace seem to be essentially "redirecting" them. I added the "pool [poolname]".

     

     

    As you said, the web server sees the request as www.outdoor.somedomain.com/trees so that is what is returned to the browser.

     

     

    to hide this URL from the browser would I edit the http resonse also, or use a stream profile?

     

     

    An iRule executes before the request is handed to the web server, correct? If so, how would I handle the response with an iRule?

     

     

    Thanks

     

    Steve