This first part of the iRule works great, but the second part doesn’t work at all. The certificate is registered to www.mynurseonline.com. If a user just puts in mynurseonline.com they get a certificate error, so I’m trying to do this redirect. Not sure I’m going about it the right way or not. Like I said, I’m new to iRules! Let me know if you think I could do anything better. Thanks so much!
Is the redirect actually not working? I.E. they’re not getting to www.mynurseonline.com? Or is it just that they’re still getting the security error?
There’s unfortunately no way for you to avoid them receiving that security error if they type the hostname incorrectly. The BIG-IP has to decrypt the session before it can do any inspection or redirection. At that point the user would have already seen the security notice and accepted the warning.
You could get a new cert using Subject Alternate Names which is valid for example.com and www.example.com. For more info on this, try searching the 9.x iRules forum for “san cert” or “subject alternate name”.
The cert would then be valid for both fully qualified domain names in your rule and the browser would not prompt the user about the hostname mismatch.
Do you get a TCL error in /var/log/ltm when the second redirect doesn’t work? What response does the client get from the VIP? Is it a TCP reset or some kind of HTTP response? If you test with Fiddler for IE or LiveHttpHeaders for Firefox, you can see if there is an HTTP response. Also, can you add logging to the rule so you can see if it’s being triggered as you expect?
Do you have another iRule added to the VIP or an HTTP class which is redirecting the client? If so, can you post that rule?
I don’t see how both redirects could be triggered from this rule as they’re wrapped in an if/else. The log output shows that the first condition isn’t being met, so there must be another redirect being issued. If you’re stuck, try posting the VIP configuration by running ‘b virtual VIRTUAL_NAME list’.