Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

f5 irule - alternative for default required

I am new to irule creation: when HTTP_REQUEST { switch -glob [HTTP::uri] {

  "/analytics*" {
     pool abc.com-analytics-pool
  }
  "/em*" {
     pool abc.com-em-pool
  }
  "/xmlpserver*" {
     pool abc.com-analytics-pool
  }
  "/console*" {
     pool abc.com-em-pool
  }
  "/va*" {
    pool abc.com-analytics-pool
  }
   default { 
      HTTP::redirect https://[HTTP::host]/analytics/
  }

} } when HTTP_RESPONSE { if { [HTTP::is_redirect] }{ HTTP::header replace Location [string map { "http://"; "https://"; } [ HTTP::header Location]] } }

this is definition of my irule problem: when URI "va" is being called first it goes to the right place "va" then default pool is also being invoked so it ends up opening wrong page "analytics" for this I have a choice of, I check why the default is being invoked unnecessarily: I don't know how can I check that
or in my default :it covers two contion 1)when the only host is being requested so only host no URI and another URI is "/" can you please confirm how can we define in irule when no URI is requested or only slash is requested so I can remove default clause from the definition

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Your question is a bit confusing :-)

Also, per RFC the URI would include the host...

As for the default pool, I would start by configuring a default pool as part of the VIP configuration. Would that solve your problem?

0
Comments on this Answer
Comment made 19-Dec-2017 by ritika.khandelwal 11

please give me another chance to explain it: so my default pool in VIP is configured as: pool abc.com-analytics-pool --with default pool being set. if I enter URL in the browser as:https://abc.com, https://abc.com/ we want URL to open be https://abc.com/analytics so I put the code of default in irule. Now when url :https://abc.com/va is being requested
In browser Developer tool :

Request URL:https://abc.com/bi-security-login/login.jsp?redirect=L3ZhL2hvbWUuanNwP2hhc2g9ZTdYTi14aE1ZX3lCX1ZtX2pkMTYxRHJTaC12YTNYejRKdVJYR3k5RHBVSmQ0WEgyWl8tU1F1U3pJaDQ0LXAxeg== Request Method:GET Status Code:302 Found (from disk cache) Remote Address:X.X.X.X:443 Referrer Policy:no-referrer-when-downgrade

Response header

Content-Length:0 Location:https://abc.com/analytics/ Server:BigItext

so in the request header, it shows it went to correct url:https://abc.com/va but in response somehow default pool got invoked and it went on url: https://abc/com/analytics if I remove default clause from irule, it works fine. in my default I am covering two conditions as:https://abc.com & https://abc.com/ --so if you can give me the irule code where I can cover these conditions and remove default clause from the irule definition or any way to figure out why default pool is being invoked specifically in this case.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

You didn't include all the information, but it looks like the second request (to /va) was redirected to a log-in page (/bi-security-login/login.jsp).

That third request would end up on the default pool.

However, this is getting really messy. I don't know what kind of authentication the application is using, but if you authenticate on a different server than the one you end up on it is quite possible that that server will not be aware that the user is already authenticated.

You would have to provide a lot more information before the question can be answered on DevCentral...

Before getting in too far, can you explain why you have to have different pools?

0
Comments on this Answer
Comment made 29-Dec-2017 by ritika.khandelwal 11

ok, so in this case two different web pages /va & /analytics comes from the same server and same port it's just matter of string or resource like /va or /analytics so for both I am using same pool. but when a request for /va is being invoked it initially goes to the right page :bi-security login then immediately another redirection happens and then /analytics is being invoked and that page appears whereas requested was /va in browser.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

but when a request for /va is being invoked it initially goes to the right page :bi-security login then immediately another redirection happens and then /analytics is being invoked and that page appears whereas requested was /va in browser.

can you try to change the switch's default to root?

from

  default { 
    HTTP::redirect https://[HTTP::host]/analytics/
  }

to

  "/" { 
    HTTP::redirect https://[HTTP::host]/analytics/
  }
0
Comments on this Answer
Comment made 29-Dec-2017 by ritika.khandelwal 11

your provided solution worked for me as well when I removed default code with : if { [HTTP::path] equals "/" } { HTTP::redirect "/analytics/" } also worked. it worked for me but I could not get a clue why the default was the problem : if you have that understanding,request you to explain.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

I could not get a clue why the default was the problem : if you have that understanding,request you to explain.

http_request event is executed on every single http request. the /bi-security-login/... was checked and the default action was taken. that is why you got the redirection response.

rule of thumb is to make condition the most specific as possible.

0