Forum Discussion

JP_42120's avatar
JP_42120
Icon for Nimbostratus rankNimbostratus
Oct 18, 2012

irule performance: combine multiple irules

Hi,

 

We have an several irules that we are trying simplify and combine for better performance.

 

first to block certain URI's

 

 

when HTTP_REQUEST {

 

switch [HTTP::uri] {

 

"/proxy/" -

 

"/content/xmlmovies/undefined" -

 

"/duas/" {

 

HTTP::respond 404 content "404 - file not found."}

 

}

 

 

To log request with certain content size

 

if { [HTTP::header Content-Length] >= 9000 } {

 

log local0. "[HTTP::header Content-Length] byte [HTTP::method] request from [IP::client_addr] for [HTTP::host][HTTP::uri]"

 

}

 

 

Redirect to certain URI's to HTTPs

 

switch -glob [string tolower [HTTP::path]] {

 

"/login*" {

 

if {[TCP::local_port] == 80} {

 

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

 

}

 

}

 

"/app/login_user*" {

 

if {[TCP::local_port] == 80} {

 

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

 

}

 

}

 

"/app/new*" {

 

if {[TCP::local_port] == 80} {

 

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

 

}

 

}

 

"/app/associate_new*" {

 

if {[TCP::local_port] == 80} {

 

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

 

}

 

}

 

"/account*" {

 

if {[TCP::local_port] == 80} {

 

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

 

}

 

}

 

}

 

}

 

14 Replies