Forum Discussion

Aj15's avatar
Aj15
Icon for Altostratus rankAltostratus
Mar 26, 2021
Solved

Need help to write irule

got confused with irule I am currently right a irule but not getting an expected output. used the concept from irule of f5 201 courses when the client makes a request on https://xyzs.anc.vtc.com/...
  • Nikoolayy1's avatar
    Nikoolayy1
    Mar 27, 2021

    I don't think it is possible for your url to remain the same after you use HTTP redirect as it is the idea HTTP redirect. Use a pool command for this and add all the nodes that are with FQDN cm.login.abc.com in that pool. See : https://clouddocs.f5.com/api/irules/pool.html

     

     

    If you want the hosts to change from cm.login.abc.com to xyzs.anc.vtc.com then but the URI to remain the same /CredentialApiService /CerdentialManager or then use HTTP redirect your irule should look like HTTP::redirect "https://cm.login.abc.com/CredentialApiService" or HTTP::redirect "https://cm.login.abc.com/CerdentialManager"

     

     

    Also I see for equals "CerdentialManager" it should be equals "/CerdentialManager" as you missed to add "/" at the start. You may also add a default pool under the VIP if you have not added one if nothing matches this pool willl andle it.

     

    Also HTTP redirect or selecting a pool based on hostname, URI or pool can be done nowadays with local traffic policy, so better use tem as they are better optimized than the iRules:

     

    https://techdocs.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/local-traffic-policies-getting-started-12-1-0/1.html

     

    https://support.f5.com/csp/article/K26312346

     

     

     

     

     

    Edit(I forgot to add):

     

    You may also test the command irule ''virtual'' for internally redirecting traffic from one vip to another vip on the same F5 device but it does not work in some cases. Search devcentral discussions about the irule ''virtual'' command:

     

    https://clouddocs.f5.com/api/irules/virtual.html

     

     

    Example discussion:

     

    https://devcentral.f5.com/s/question/0D51T00006i7kHX/irule-to-redirect-to-another-vs-on-the-same-ltm