Forum Discussion
together_183451
Nimbostratus
Feb 13, 2015Need help to redirect all url from http to https
when HTTP_REQUEST {
set uri_lower [string tolower [HTTP::uri]]
if { $uri_lower starts_with {/test1}} {pool test1_Pool}
if { $uri_lower starts_with {/test2} {pool test2_Pool}
if { $uri_lower starts_w...
StephanManthey
Nacreous
Feb 14, 2015Hi together,
the topic of your question does not match the iRule sample code.
Please clarify.
Regarding the thread´s subject:
There is a built-in iRule to redirect from http to https (/Common/_sys_https_redirect):
when HTTP_REQUEST {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}It takes the original hostname and uri into account and takes care of service port settings.
It just needs to be assigned to your virtual servers listening i.e. on port 80. These servers will need an http-profile and this iRule. Done.
Regarding the iRule code. It can be optimized a bit i.e. as follows:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/test1*" { pool test1_Pool }
"/test2*" { pool test2_Pool }
"/test3*" { pool test3_Pool }
"/test4*" { pool test4_Pool }
default { pool [LB::server pool] }
}
}Thanks, Stephan
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects