Forum Discussion
Redirecting one HTTPS url to another HTTPS url
I am trying to redirect our mobile users to our new mobile site with a simple iRule. The rule works fine for http traffic as it flows through but for HTTPS it does not work. No errors, it just seems to not redirect even though the debug messages are showing that it goes through the motions. I read another post where it states without a proxy that you cannot do it, but I am not sure I follow. I see multiple posts where others have apprently been able to get it to work
when HTTP_REQUEST {
log 10.40.25.59:34555 local0. "Entered iRule"
if { [string tolower [HTTP::host]] starts_with "www"}{
if { [string length [HTTP::uri]] < 2 } {
switch -glob [string tolower [HTTP::header User-Agent]] {
"*android*" -
"*blackberry*" -
"*iphone*" -
"*ipod*" -
"*googlebot-mobile*" {
log 10.40.25.59:34555 local0. "[IP::client_addr]: Redirect Path - [HTTP::host][HTTP::path] - User Agent [HTTP::header User-Agent]"
HTTP::respond 301 Location "https://m.mydomain.com/content/mobile/en/home.html"
return
}
}
}
}
}
10 Replies
- RFLORY_78743
Nimbostratus
http://www.mydomain.com/ gets redirected to https://m.mydomain.com/content/mobile/en/home.html no problem - What_Lies_Bene1
Cirrostratus
What port does the Virtual Server listen on please? Is an SSL profile assigned, i.e. are you terminating the SSL on the F5? I don't see how you can be as then the HTTP connections wouldn't work. If you're not terminating the SSL, the traffic remains encrypted as it passes through the device and iRules obviously can't read or modify it's contents. - RFLORY_78743
Nimbostratus
The both of the Virtual servers are listening on 443 and they have an SSL profile assigned - RFLORY_78743
Nimbostratus
Let me clarify that, the http is flowing through a different Virtual server on port 80 but using the same iRule thus redirecting to the same destination https. There is no sslprofile on the http/port80 Virtual server. - ssievers_87378
Nimbostratus
Hi, - What_Lies_Bene1
Cirrostratus
OK, I understand the setup. I don't see any reason why this wouldn't work; the iRule looks just fine, the VS setup you've described sounds fine. If the SSL clients are causing the log entries in both places it's configured then clearly the iRule can read the client data. I'd suggest a few things to try; - RFLORY_78743
Nimbostratus
I did some traces and basically found that it did not look like a response was getting sent back... On a hunch I removed another iRule that was called after this one and it appears to work, except it is missing the logic in the other iRule now. So the question is, how can I get the request to not process through other irules. - nitass
Employee
So the question is, how can I get the request to not process through other irules. i do not think HTTP_RESPONSE event is executed after running HTTP::respond in HTTP_REQUESTED event.[root@ve10:Active] config b rule myrule list rule myrule { when CLIENT_ACCEPTED { log local0. "" } when HTTP_REQUEST { log local0. "" HTTP::respond 301 Location "https://m.mydomain.com/content/mobile/en/home.html" } when HTTP_RESPONSE { log local0. "" } when CLIENT_CLOSED { log local0. "" } when SERVER_CLOSED { log local0. "" } } [root@ve10:Active] config tail -f /var/log/ltm Oct 19 21:28:00 local/tmm info tmm[7926]: Rule myrule : Oct 19 21:28:00 local/tmm info tmm[7926]: Rule myrule : Oct 19 21:28:00 local/tmm info tmm[7926]: Rule myrule :
- What_Lies_Bene1
Cirrostratus
Best bet would be to combine the two iRules, have the HTTP_REQUEST first and use 'event disable HTTP_RESPONSE' after you've sent your redirect (and only then) and then re-enable HTTP_RESPONSE at the end of the rule. - Norbert_65990
Nimbostratus
Hi, try:
HTTP::respond 301 Location "https://m.mydomain.com/content/mobile/en/home.html" event HTTP_REQUEST disable return
Does it work?
Recent Discussions
Related Content
* 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