Forum Discussion

Mathew_Loesch's avatar
Mathew_Loesch
Icon for Nimbostratus rankNimbostratus
Oct 15, 2014

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_13667's avatar
    R_Eastman_13667
    Historic F5 Account

    when HTTP_RESPONSE{ HTTP::uri [string map {"/path2/file.aspx" "/path1/file.aspx"} [HTTP::uri]] }

     

  • 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]] }]

     

  • 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_13667's avatar
      R_Eastman_13667
      Historic F5 Account
      Maybe 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's avatar
    shaggy
    Icon for Nimbostratus rankNimbostratus

    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?

     

  • 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