Forum Discussion
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/credentialmanager or https://xyzs.anc.vtc.com/credentailAPIservice so the request should get redirect to https://cm.login.abc.com -with 192.168.1.x
but I want my URL should remain the same https://xyzs.anc.vtc.com/credentialmanager or https://xyzs.anc.vtc.com/credentailAPIservice
currently, I am using redirect irule but not getting the output as required
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://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
- Aj15Altostratus
@NiKoolayy1
Yeah, the Concept of a Virtual Server Worked for me.
Thanks :)
Can you mark the question as closed, so we can close this discussion.
Can you share your irule ?
- Aj15Altostratus
Thanks for your response
Currently I am using
when HTTP_REQUEST {
if { [HTTP::host] equals "xyzs.anc.vtc.com"} {
if { [HTTP::uri] equals "/CredentialApiService" } {
HTTP::redirect "https://cm.login.abc.com"
}
elseif { [HTTP::uri] equals "CerdentialManager" } {
HTTP::redirect "https://cm.login.abc.com"
}
}
}
Requirement is when client request for https://xyz.anc.vtc.com/CredentialsApiService or /CredentialManager ,traffic must redirect toward https://cm.login.abc.com/CredentialsApiService or /CredentialManager respectively, but User must see https://xyz.anc.vtc.com(Main URL) within Browser
Note https://cm.login.abc.com is FQDN node on F5, so we don't have IP based node for mentioned URL.
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://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
Recent Discussions
Related Content
* 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