Forum Discussion

matt1985_299432's avatar
matt1985_299432
Icon for Nimbostratus rankNimbostratus
Sep 12, 2017

Stream Content Rewrite

Hi,

I have a requirement to rewrite some content and mask this from the connecting client. I originally had this working with a re-write profile but couldn't figure out how to do other things in an IRULE with a rewrite profile.

So I have the following IRULE some content needs rewriting '/content/site' which appears to work OK however some content needs to stay as is "/content/preserve/preserve" . So when I load the page the /content/site content appears to be ok however the /content/preserve/preserve doesn't load and not sure why.... my rule is below any help appreciated..

Thanks

Matt

when HTTP_REQUEST { HTTP::path [string tolower [HTTP::path]] if {[string tolower [HTTP::uri]] starts_with "/content/preserve/preserve/"} { continue STREAM::disable } elseif {[string tolower [HTTP::uri]] starts_with "/"} { set uri [string map -nocase {"/" "/content/site/"} [HTTP::uri]] HTTP::uri $uri STREAM::disable HTTP::header remove "Accept-Encoding" } } when HTTP_RESPONSE { STREAM::disable STREAM::expression {@/content/site/@/@}

 Enable the stream filter for this response only
STREAM::enable

re-write Location header
HTTP::header replace Location [string map {/content/site/ /} [HTTP::header Location]]

}

5 Replies

  • when HTTP_REQUEST {
        HTTP::path [string tolower [HTTP::path]] 
          if {[string tolower [HTTP::uri]] starts_with "/content/preserve/preserve/"} {
           continue
           STREAM::disable
            }
        elseif {[string tolower [HTTP::uri]] starts_with "/"} {
            set uri [string map -nocase {"/" "/content/site/"} [HTTP::uri]]
            HTTP::uri $uri
            STREAM::disable
            HTTP::header remove "Accept-Encoding"
            }
    }
    when HTTP_RESPONSE {
        STREAM::disable
        STREAM::expression {@/content/site/@/@}
    
         Enable the stream filter for this response only
        STREAM::enable
    
        re-write Location header
        HTTP::header replace Location [string map {/content/site/ /} [HTTP::header Location]]
    }
    
  • Hi Matt,

     

    Did you to try configure Stream profile on Virtual Server? Instead of using i Rule

     

    • matt1985_299432's avatar
      matt1985_299432
      Icon for Nimbostratus rankNimbostratus

      Hi Thanks,

       

      I thought you needed both? I had the default stream profile and then the IRULE.

       

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Couple of questions, if you browse to content/preserve/preserve do you simply want to do nothing and is that what "continue" is in there for, in the first if statement? I'm not sure continue is a valid irule command (although i may be wrong). You could use the return or event commands instead e.g.

    event disable all

    You will probably need to enable OneConnect profile too - if you haven't already - to ensure all HTTP requests are evaluated.

    Hopefully this helps,

    N