Forum Discussion

test_user_14481's avatar
test_user_14481
Icon for Nimbostratus rankNimbostratus
Feb 19, 2014

iRule not working properly

Hi,

 

Here's my virtual server,

 

 

Here's my default pool,

 

 

here's my pool members,

 

 

Then I have created following iRule and have assigned it to the virtual server.

 

when HTTP_REQUEST { if { [HTTP::uri] starts_with "/api/" } { pool API.Access } }

 

when HTTP_RESPONSE { if { [HTTP::is_redirect] } { foreach aCookieName [HTTP::cookie names] { set currentCookie "$aCookieName=[HTTP::cookie value $aCookieName]" set cookies "$cookies\r\nSet-Cookie: $currentCookie" } HTTP::respond 200 content "\ The server is trying to redirect the client to an external site, but it is forbidden" Set-Cookie $cookies } }

 

Here's the pool called API.Access

 

 

Here's it's members,

 

 

My URL looks like this,

 

http://portal.mydomain.com

 

However I want them to be redirected to the API.Access pool when the URL looks like this,

 

http://poral.mydomain.com/api/help

 

When I add my iRule, it does work for http://poral.mydomain.com/api/help but not for http://poral.mydomain.com.

 

Can you please point me in the right direction?

 

Many thanks.

 

5 Replies