Forum Discussion
Irule to modify server response
Hello All,
I have the below requirements, One virtual server (10.10.10.10:443) One pool with 20 pool members (172.16.1.X:80) Users will be accessing five different urls e.g
https://sales.example.com
https://mgmt.example.com
https://learn.example.com
https://train.example.com
https://hr.example.com
When the request comes from users to vs it should come as above but the vs should change it to the following accordingly and send it to the pool members
https://sales.example.com ------ VS----- http://int-sales.local.loc (pool members)
https://mgmt.example.com -----VS ---- http://int-mgmt.local.loc (pool members)
https://learn.example.com --- VS ---- http://int-learn.local.loc (pool members)
https://train.example.com --- VS ----- http://int-train.local.loc (pool members)
https://hr.example.com ----- VS ---- http://int-hr.local.loc (pool members)
When the vs response to the users it should retain the original urls as below
Users – https://sales.example.com ---- VS ------ http://int-sales.local.loc (pool members) VS ---- https://sales .example.com ------ client
I have tried to use the irule below,
when HTTP_REQUEST { if {[HTTP::host] equals "sales.example.com" } { set host [string map { sales.example.com int-sales.local.loc} [HTTP::host]] HTTP::redirect "https://$host[HTTP::uri]" } }
But the new url is now showing in the user browser as https://int-sales.local.loc Could you please help with the required irule to modify the server response; and if I can merge all in one irule?
1 Reply
- nitass
Employee
But the new url is now showing in the user browser as https://int-sales.local.loc
it is shown in user browser because you use HTTP::redirect. check the following article about redirect and invisible rewrite.
Redirects, Rewrites and App Transfers via iRules by Colin Walker
https://devcentral.f5.com/articles/redirects-rewrites-and-app-transfers-via-irulesif you want to rewrite embedded url in response body, you may try stream profile.
sol8115: Overview of the Stream profile
https://support.f5.com/kb/en-us/solutions/public/8000/100/sol8115.htmlhope this helps.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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