Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

Rewrite static content response for CDN network without modifying site code

Hello! I have a delicate problem to which I have not (yet) found a working solution. I would like to test out a CDN network without modifying the site code. So I thought this simple iRule would do it for rewriting /static content location:

when HTTP_RESPONSE { HTTP::collect 1000000 }

when HTTP_RESPONSE_DATA { log "Replacing payload with new data." HTTP::payload replace 0 [HTTP::payload length] [string map {www.site.com/static cdn01.site.com/static} [HTTP::payload]] HTTP::release }

Issue is that site use relative URL:s so the host never comes in the payload = no rewrite occur.

Also tested creating a stream profile and added it to VIP to replace https://www.site.com/static with https://cdn01.site.com/static but it din't work. Any idea how to do this?

Kind regards, Orjan

0
Rate this Question
Comments on this Question
Comment made 28-Sep-2017 by Jeff Maddox

You could try doing redirects for all requests other than the initial page.

something like: when HTTP_REQUEST { if { uri not equal /} { redirect http::cdn01.site.com/...uri }

}

0
Comment made 28-Sep-2017 by Rasman 55

Thanks! That works. I would like to avoid redirects but if there's no other way this might do:

when HTTP_REQUEST { if { [HTTP::uri] starts_with "/static"} { HTTP::redirect https://cdn01.site.com[HTTP::uri] } }

Regards, Orjan

0
Comment made 28-Sep-2017 by Jeff Maddox

Yea, the only other way i see is to know all of your relative urls, and do a Stream method to insert the https::host before each one in your response. you would have to do it statically for each one.

0

Answers to this Question