Forum Discussion
THE_BLUE
Cirrostratus
Aug 05, 2021redirect http to https
I want to redirect Http to Https, for now I have created 2 VS one with port 443 and port 80 and I have used _sys_https_redirect rule ( provided by waf) in VS port 80.. so is there any alternative ...
StephanManthey
Nacreous
Aug 05, 2021Alternatively you can use a virtual server with port 0.
The wildcard of 0 lets the virtual listen on all ports.
Now you need to differentiate the handling depending on the service port.
This might be done via LTM policy or by iRule as the following one:
when CLIENT_ACCEPTED {
switch [LB::server port] {
80 {
SSL::disable
return
}
443 {
# some other iRule logic on tcp protocol level
}
default {
reject
}
}
}
when HTTP_REQUEST {
if { [LB::server port] == 80 } {
HTTP::respond 301 \
noserver \
Server "redirector" \
Location https://[getfield [HTTP::host] ":" 1][HTTP::uri] \
Date [clock format [clock seconds] -format {%a, %b %d %Y %H:%M:%S GMT} -gmt 1] \
Connection Close
} else {
# some other iRule logic on http protocol level
}
}
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