milo
Jul 06, 2009Nimbostratus
consolidate all http to https request under one virtual server
I would like to create one virtual server that uses a network segment to support all incoming http requests. The majority of my company's http traffic is redirected to https. I've come up with four different iRules that could be used to support the various redirects, including one to simply forward traffic to the correct pool.
Can I consolidate the following iRules into one iRule? And, does it even make sense to do this?
Rule URI_https_redirect
Purpose - Redirect http URI to specific https URI
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri] ] {
"/portal*" {HTTP::redirect "https://secure.aaa.com/login.do"}
"/b-portal*" {HTTP::redirect "https://secure.bbb.com/login.do"}
}
}
Rule domain_https_redirect
Purpose - Redirect http domains to specific https URI
when HTTP_REQUEST
switch [string tolower [HTTP::host] ] {
www.aaa.com { HTTP::redirect https://www.aaa.com[HTTP::uri] }
www.bbb.com { HTTP::redirect https://www.bbb.com[HTTP::uri] }
}
}
Rule http_no_redirect
Purpose - Forward http traffic to appropriate pool
when HTTP_REQUEST {
switch [string tolower [HTTP::host] ] {
www.ccc.com {pool www.ccc.com}
www.ddd.com {pool www.ddd.com}
}
}
Rule http_to_https_redirect
Purpose - Redirect any http URL to an https URL
when HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri] }