Forum Discussion

Nova_201357's avatar
Nova_201357
Icon for Nimbostratus rankNimbostratus
Sep 28, 2017

Log Stream Substitutions

Hi,

I'm trying to help w/ moving a site to ssl only. I think I have things dialed in well enough and it looks like it's working well. As a bonus, I'd like to log the URLs that the stream matches. In other words, when I do the substitution in the HTTP_RESPONSE, is there any way to capture the greater context around the substitution so the web team knows which URLs need to be fixed (they want to use the F5 to jump start the process and fix it on the back end as time permits).

So the iRule (stolen from dev central) is like this:

 when HTTP_REQUEST {
     tell server not to compress response
    HTTP::header remove Accept-Encoding

     disable STREAM for request flow
    STREAM::disable
}
when HTTP_RESPONSE {
     catch and replace redirect headers
    if { [HTTP::header exists Location] } {
        HTTP::header replace Location [string map {"http://" "https://"} [HTTP::header Location]]
    }

     only look at text data
    if { [HTTP::header Content-Type] contains "text" } {

         create a STREAM expression to replace any http:// with https://
        STREAM::expression {@http://@https://@}

         enable STREAM
        STREAM::enable
    }
}
when STREAM_MATCHED {
    log local0. "Matched [STREAM::match]"
}

It would be a great help if in the stream_matched event, I could log something useful for the web developers.

Thanks for any input. Mike

No RepliesBe the first to reply