Forum Discussion
The idea is this: you're client is going to request a JavaScript-based PAC file, and you're going to attach the contents of the datagroup, where appropriate, to that file. There are at least two ways to do this:
-
Create and maintain the entire PAC file in the iRule - this is probably the easiest method, but it requires you to host the PAC content on the F5 itself. Given that most of the data is static though, this should really be an issue.
when HTTP_REQUEST { if { [HTTP::uri] equals "/proxy.pac" } { HTTP::respond 200 content $data "Content-Type" "text/javascript" } }
where $data is the content that you've dynamically built from both the static content and the datagroup-based dynamic content.
-
Use a STREAM profile to add the data group content as the PAC file flows through the proxy - this is a bit more elaborate and requires that you a) monitor for the PAC file request, and 2) attach content in a known location in that file as it passes through in the response.
when HTTP_REQUEST { STREAM::disable if { [HTTP::uri] equals "/proxy.pac" } { set rewrite 1 HTTP::header remove Accept-Encoding } } when HTTP_RESPONSE { if { [info exists rewrite] } { unset rewrite STREAM::expression "@$hook@$replace@" STREAM::enable } }
where $hook is some arbitrary content in the PAC file that you can attach to (or replace), and $replace is the dynamic datagroup-based content that you want to add.
The class get command is used to return all of the data from a datagroup as a list, so the above example extracts that data into a temporary list and then iterates over its contents.
set y ""
foreach x [class get noproxy] {
append y [lindex $x 0]
}
Each key and value inside a datagroup is going to be returned as a list itself, so the entire list will essentially be a list of lists:
{ { key value } { key value } { key value } { key value } }
The lindex command extracts the first item from each internal list (which is the key of that list).