Forum Discussion

cquick11_115408's avatar
cquick11_115408
Icon for Nimbostratus rankNimbostratus
May 17, 2013

Irule Help with redirection

I created an irule to redirect from http:https and vice versa based on creteria from our development team; however some of the checkout pages aren't rendering correctly because they are staying in http on the secure page. They gave me a list of other patterns to check, so that if the page is in https, use https. My code is not working correctly:

 

I have two VS, http and https, they both have http profiles and it's doing ssl termination. I am using data groups:

 

List of mixed-mode URL patterns:

 

/services/*

 

*/qas_proxy*

 

URL Extension List:

 

.aspx

 

.html

 

.htm

 

.svc

 

List of secure URL patterns:

 

/checkout*

 

*/orderconfirmation*

 

/accountinformation*

 

/login*

 

/register*

 

 

VS:http

 

when HTTP_REQUEST {

 

if { [class match [HTTP::uri] starts_with mixed_mode] } {

 

pool POOL_CHD-Stage-Web

 

log local0. "mixed_mode Request:[HTTP::method] [HTTP::host][HTTP::path] URI: [HTTP::uri]"

 

 

} elseif { [class match [HTTP::path] equals file_extensions] } {

 

pool POOL_CHD-Stage-Web

 

log local0. "file_extensions Request:[HTTP::method] [HTTP::host][HTTP::path] URI: [HTTP::uri]"

 

 

} elseif { [class match [HTTP::uri] starts_with secure_uris] } {

 

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

 

log local0. "Secure_Uris Request:[HTTP::method] [HTTP::host][HTTP::path] URI: [HTTP::uri]"

 

}

 

}

 

 

VS:HTTPS

 

 

when HTTP_REQUEST {

 

if { [class match [HTTP::uri] starts_with mixed_mode] } {

 

pool POOL_CHD-Stage_443

 

log local0. "mixed_mode Request 443:[HTTP::method] [HTTP::host][HTTP::path] URI: [HTTP::uri]"

 

 

} elseif { [class match [HTTP::path] equals file_extensions] } {

 

pool POOL_CHD-Stage_443

 

log local0. "file_extensions Request 443:[HTTP::method] [HTTP::host][HTTP::path] URI: [HTTP::uri]"

 

 

} elseif { not [class match [HTTP::uri] starts_with secure_uris] } {

 

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

 

log local0. "Secure_Uris Request 443:[HTTP::method] [HTTP::host][HTTP::path] URI: [HTTP::uri]"

 

}

 

}

 

 

 

 

 

1 Reply

  • List of mixed-mode URL patterns:

     

    /services/*

     

    */qas_proxy*

     

    List of secure URL patterns:

     

    /checkout*

     

    */orderconfirmation*

     

    /accountinformation*

     

    /login*

     

    /register*i do not think you need asterisk (*) in data group since you are using class match.

     

     

    if { [class match [HTTP::uri] starts_with mixed_mode] } {shouldn't operator be contains?

     

     

    } elseif { [class match [HTTP::path] equals file_extensions] } {is it ends_with?

     

     

    } elseif { not [class match [HTTP::uri] starts_with secure_uris] } {is it also contains?