Forum Discussion

gusf5_117081's avatar
gusf5_117081
Icon for Nimbostratus rankNimbostratus
May 16, 2013

host rewrite newbi

 

simple change from https://test.irule.test.com/hello.html to https://preview.test.com/hello.html

 

 

also would like to to the following https://test.irule.test.com/***any uri *** https://preview.test.com/***any uri***

 

 

Will this do it?

 

 

when HTTP_REQUEST {

 

if { [HTTP::host] contains "test.irule.preview.test.com" } {

 

set HTTP::host "preview.test.com"

 

}

 

}

 

 

because I only get page cannot be displayed if I go to test.irule.test.com/test.html, I cannot see preview.test.com/test.html

 

 

Thanks

 

6 Replies

  • If you're happy with a redirect (that will show the other domain name in the browser address bar) this will do it;

    
    when HTTP_REQUEST {
    if { [HTTP::host] contains "test.irule.test.com" } {
    HTTP::redirect "https://preview.test.com[HTTP::uri]"
    }
    }
    
  • Thank you very much!!

     

    If I want to do a invisible HTTP::host change, will it be?

     

     

    when HTTP_REQUEST {

     

     

    if { [HTTP::host] contains "test.irule.preview.test.com" } {

     

     

    set HTTP::host "preview.test.com[HTTP::uri]""

     

     

    }

     

     

    }
  • You're welcome. It's a bit different if you want it to be invisible to the user and no need to touch the URI (although an absolute URI could bypass the host check);

    
    when HTTP_REQUEST {
    if { [HTTP::host] contains "test.irule.test.com" } {
    HTTP::header remove Host
    HTTP::header insert Host "preview.test.com"
    }
    }
    
  • Is there a reason why when I enable the irule the site stops working.

     

     

    I have it working with a default persistence profile dest_addres and I add the http profile for the http and the https traffic and nothing comes up.

     

     

    Well thanks for you help
  • I got it working on http, for some reason in the test environment with self signed certificates the https traffic drops as soon as I add a http profile. Any ideas?

     

     

    Thanks
  • You'll need separate VSs for HTTP and HTTPS traffic I'd imagine. You can't inspect SSL without assigning a ClientSSL profile.