Forum Discussion
NetScaler content switching vs. F5 iRule - instream rewrite
I am migrating a configuration from NetScaler to F5. I need to replicate the content switching capability on the NetScaler with an iRule on the F5. The client sends "/path1/file.aspx" the server sees "/path2/file.aspx". I also need to reverse it on the way back out, so that the client always sees "/path1/file.aspx". The code for the inbound rewrite is easy... when HTTP_REQUEST { HTTP::uri [string map {"/path1/file.aspx" "/path2/file.aspx"} [HTTP::uri]] } How do I so the same on the outbound. I assume I have to use an HTTP_RESPONSE event, but the syntax is eluding me. Cane someone offer some assistance? Or better yet, a code example?
9 Replies
- R_Eastman_13667Historic F5 Account
when HTTP_RESPONSE{ HTTP::uri [string map {"/path2/file.aspx" "/path1/file.aspx"} [HTTP::uri]] }
- Mathew_Loesch
Nimbostratus
Unfortuately, that won't work. The LTM gives me the following error: 1070151:3: Rule [/Common/dbrewrite] error: /Common/dbrewrite:4: error: [unknown event (HTTP_RESPONSE{)][when HTTP_RESPONSE{ HTTP::uri [string map {"/path2/file.aspx" "/path1/file.aspx"} [HTTP::uri]] }]
- Mathew_Loesch
Nimbostratus
I tried that originally. Unfortunately, the HTTP_RESPONSE and the HTTP_REQUEST have totaly different command options. I cannot use an HTTP::uri in the RESPONSE event.
- R_Eastman_13667Historic F5 AccountMaybe something like this in the HTTP_RESPONSE event. Make sure to enable stream profile on the VIP. if {[HTTP::header value Content-Type] contains "text"} {STREAM::expression {@/path2/file.aspx@/path1/file.aspx@} }
- shaggy
Nimbostratus
There is no HTTP::uri object in an HTTP response since the URI is the requested resource location in a request. Are you trying to replace references to the URI in the response content or a redirect location?
- Mathew_Loesch
Nimbostratus
I am trying to reverse the HTTP_REQUEST action taken.
- Mathew_Loesch
Nimbostratus
I'll try that R Eastman and let you know what comes about... thanks.
- What_Lies_Bene1
Cirrostratus
Matthew, everything you need can be found here: https://devcentral.f5.com/questions/need-help-with-irule-masking-the-url-please
- Carl_Brothers
Employee
Rather than going the irule route, what about the new Rewrite profiles? https://support.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/ltm-concepts-11-5-0/8.htmlunique_1728863099
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