For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

mike_schweinber's avatar
mike_schweinber
Icon for Nimbostratus rankNimbostratus
Jul 22, 2006

Can I use an IRULE?

Hello,

 

 

Trying to load balance 3 web servers running Kronos Application. Need to use 443 for some security but application uses 80. Can I use an IRULE to manipulate this? With the setup now, they can go to the URL with HTTP or HTTPS. Only want HTPS.

 

 

User goes to https://time.abc.org/scf/login

 

 

Java client needs to be installed if not already. They sign in and do what they need to in the Application. Currently I have both ports 80 and 443 opened to make this work.

 

 

I did find this on the site for HTTP redirects:

 

 

when HTTP_REQUEST {

 

HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]

 

}

 

 

 

Will this work? I really have no idea about Irules so I appologize for any stupidity! Thanks in advance!

15 Replies

  • HTTP vip has irule that just redirects to HTTPS VIP

     

    when HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri] }

     

  • Hi Brett,

    Just to recap, I tried the above irule on the HTTPS VIP, and custom http profile on both the HTTP/HTTPS VIP based on the default http profile with redirect rewrite to matching. This time the web-page is not working at all. Fiddler output says the following:

    [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.

    HTTP VIP irule

    when HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri] }
    

    HTTPS VIP irule

    when HTTP_REQUEST { 
    STREAM::disable 
    HTTP::header remove "Accept-Encoding" 
    } 
    when HTTP_RESPONSE { 
     Check if response type is text and host isn't null 
    if {[HTTP::header value Content-Type] contains "text" and $host ne ""}
    { 
     Replace http://$host with https://$host 
    STREAM::expression "@http://$host@https://$host@" 
     Enable the stream filter for this response only 
    STREAM::enable 
    } 
     Rewrite the Location header in redirects to https:// 
    if { [HTTP::is_redirect] && [string tolower [HTTP::header Location]] starts_with "http://$host"} { 
    HTTP::header replace Location [string map -nocase "http://$host https://$host" [HTTP::header Location]] 
    } 
    } 
    

    I get the same result with the default http profile on both VIPs. Kronos works fine from the backend Servers, (when we skip the F5) but everything is presented in HTTP. Is this a Kronos or F5 issue?

  • Hi Brett,

    Just to recap, I tried the above irule on the HTTPS VIP, and custom http profile on both the HTTP/HTTPS VIP based on the default http profile with redirect rewrite to matching. This time the web-page is not working at all. Fiddler output says the following:

    [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.

    HTTP VIP irule

    when HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri] }
    

    HTTPS VIP irule

    when HTTP_REQUEST { 
    STREAM::disable 
    HTTP::header remove "Accept-Encoding" 
    } 
    when HTTP_RESPONSE { 
     Check if response type is text and host isn't null 
    if {[HTTP::header value Content-Type] contains "text" and $host ne ""}
    { 
     Replace http://$host with https://$host 
    STREAM::expression "@http://$host@https://$host@" 
     Enable the stream filter for this response only 
    STREAM::enable 
    } 
     Rewrite the Location header in redirects to https:// 
    if { [HTTP::is_redirect] && [string tolower [HTTP::header Location]] starts_with "http://$host"} { 
    HTTP::header replace Location [string map -nocase "http://$host https://$host" [HTTP::header Location]] 
    } 
    } 
    

    I get the same result with the default http profile on both VIPs. Kronos works fine from the backend Servers, (when we skip the F5) but everything is presented in HTTP. Is this a Kronos or F5 issue?

  • Ajit's avatar
    Ajit
    Icon for Altostratus rankAltostratus

    Hello Rahul,

    Please try the below iRule and you should be good to test

    when HTTP_REQUEST {
      HTTP::header remove "Accept-Encoding"
      STREAM::disable
      set host [HTTP::host]
    }
    
    when HTTP_RESPONSE {
      STREAM::disable
      
      if { [HTTP::header exists Location] } {
        HTTP::header replace Location [string map {"http://" "https://"} [HTTP::header Location]]
      }
      
      if { [HTTP::header Content-Type] contains "text" } {
        set before "http://${host}:80/"
        set after "https://${host}/"
    
        STREAM::expression "@${before}@${after}@"
        STREAM::enable
      }
    }
    

    Please apply the above iRule to the https VIP and also make sure that you select the default stream profile for this HTTPS VIP.

    Also, assign a custom https profile to the same VIP with the following features enabled:

    Response Chunking: Re-chunk Redirect Rewrite: All

    Let me know how it goes.

    Thanks,

    Ajit