Forum Discussion
PacketHead_4009
Nimbostratus
Feb 17, 2010Simple redirect ?
Ok, this probably doesn't qualify for Adv Configuration but I couldn't find a spot where this question would fit.
How I can create a redirect so that if a user tries to go to:
http://webmail.mysite.com
that is redirects them to:
http://webmail.mysite.com/home/mail/default/
Also I would prefer that it redirects them to https instead of http.
so basically two things:
if a user goes to https://webmail.mysite.com it will redirect to https://webmail.mysite.com/home/mail/default/
and
if a user goes to http://webmail.mysite.com it will HTTP to HTTPS rediect to
https://webmail.mysite.com/home/mail/default/
is executing both of these requirements possible ?
8 Replies
- The_Bhattman
Nimbostratus
Hi Jcribb,
I am assuming that you have a vip for listening on port 80 and another vip listening on port 443
Based on this you could create an irule for port 80 redirect only
Which would look like the followingwhen HTTP_REQUEST { HTTP::redirect "https://webmail.mysite.com/home/mail/default/" }
This would take care of anyone going to port 80 and would be redirected correctly to https
-------------
The following example is the virtual server for port 443. Assuming this is for clients already using https but not the correct URI path you wantedwhen HTTP_REQUEST { if { ([HTTP::Host] eq "webmail.mysite.com") and ([HTTP::uri] eq "/") } { HTTP::redirect "https://webmail.mysite.com/home/mail/default/" } }
I hope this helps
Bhattman - PacketHead_4009
Nimbostratus
Thanks Bhatty,
Yes 2 VIPs, one HTTP and HTTPS
I tried the HTTP example you listed and it was going in a loop. I'll have to review my iRule and see where I went wrong.
Thanks for the HTTPS rule. I'll set that up and see if it works.
Thanks!
James - PacketHead_4009
Nimbostratus
Hello Bhatty,
I tried the HTTP iRule you gave and it just causes the site to site to fail (page cannot be displayed). It took the iRule fine which is strange.
For the HTTPS iRule I get this error when trying to save the iRule:
01070151:3: Rule [OWA_HTTPS_Path_Redirect] error:
line 2: [parse error: PARSE syntax 83 {syntax error in expression "([HTTP::Host] eq "webmail.mysite.com") and ([HTTP::uri] eq "...": looking for close parenthesis}] [{([HTTP::Host] eq "webmail.mysite.com") and ([HTTP::uri] eq "/"}] - L4L7_53191
Nimbostratus
There's a missing paren - try this:when HTTP_REQUEST { if {([HTTP::Host] eq "webmail.mysite.com") and ([HTTP::uri] eq "/")} { HTTP::redirect "https://webmail.mysite.com/home/mail/default/" } }
..On the 443 virtual server.
-Matt - PacketHead_4009
Nimbostratus
Ok it took it now. But when I apply that to the virtual server it doesn't work.
Now if I go to https://webmail.am.mysite.com I get nothing.
If I manually input the whole link https://webmail.am.mysite.com/home/mail/default/ I get nothing as well. It times out immediately. - hoolio
Cirrostratus
If you're seeing an immediate failure, it could be a TCP reset being sent when a runtime TCL error is hit. Can you check /var/log/ltm for any TCL errors?
Aaron - PacketHead_4009
Nimbostratus
No TCL errors ... log is clean. - hoolio
Cirrostratus
Can you add logging to the iRule and check the log output in /var/log/ltm to see what's happening in the rule?when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]" if {([HTTP::host] eq "webmail.mysite.com") and ([HTTP::uri] eq "/")} { log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to https://webmail.mysite.com/home/mail/default/" HTTP::redirect "https://webmail.mysite.com/home/mail/default/" } }
Thanks,
Aaron
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
