Forum Discussion

kincho_51094's avatar
kincho_51094
Icon for Nimbostratus rankNimbostratus
Jul 10, 2010

how to redirect in F5 balancers

Hi guys

 

 

I need help, I am really frustrated because I had request to configure one rule as below:

 

Example:

 

These are the webserver to be balanced

 

https://pcname01.domain.com/main

 

https://pcname02.domain.com/main

 

 

in https://dns.domain.com/main

 

 

but I didn't know how to do a redirect from https://dns.domain.com to https://dns.domain.com/main

 

Everytime when go to https://dns.domain.com I get the apache test page, but I need to the F5 sends me to https://dns.domain.com/main.

 

 

Where in the configuration of F5 can I add that header "main" to go there when I put the link in the browser https://dns.domain.com

 

 

in addition I would like to know how to configure how to send the request to https everytime when the users try to go to http://dns.domain.com

 

I mean to convert this http://dns.domain.com in this https://dns.domain.co

 

 

Thanks in advance

 

6 Replies

  • Thanks a lot Chris, your idea sounds great.

     

     

    Just to be sure, if I understood well this code should be in the irule for the virtual server of HTTP, right?

     

     

    I will try this and I will comment how it worked

     

     

    Regards
  • Posted By kincho on 07/10/2010 04:12 PM

     

    Thanks a lot Chris, your idea sounds great.

     

     

    Just to be sure, if I understood well this code should be in the irule for the virtual server of HTTP, right?

     

     

    I will try this and I will comment how it worked

     

     

    Regards

     

     

    Yep - tie it to the VS.
  • A small note:

    [HTTP::host] - will return the host header value

    [HTTP::host] eq "dns.domain.com" - will return 0 or 1 depending on whether the HTTP host is dns.domain.com or not

    [[HTTP::host] eq "dns.domain.com"] - will try to execute 0 or 1 and return a runtime TCL error as 0 or 1 isn't a valid command

    Similarly:

    [HTTP::uri] - will return the URI (path plus query string)

    [HTTP::uri] eq "/" - will return 0 or 1 depending on whether the HTTP URI is / or not

    [[HTTP::uri] eq "/"]] - will try to execute 0 or 1 and return a runtime TCL error as 0 or 1 isn't a valid command

    You could use this:

    
        if { [string tolower [HTTP::host]] eq "dns.domain.com" and [HTTP::uri] eq "/"] } {
    

    Or use Joe's preferred syntax:

    
        if { [string tolower [HTTP::host]][HTTP::uri] eq "dns.domain.com/" } {
    

    Aaron
  • Posted By hoolio on 07/12/2010 03:58 AM

    A small note:

    [HTTP::host] - will return the host header value

    [HTTP::host] eq "dns.domain.com" - will return 0 or 1 depending on whether the HTTP host is dns.domain.com or not

    [[HTTP::host] eq "dns.domain.com"] - will try to execute 0 or 1 and return a runtime TCL error as 0 or 1 isn't a valid command

    Similarly:

    [HTTP::uri] - will return the URI (path plus query string)

    [HTTP::uri] eq "/" - will return 0 or 1 depending on whether the HTTP URI is / or not

    [[HTTP::uri] eq "/"]] - will try to execute 0 or 1 and return a runtime TCL error as 0 or 1 isn't a valid command

    You could use this:

        if { [string tolower [HTTP::host]] eq "dns.domain.com" and [HTTP::uri] eq "/"] } {
    

    Or use Joe's preferred syntax:

        if { [string tolower [HTTP::host]][HTTP::uri] eq "dns.domain.com/" } {
    

    Aaron

    F5 needs to release a "Hoolio App" that automatically adjusts your iRule to correct syntax so you don't have to correct mine üòõ
  • Better yet. Why doesn't F5 just re-hire Hoolio provide him access to lab gear and have him run the forums.

     

     

    Bhattman
  • Posted By Bhattman on 07/18/2010 05:29 AM

     

    Better yet. Why doesn't F5 just re-hire Hoolio provide him access to lab gear and have him run the forums.

     

     

    Bhattman

     

     

    He kinda sorta does run the forums. :-P