Forum Discussion
Pradeep_Siwach_
Nimbostratus
Jul 17, 2012HTTPS Request irule
Hi,
We have VS with SSL client profile and the redirection irule configured for HTTP VS.
Currently the site www.xyz.com or xyz.com get redirected to https://www.xyz.com due to irule configuration on HTTP VS.
However when client request for https://xyz.com the redirection is not happening even though the following irule is configured.
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] eq "xyz.co.in" &&
[TCP::local_port] == 443 } {
HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"
}
}
Kindly help in fixing the issue.
Appreciate your prompt response and support.
7 Replies
- Brian_Van_Stone
Nimbostratus
[HTTP::host] should return "xyz.com" when https://xyz.com is requested. Try this:when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "xyz.com" } { HTTP::redirect "https://www.[HTTP::host][HTTP::uri]" } }This iRule needs to go on the https VS, not the http one.
Notice that you don't need to check the port if you only put this iRule on your 443 VS. Keep in mind, however, that if https://xyz.com results in a certificate error because of a host name mismatch that this error will still be encountered as the request without the www is already being served. Here is a good article on the host name mismatch fun.
https://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/265/Can-iRules-fix-my-cert-mismatch-errors.aspx - Pradeep_Siwach_
Nimbostratus
Hi Brian,
Thanks for the response however the applied irule doenst work as required.
Whenever we go for URL https://xyz.com it gives Connection reset but when we provide the URI along with it redirect properly such as https://xyz.com/home.aspx.
Do let me know any additional modification to be done in irule.
Regards - nathe
Cirrocumulus
Pradeep
Would this work for you?
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] eq "xyz.com" } {
Check if there is no uri too
if { [string tolower [HTTP::uri]] eq "" } {
HTTP::redirect "https://www.[HTTP::host]"
} elseif { [string tolower [HTTP::host]] eq "xyz.com" } {
HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"
}
}
}
Hope this helps,
N - Pradeep_Siwach_
Nimbostratus
Hi Nathan,
I will check with the mentioned irule and get back to you.
Anyway thanks for the response.
Regards. - nitass
Employee
Whenever we go for URL https://xyz.com it gives Connection reset but when we provide the URI along with it redirect properly such as https://xyz.com/home.aspx.wondering what result is when running curl.
e.g.[root@ve10:Active] config b virtual bar list virtual bar { destination 172.28.19.79:443 ip protocol 6 rules myrule profiles { clientssl { clientside } http {} tcp {} } } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "xyz.com" } { HTTP::redirect "https://www.[HTTP::host][HTTP::uri]" } } } - nitass
Employee
sorry i forgot to paste the result. 🙂[root@ve10:Active] config curl -Ik https://172.28.19.79 -H "Host: xyz.com" HTTP/1.0 302 Found Location: https://www.xyz.com/ Server: BigIP Connection: Keep-Alive Content-Length: 0 - Pradeep_Siwach_
Nimbostratus
Hi,
I will apply and check the result with curl.
We'll update you once tested.
Regards
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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