aboutsummaryrefslogtreecommitdiffstats
path: root/config/varnish3
diff options
context:
space:
mode:
authorMarcello Coutinho <marcellocoutinho@gmail.com>2011-12-14 02:37:31 -0200
committermarcelloc <marcellocoutinho@gmail.com>2011-12-14 02:37:31 -0200
commit7804046877f31f93a387f331cf5bff4bbd72a415 (patch)
treebd2281a1e3f61ea9a0f14e2b09d4dde6f314b054 /config/varnish3
parent418194e1b8d251833d815acdf03f8bfd82151245 (diff)
downloadpfsense-packages-7804046877f31f93a387f331cf5bff4bbd72a415.tar.gz
pfsense-packages-7804046877f31f93a387f331cf5bff4bbd72a415.tar.bz2
pfsense-packages-7804046877f31f93a387f331cf5bff4bbd72a415.zip
varnish - change varnish-dev to varnish3 with streaming support
Diffstat (limited to 'config/varnish3')
-rw-r--r--config/varnish3/varnish.inc757
-rwxr-xr-xconfig/varnish3/varnish.widget.php126
-rw-r--r--config/varnish3/varnish_backends.xml286
-rw-r--r--config/varnish3/varnish_custom_vcl.xml142
-rw-r--r--config/varnish3/varnish_lb_directors.xml258
-rw-r--r--config/varnish3/varnish_settings.xml290
-rw-r--r--config/varnish3/varnish_sync.xml120
-rw-r--r--config/varnish3/varnish_view_config.php89
-rw-r--r--config/varnish3/varnishstat.php111
9 files changed, 2179 insertions, 0 deletions
diff --git a/config/varnish3/varnish.inc b/config/varnish3/varnish.inc
new file mode 100644
index 00000000..91d09413
--- /dev/null
+++ b/config/varnish3/varnish.inc
@@ -0,0 +1,757 @@
+<?php
+/* ========================================================================== */
+/*
+ varnish.inc
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
+ Copyright (C) 2011 Marcello Coutinho
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+
+function varnish_settings_post_validate($post, $input_errors) {
+ if($post['storagesize'] && !is_numeric($post['storagesize']))
+ $input_errors[] = "A valid number is required for the field 'Storage size'";
+ if($post['listeningport'] && !is_numeric($post['listeningport']))
+ $input_errors[] = "A valid number is required for the field 'Listening port'";
+ if($post['minworkers'] && !is_numeric($post['minworkers']))
+ $input_errors[] = "A valid number is required for the field 'Minimum worker threads'";
+ if($post['maxworkers'] && !is_numeric($post['maxworkers']))
+ $input_errors[] = "A valid number is required for the field 'Maximum worker threads'";
+ if($post['timeoutworkers'] && !is_numeric($post['timeoutworkers']))
+ $input_errors[] = "A valid number is required for the field 'Worker thread timeout'";
+ if($post['managment']){
+ $mgm= explode(":",$post['managment']);
+ if(!is_ipaddr($mgm[0]) || !is_numeric($mgm[1]))
+ $input_errors[] = "A valid ip:port is required for the field 'managment'";
+ }
+ if($post['grace'] && ! preg_match("/^\d+(h|m|s)$/",$post['grace']))
+ $input_errors[] = "A valid number with a time reference is required for the field 'Fetch grace'";
+ if($post['saint'] && ! preg_match("/^\d+(h|m|s)$/",$post['saint']))
+ $input_errors[] = "A valid number with a time reference is required for the field 'Saint mode'";
+
+}
+
+function varnish_lb_directors_post_validate($post, $input_errors) {
+ if (preg_match("/[^a-zA-Z0-9]/", $post['directorname']))
+ $input_errors[] = "The directorname name must only contain the characters a-Z or 0-9";
+ if(stristr($post['directorurl'], 'http'))
+ $input_errors[] = "You do not need to include the http:// string in the director URL";
+ if($post['grace'] && ! preg_match("/^\d+(h|m|s)$/",$post['grace']))
+ $input_errors[] = "A valid number with a time reference is required for the field 'Req grace'";
+}
+
+function varnish_backends_post_validate($post, $input_errors) {
+ if (!$post['backendname'] || preg_match("/[^a-zA-Z0-9]/", $post['backendname']))
+ $input_errors[] = "The backend name must only contain the characters a-Z or 0-9";
+ if(!is_ipaddr($post['ipaddress']))
+ $input_errors[] = "A valid IP address is required for the field 'IPAddress'";
+ if($post['first_byte_timeout'] && !is_numeric($post['first_byte_timeout']))
+ $input_errors[] = "A valid number is required for the field 'first byte timeout'";
+ if($post['connect_timeout'] && !is_numeric($post['connect_timeout']))
+ $input_errors[] = "A valid number is required for the field 'connect timeout'";
+ if($post['probe_interval'] && !is_numeric($post['probe_interval']))
+ $input_errors[] = "A valid number is required for the field 'probe interval'";
+ if($post['probe_interval'] && !is_numeric($post['probe_interval']))
+ $input_errors[] = "A valid number is required for the field 'probe interval'";
+ if($post['probe_timeout'] && !is_numeric($post['probe_timeout']))
+ $input_errors[] = "A valid number is required for the field 'probe timeout'";
+ if($post['probe_window'] && !is_numeric($post['probe_window']))
+ $input_errors[] = "A valid number is required for the field 'probe window'";
+ if($post['probe_threshold'] && !is_numeric($post['probe_threshold']))
+ $input_errors[] = "A valid number is required for the field 'probe threshold'";
+ $x=0;
+ while ($post['maptype'.$x] != ""){
+ if($post['grace'.$x] && ! preg_match("/^\d+(h|m|s)$/",$post['grace'.$x])){
+ $input_errors[] = "A valid number with a time reference is required for the field 'grace' in map ".($x +1);
+ }
+ $x++;
+
+}
+
+}
+
+function varnish_install() {
+ create_varnish_rcd_file();
+}
+
+function varnish_deinstall() {
+ create_varnish_rcd_file();
+}
+
+function text_area_decode($text){
+ return preg_replace('/\r\n/', "\n",base64_decode($text));
+}
+function varnish_start() {
+ global $g, $config;
+ if ($config['installedpackages']['varnishsettings']['config'][0]['enablevarnish']){
+ exec("chmod +x /usr/local/etc/rc.d/varnish.sh");
+ mwexec("/usr/local/etc/rc.d/varnish.sh");}
+ else{
+ exec("chmod -x /usr/local/etc/rc.d/varnish.sh");
+ mwexec("/usr/bin/killall varnishd");}
+}
+
+/* Build the URL mappings logic VCL config txt */
+function varnish_get_url_mappings_txt() {
+ global $g, $config, $urlmappings,$backends_in_use;
+ $catch_all= "unset";
+ $isfirst = true;
+ if($config['installedpackages']['varnishlbdirectors']['config'] != "") {
+ foreach($config['installedpackages']['varnishlbdirectors']['config'] as $url) {
+ #check options
+ $directo_grace_time="";
+ if ($url['customapping'])
+ $directo_grace_time.=text_area_decode($url['customapping'])."\n\t\t";
+ if($url['grace'])
+ $directo_grace_time.=($url['grace']=="0s"?"return(pass);":"set req.grace=".$url['grace'].";");
+ $fieldtype = ($url['fieldtype']?$url['fieldtype']:"==");
+ $req=($url['directorurl2']?"url":"http.host");
+ $director_prefix=($url['directorurl'] && $url['directorurl2']?"^http://":"");
+ #check url
+ if ( $url['directorurl'] || $url['directorurl2'] || $catch_all == "unset" ){
+ if ( $url['directorurl']== "" && $url['directorurl2']== "" ){
+ #director with no host or url, so director for catch all traffic not specified in config
+ $lasturlmappings = "\telse\t{\n\t\tset req.backend = ".$url['directorname'].";\n\t\t}\n";
+ $catch_all = "set";
+ $isfirst = false;
+ }
+ else{
+ if(!$isfirst)
+ $urlmappings .= "\telse ";
+ $urlmappings .= "if (req.$req $fieldtype ".'"'.$url['directorurl'].$url['directorurl2'].'") {'."\n";
+ #check failover
+ $urlbackend = "\t\t\tset req.backend = ".$url['directorname'].";";
+ if ($url['failover'] && $url['failover'] != $url['directorname']){
+ $tabs=($url['grace']?"\n\t\t\t":"");
+ $urlfailover = "\t\t\tset req.backend = ".$url['failover'].";";
+ $urlmappings .= "\t\tif (req.restarts == 0) {\n".$urlbackend.$tabs.$directo_grace_time.$tabs."}";
+ $urlmappings .= "\n\t\telse\t{\n".$urlfailover.$tabs.$directo_grace_time.$tabs."}\n\t\t}\n";
+ $isfirst = false;
+ }
+ else{
+ $tabs=($url['grace']?"\n\t\t":"");
+ $urlmappings .= $urlbackend.$tabs.$directo_grace_time."\n\t\t}\n";
+ $isfirst = false;
+ }
+ }
+ }
+ }
+ }
+ if($config['installedpackages']['varnishbackends']['config'])
+ foreach($config['installedpackages']['varnishbackends']['config'] as $urlmapping) {
+ if($urlmapping['row'])
+ foreach($urlmapping['row'] as $url) {
+ $directo_grace_time="";
+ if($url['grace'])
+ $directo_grace_time=($url['grace']=="0s"?"\n\t\t return(pass);":"\n\t\tset req.grace=".$url['grace'].";");
+ $req=($url['maptype']?$url['maptype']:"http.host");
+ $fieldtype=($url['fieldtype']?$url['fieldtype']:"==");
+ if ($url['urlmapping'] != "" || $catch_all == 'unset'){
+ if($url['urlmapping'] == ""){
+ $catch_all = "set";
+ $lasturlmappings = "\telse\t{\n\t\tset req.backend = ".$urlmapping['backendname']."BACKEND;\n\t\t}\n";
+ }
+ else{
+ if(!$isfirst)
+ $urlmappings .= "\telse ";
+ $urlmappings .= <<<EOAU
+if (req.{$req} {$fieldtype} "{$url['urlmapping']}") {
+ set req.backend = {$urlmapping['backendname']}BACKEND;{$directo_grace_time}
+ }
+
+EOAU;
+ }
+ $backends_in_use[$urlmapping['backendname']].=($url['directorurl'] == ""?"catch_all ":"url_map ");
+ $isfirst = false;
+ }
+ }
+ }
+
+ return $urlmappings.$lasturlmappings;
+}
+
+function create_varnish_rcd_file() {
+ global $config, $g;
+ if($config['installedpackages']['varnishsettings']['config'] != "") {
+ foreach($config['installedpackages']['varnishsettings']['config'] as $vs) {
+ if($vs['storagetype'] == "malloc")
+ $storage_type = "-s malloc,{$vs['storagesize']}MB";
+ else
+ $storage_type = "-s file,/var/varnish/storage.bin,{$vs['storagesize']}MB";
+ if($vs['listeningport'])
+ $listeningport = "-a :{$vs['listeningport']}";
+ else
+ $listeningport = "-a :80";
+ if($vs['managment'])
+ $advancedstartup = "-T {$vs['managment']} ";
+ else
+ $advancedstartup = "";
+ if($vs['advancedstartup'])
+ $advancedstartup .= text_area_decode($vs['advancedstartup'])."\n";
+ if($vs['minworkers'])
+ $minworkers = "{$vs['minworkers']}";
+ else
+ $minworkers = "200";
+ if($vs['maxworkers'])
+ $maxworkers = "{$vs['maxworkers']}";
+ else
+ $maxworkers = "4000";
+ if($vs['timeoutworkers'])
+ $timeoutworkers = "{$vs['timeoutworkers']}";
+ else
+ $timeoutworkers = "50";
+ }
+ }
+ $fd = fopen("/usr/local/etc/rc.d/varnish.sh", "w");
+ $rc_file = <<<EOF
+#!/bin/sh
+mkdir -p /var/varnish
+rm /var/varnish/storage.bin 2>/dev/null
+killall varnishd 2>/dev/null
+sleep 1
+sysctl kern.ipc.nmbclusters=65536
+sysctl kern.ipc.somaxconn=16384
+sysctl kern.maxfiles=131072
+sysctl kern.maxfilesperproc=104856
+sysctl kern.threads.max_threads_per_proc=4096
+/usr/bin/env \
+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
+/usr/local/bin/php -q -d auto_prepend_file=config.inc <<ENDOFF
+<?php
+ require_once("globals.inc");
+ require_once("functions.inc");
+ require_once("pkg-utils.inc");
+ require_once("varnish.inc");
+ sync_package_varnish();
+ #varnish_start();
+
+?>
+ENDOFF
+
+/usr/local/sbin/varnishd \
+ {$listeningport} \
+ -f /var/etc/default.vcl \
+ {$storage_type} \
+ -w {$minworkers},{$maxworkers},{$timeoutworkers} \
+ {$advancedstartup}
+
+EOF;
+
+ fwrite($fd, $rc_file);
+ fclose($fd);
+ exec("chmod a+rx /usr/local/etc/rc.d/varnish.sh");
+}
+
+function get_backend_config_txt() {
+ global $config, $g, $backends_in_use;
+ $backends="";
+ if($config['installedpackages']['varnishbackends']['config'] != "") {
+ foreach($config['installedpackages']['varnishbackends']['config'] as $backend) {
+ if($backend['connect_timeout'])
+ $connect_timeout = $backend['connect_timeout'] . "s";
+ else
+ $connect_timeout = "25s";
+ if($backend['port'])
+ $connect_port = $backend['port'];
+ else
+ $connect_port = "80";
+ if($backend['first_byte_timeout'])
+ $first_byte_timeout = $backend['first_byte_timeout'] . "s";
+ else
+ $first_byte_timeout = "300s";
+ if($backend['probe_url'])
+ if (preg_match("@^(http)://([a-zA-Z0-9.-]*)/(.*)$@",$backend['probe_url'],$matches)){
+ $probe_url=".request =\n";
+ $probe_url.="\t\t\t".'"GET /'.$matches[3].' HTTP/1.1"'."\n";
+ $probe_url.="\t\t\t".'"Accept: text/*"'."\n";
+ $probe_url.="\t\t\t".'"User-Agent: Varnish"'."\n";
+ $probe_url.="\t\t\t".'"Host: '.$matches[2].'"'."\n";
+ $probe_url.="\t\t\t".'"Connection: Close";';
+ }
+ else{
+ $probe_url = '.url = "'.$backend['probe_url'].'";';
+ }
+ else
+ $probe_url ='.url = "/";';
+ if($backend['probe_interval'])
+ $probe_interval = $backend['probe_interval'] . "s";
+ else
+ $probe_interval = "1s";
+ if($backend['probe_timeout'])
+ $probe_timeout = $backend['probe_timeout'] . "s";
+ else
+ $probe_timeout = "1s";
+ if($backend['probe_window'])
+ $probe_window = $backend['probe_window'];
+ else
+ $probe_window = "5";
+ if($backend['probe_threshold'])
+ $probe_threshold = $backend['probe_threshold'];
+ else
+ $probe_threshold = "5";
+ if (isset($probe_threshold)){
+ #last parameter set ,so write conf if backend is in use
+ if ($backends_in_use[$backend['backendname']] != ""){
+ $backends .= <<<EOFA
+
+backend {$backend['backendname']}BACKEND {
+ # used in {$backends_in_use[$backend['backendname']]}
+ .host = "{$backend['ipaddress']}";
+ .port = "{$backend['port']}";
+ .first_byte_timeout = {$first_byte_timeout};
+ .connect_timeout = {$connect_timeout};
+ .probe = {
+ {$probe_url}
+ .interval = {$probe_interval};
+ .timeout = {$probe_timeout};
+ .window = {$probe_window};
+ .threshold = {$probe_threshold};
+ }
+}
+
+
+EOFA;
+ }
+ else {
+ $backends .= "\n".'# backend '.$backend['backendname']." not in use.\n";
+ }
+ }
+ }
+ }
+ return $backends;
+}
+
+function get_lb_directors_config_txt() {
+ global $config, $g, $backends_in_use;
+ $backends="";
+ if($config['installedpackages']['varnishlbdirectors']['config'] != "") {
+ foreach($config['installedpackages']['varnishlbdirectors']['config'] as $backend) {
+ $director = "";
+ if($backend['directortype'] == "round-robin" ){$weight=" ";}
+ if($backend['row']){
+ foreach($backend['row'] as $be) {
+ if($be['weight'] && $weight != " ")
+ $weight = "\t\t.weight = {$be['weight']};\n";
+ elseif($weight != " ")
+ $weight = "\t\t.weight = 100;\n";
+
+ $director .= "\t{\n\t\t.backend = {$be['backendname']}BACKEND;\n{$weight}\t}";
+ $backends_in_use[$be['backendname']].= $backend['directorname']." ";
+ }
+ $backends .= <<<EOFA
+director {$backend['directorname']} {$backend['directortype']} {
+{$director}
+}
+
+
+EOFA;
+
+ }
+ }
+ }
+ return $backends;
+}
+
+function sync_package_varnish() {
+ global $config, $g;
+ if($config['installedpackages']['varnishcustomvcl']['config'] != "") {
+ foreach($config['installedpackages']['varnishcustomvcl']['config'] as $vcl) {
+ if($vcl['vcl_recv_early'])
+ $vcl_recv_early = text_area_decode($vcl['vcl_recv_early']);
+ if($vcl['vcl_recv_late'])
+ $vcl_recv_late = text_area_decode($vcl['vcl_recv_late']);
+ if($vcl['vcl_fetch_early'])
+ $vcl_fetch_early = text_area_decode($vcl['vcl_fetch_early']);
+ if($vcl['vcl_fetch_late'])
+ $vcl_fetch_late = text_area_decode($vcl['vcl_fetch_late']);
+ if($vcl['vcl_pipe_early'])
+ $vcl_pipe_early = text_area_decode($vcl['vcl_pipe_early']);
+ if($vcl['vcl_pipe_late'])
+ $vcl_pipe_late = text_area_decode($vcl['vcl_pipe_late']);
+ }
+ }
+ $vcl_recv_set_basic='#BASIC VCL RULES SETTING'."\n";
+ $vcl_recv_action_basic='#BASIC VCL RULES ACTIONS'."\n";
+ #$plataform=posix_uname();
+ foreach($config['installedpackages']['varnishsettings']['config'] as $vcl) {
+ if($vcl['streaming']){
+ $vcl_fetch_stream="set beresp.do_stream = true;\n";
+ }
+ if($vcl['fixgzip']){
+ $vcl_recv_set_basic.="\t#Fix gzip compression\n";
+ $vcl_recv_set_basic.="\t".'if (req.http.Accept-Encoding) {'."\n";
+ $vcl_recv_set_basic.="\t".'if (req.url ~ "\.(gif|jpg|jpeg|bmp|png|ico|img|tga|wmf|gz|tgz|bz2|tbz|mp3|ogg)$") {'."\n\t\tunset req.http.Accept-Encoding;\n\t\t}\n";
+ $vcl_recv_set_basic.="\t".'else if (req.http.Accept-Encoding ~ "gzip") {'."\n\t\tset req.http.Accept-Encoding = ".'"gzip"'.";\n\t\t}\n";
+ $vcl_recv_set_basic.="\t".'else if (req.http.Accept-Encoding ~ "deflate") {'."\n\t\tset req.http.Accept-Encoding = ".'"deflate"'.";\n\t\t}\n";
+ $vcl_recv_set_basic.="\telse\t{\n\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\n";
+ }
+ #if($vcl['clientbalance'] && $plataform['machine'] == 'amd64'){
+ $vcl_recv_set_basic.="\t#set client balance identity\n";
+ switch ($vcl['clientbalance']){
+ case 'url':
+ $vcl_recv_set_basic.="\t".'set client.identity = req.url;'."\n\n";
+ break;
+ case 'ip':
+ $vcl_recv_set_basic.="\t".'set client.identity = client.ip;'."\n\n";
+ break;
+ case 'agent':
+ $vcl_recv_set_basic.="\t".'set client.identity = req.http.user-agent;'."\n\n";
+ break;
+ }
+ #}
+ if($vcl['grace'] ){
+ $vcl_grace_time="set beresp.grace = ".$vcl['grace'].";\n\t\t";
+ }
+ if($vcl['saint'] ){
+ $vcl_saint_mode="set beresp.saintmode = ".$vcl['saint'].";\n\t\t";
+ }
+ if($vcl['xforward']){
+ $vcl_recv_set_basic.="\t#set X-forward\n";
+ switch ($vcl['xforward']){
+ case 'set':
+ $vcl_recv_set_basic.="\t".'set req.http.X-Forwarded-For = client.ip;'."\n\n";
+ break;
+ case 'append':
+ $vcl_recv_set_basic.="\t".'set req.http.X-Forwarded-For = req.http.X-Forwarded-For "," client.ip;'."\n\n";
+ break;
+ case 'create':
+ $vcl_recv_set_basic.="\t".'set req.http.X-Forwarded-Varnish = client.ip;'."\n\n";
+ break;
+ case 'unset':
+ $vcl_recv_set_basic.="\t".'unset req.http.X-Forwarded-For;'."\n\n";
+ break;
+ }
+ }
+ if($vcl['postcache']){
+ $vcl_recv_action_basic.="\t#Disable post cache\n";
+ $vcl_recv_action_basic.="\t".'if (req.request == "POST") {'."\n\t\treturn(pass);\n\t\t}\n";
+ }
+
+ $vcl_fetch_session ="#Disable cache when backend is starting a session\n";
+ $vcl_fetch_session.="\t".'if (beresp.http.Set-Cookie && beresp.http.Set-Cookie ~ "(PHPSESSID|phpsessid)") {'."\n\t\treturn(hit_for_pass);\n\t\t}\n";
+ $vcl_fetch_session.="\t".'if (beresp.http.Set-Cookie && beresp.http.Set-Cookie ~ "(JSESSION|jsession)") {'."\n\t\treturn(hit_for_pass);\n\t\t}\n";
+
+ if($vcl['sessioncache']== "never"){
+ $vcl_recv_session ="\t#Disable session cache\n";
+ $vcl_recv_session.="\t".'if (req.http.Cookie && req.http.Cookie ~ "(PHPSESSID|phpsessid)") {'."\n\t\treturn(pass);\n\t\t}\n";
+ $vcl_recv_session.="\t".'if (req.http.Cookie && req.http.Cookie ~ "(JSESSION|jsession)") {'."\n\t\treturn(pass);\n\t\t}\n";
+ $vcl_recv_session.="\t".'if (req.http.X-Requested-With == "XMLHttpRequest" || req.url ~ "nocache") {'."\n\t\treturn(pass);\n\t\t}\n";
+ $vcl_fetch_session.="\t".'if (beresp.http.X-Requested-With == "XMLHttpRequest" || req.url ~ "nocache") {'."\n\t\treturn(hit_for_pass);\n\t\t}\n";
+ $vcl_recv_static_prefix=($vcl['staticache']=="no"?"":"\n\t\tunset req.http.cookie;");
+ }
+ else
+ {
+ $vcl_hash = "#Enable Per user session cache.\n";
+ $vcl_hash.= "sub vcl_hash {\n\thash_data(req.http.cookie);\n}\n";
+ }
+ #set static content var
+ $vcl_recv_static_sufix=($vcl['staticache']=='no'?"pass":"lookup");
+ $vcl_recv_static ="\t#Enable static cache\n";
+ $vcl_recv_static.="\t".'if (req.request=="GET" && req.url ~ "\.(css|js|txt|zip|pdf|rtf|flv|swf|html|htm)$") {'.$vcl_recv_static_prefix."\n\t\treturn($vcl_recv_static_sufix);\n\t\t}\n";
+ $vcl_recv_static.="\t".'if (req.request=="GET" && req.url ~ "\.(gif|jpg|jpeg|bmp|png|ico|img|tga|wmf|mp3|ogg)$") {'.$vcl_recv_static_prefix."\n\t\treturn($vcl_recv_static_sufix);\n\t\t}\n";
+ $vcl_fetch_static ="#Enable static cache\n";
+ $vcl_fetch_static.='if (req.url ~ "\.(css|js|txt|zip|pdf|rtf|flv|swf|html|htm)$") {'."\n\tunset beresp.http.set-cookie;\n\t}\n";
+ $vcl_fetch_static.='if (req.url ~ "\.(gif|jpg|jpeg|bmp|png|ico|img|tga|wmf|mp3|ogg)$") {'."\n\tunset beresp.http.set-cookie;\n\t}\n";
+
+ switch ($vcl['staticache']){
+ case "all":
+ # cache all static content, unseting cookie when present
+ $vcl_recv_action_basic.=($vcl['sessioncache']=="never"?$vcl_recv_static.$vcl_recv_session:$vcl_recv_static);
+ $vcl_fetch_action=($vcl['sessioncache']=="never"?$vcl_fetch_static.$vcl_fetch_session:$vcl_fetch_static);
+ break;
+ case "yes":
+ # cache only object without cookie set
+ $vcl_recv_action_basic.=($vcl['sessioncache']=="never"?$vcl_recv_session.$vcl_recv_static:$vcl_recv_static);
+ $vcl_fetch_action=$vcl_fetch_session;
+ break;
+ default:
+ # no static cache at all
+ $vcl_recv_action_basic.=$vcl_recv_static.$vcl_recv_session;
+ $vcl_fetch_action=$vcl_fetch_session;
+ }
+
+ if($vcl['rfc2616']){
+ $vcl_recv_action_basic.="\t#Be rfc2616 compliant\n";
+ $vcl_recv_action_basic.="\t".'if (req.request ~ "^(GET|HEAD|PUT|POST|TRACE|OPTIONS|DELETE)$") {'."\n\t\treturn(lookup);\n\t\t}\n\telse\t{\n\t\treturn(pipe);\n\t\t}\n";
+ #$vcl_recv_action_basic.="\t".'if (req.request != "GET" && req.request != "HEAD" && req.request != "PUT" && reqa.request != "POST" &&'."\n";
+ #$vcl_recv_action_basic.="\t".' req.request != "TRACE" && req.request != "OPTIONS" && req.request != "DELETE") {return(pipe);}'."\n\n";
+ }
+ else {
+ $vcl_recv_action_basic.="\t".'if (req.request != "GET" && req.request != "HEAD") {return(pipe);}'."\n";
+ }
+ if($vcl['restarts']){
+ $vcl_restarts=$vcl['restarts'];
+ }
+ if($vcl['htmlerror']){
+ $errorvcl=text_area_decode($vcl['htmlerror']);
+ }
+ }
+
+ if(!$errorvcl)
+ $errorvcl = <<<EOF
+<html>
+<head>
+<title>"} + obj.status + " " + obj.response + {"</title>
+</head>
+<body>
+<h1>Error "} + obj.status + " " + obj.response + {"</h1>
+<p>"} + obj.response + {"</p>
+<h3>Guru Meditation:</h3>
+<p>XID: "} + req.xid + {"</p>
+<hr>
+<p>Varnish cache server</p>
+</body>
+138 </html>
+EOF;
+
+/* Grab configuration txt blocks */
+/* Please keep this sequence to determine witch backends are in use */
+$backends_in_use=array();
+$lb_config= get_lb_directors_config_txt();
+$urlmappings = varnish_get_url_mappings_txt();
+$backends = get_backend_config_txt() . $lb_config ;
+#$backends .= get_lb_directors_config_txt();
+
+
+/* Start to build varnish default.vcl configurationf file */
+$varnish_config_file = <<<EOF
+# Varnish configuration file
+# Automatically generated by the pfSense package system
+
+# This file is located in /var/etc/default.vcl
+
+sub vcl_error {
+ if (obj.status == 503 && req.restarts < {$vcl_restarts}) {
+ return(restart);
+ }
+
+ set obj.http.Content-Type = "text/html; charset=utf-8";
+ synthetic {"<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+{$errorvcl}"};
+ return(deliver);
+
+}
+
+{$backends}
+{$vcl_hash}
+sub vcl_recv {
+ {$vcl_recv_early}
+ {$vcl_recv_set_basic}
+ {$urlmappings}
+ {$vcl_recv_late}
+ #respect client wish to refresh the page
+ if (req.http.Pragma ~ "no-cache")
+ {
+ return(pass);
+ }
+
+ {$vcl_recv_action_basic}
+ return(lookup);
+}
+
+sub vcl_pipe {
+ {$vcl_pipe_early}
+ # If we don't set the Connection: close header, any following
+ # requests from the client will also be piped through and
+ # left untouched by varnish. We don't want that.
+ set req.http.connection = "close";
+ # Note: no "pipe" action here - we'll fall back to the default
+ # pipe method so that when any changes are made there, we
+ # still inherit them.
+ {$vcl_pipe_late}
+}
+sub vcl_hit {
+ return (deliver);
+}
+
+sub vcl_miss {
+ return (fetch);
+}
+
+sub vcl_fetch {
+ {$vcl_fetch_stream}{$vcl_fetch_early}
+ {$vcl_fetch_action}
+ # Varnish respects the wishes of the backend application.
+ if (beresp.http.Pragma ~ "no-cache" || beresp.http.Cache-Control ~ "(no-cache|no-store|private)") {
+ return(hit_for_pass);
+ }
+ ## If the request to the backend returns a code other than 200, restart the loop
+ ## If the number of restarts reaches the value of the parameter max_restarts,
+ ## the request will be error'ed. max_restarts defaults to 4. This prevents
+ ## an eternal loop in the event that, e.g., the object does not exist at all.
+ if (beresp.status != 200 && beresp.status != 403 && beresp.status != 404 &&
+ beresp.status != 303 && beresp.status != 302 && beresp.status != 301 && beresp.status != 401 ) {
+ {$vcl_saint_mode}return(restart);
+ }
+
+
+ {$vcl_fetch_late}
+ {$vcl_grace_time}return(deliver);
+}
+
+sub vcl_deliver {
+ ##set resp.http.X-Served-By = server.hostname;
+ if (obj.hits > 0) {
+ set resp.http.X-Cache = "HIT";
+ set resp.http.X-Cache-Hits = obj.hits;
+ } else {
+ set resp.http.X-Cache = "MISS";
+ }
+ return(deliver);
+}
+
+sub vcl_init {
+ return (ok);
+}
+
+sub vcl_fini {
+ return (ok);
+}
+
+EOF;
+
+ $fd = fopen("/var/etc/default.vcl", "w");
+ fwrite($fd, $varnish_config_file);
+ fclose($fd);
+
+ varnish_sync_on_changes();
+}
+
+/* Uses XMLRPC to synchronize the changes to a remote node */
+function varnish_sync_on_changes() {
+ global $config, $g;
+ log_error("[varnish] varnish_xmlrpc_sync.php is starting.");
+ $synconchanges = $config['installedpackages']['varnishsync']['config'][0]['synconchanges'];
+ if(!$synconchanges)
+ return;
+ foreach ($config['installedpackages']['varnishsync']['config'] as $rs ){
+ foreach($rs['row'] as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $password = $sh['password'];
+ if($password && $sync_to_ip)
+ varnish_do_xmlrpc_sync($sync_to_ip, $password);
+ }
+ }
+ log_error("[varnish] varnish_xmlrpc_sync.php is ending.");
+}
+/* Do the actual XMLRPC sync */
+function varnish_do_xmlrpc_sync($sync_to_ip, $password) {
+ global $config, $g;
+
+ if(!$password)
+ return;
+
+ if(!$sync_to_ip)
+ return;
+
+ $xmlrpc_sync_neighbor = $sync_to_ip;
+ if($config['system']['webgui']['protocol'] != "") {
+ $synchronizetoip = $config['system']['webgui']['protocol'];
+ $synchronizetoip .= "://";
+ }
+ $port = $config['system']['webgui']['port'];
+ /* if port is empty lets rely on the protocol selection */
+ if($port == "") {
+ if($config['system']['webgui']['protocol'] == "http")
+ $port = "80";
+ else
+ $port = "443";
+ }
+ $synchronizetoip .= $sync_to_ip;
+
+ /* xml will hold the sections to sync */
+ $xml = array();
+ $xml['varnishcustomvcl'] = $config['installedpackages']['varnishcustomvcl'];
+ $xml['varnishbackends'] = $config['installedpackages']['varnishbackends'];
+ $xml['varnishlbdirectors'] = $config['installedpackages']['varnishlbdirectors'];
+ $xml['varnishsettings'] = $config['installedpackages']['varnishsettings'];
+
+ /* assemble xmlrpc payload */
+ $params = array(
+ XML_RPC_encode($password),
+ XML_RPC_encode($xml)
+ );
+
+ /* set a few variables needed for sync code borrowed from filter.inc */
+ $url = $synchronizetoip;
+ log_error("Beginning Varnish XMLRPC sync to {$url}:{$port}.");
+ $method = 'pfsense.merge_installedpackages_section_xmlrpc';
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials('admin', $password);
+ if($g['debug'])
+ $cli->setDebug(1);
+ /* send our XMLRPC message and timeout after 250 seconds */
+ $resp = $cli->send($msg, "250");
+ if(!$resp) {
+ $error = "A communications error occurred while attempting varnish XMLRPC sync with {$url}:{$port}.";
+ log_error($error);
+ file_notice("sync_settings", $error, "varnish Settings Sync", "");
+ } elseif($resp->faultCode()) {
+ $cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ $error = "An error code was received while attempting varnish XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("sync_settings", $error, "varnish Settings Sync", "");
+ } else {
+ log_error("varnish XMLRPC sync successfully completed with {$url}:{$port}.");
+ }
+
+ /* tell varnish to reload our settings on the destionation sync host. */
+ $method = 'pfsense.exec_php';
+ $execcmd = "require_once('/usr/local/pkg/varnish.inc');\n";
+ $execcmd .= "sync_package_varnish();\nvarnish_start();";
+ /* assemble xmlrpc payload */
+ $params = array(
+ XML_RPC_encode($password),
+ XML_RPC_encode($execcmd)
+ );
+
+ log_error("varnish XMLRPC reload data {$url}:{$port}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials('admin', $password);
+ $resp = $cli->send($msg, "250");
+ if(!$resp) {
+ $error = "A communications error occurred while attempting varnish XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
+ log_error($error);
+ file_notice("sync_settings", $error, "varnish Settings Sync", "");
+ } elseif($resp->faultCode()) {
+ $cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ $error = "An error code was received while attempting varnish XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("sync_settings", $error, "varnish Settings Sync", "");
+ } else {
+ log_error("varnish XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
+ }
+
+}
+
+?>
diff --git a/config/varnish3/varnish.widget.php b/config/varnish3/varnish.widget.php
new file mode 100755
index 00000000..f2b68aec
--- /dev/null
+++ b/config/varnish3/varnish.widget.php
@@ -0,0 +1,126 @@
+<?php
+/*
+ Copyright 2011 Thomas Schaefer - Tomschaefer.org
+ Copyright 2011 Marcello Coutinho
+ Part of pfSense widgets (www.pfsense.com)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+@require_once("guiconfig.inc");
+@require_once("pfsense-utils.inc");
+@require_once("functions.inc");
+function open_table(){
+ echo "<table style=\"padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
+ echo" <tr>";
+}
+function close_table(){
+ echo" </tr>";
+ echo"</table>";
+ echo "<br>";
+}
+
+$pfb_table=array();
+$img['Sick']="<img src ='/themes/{$g['theme']}/images/icons/icon_interface_down.gif'>";
+$img['Healthy']="<img src ='/themes/{$g['theme']}/images/icons/icon_interface_up.gif'>";
+
+
+#var_dump($pfb_table);
+#exit;
+?><div id='varnish'><?php
+open_table();
+
+if ($config['installedpackages']['varnishsettings']['config'][0])
+ $mgm=$config['installedpackages']['varnishsettings']['config'][0]['managment'];
+if ($mgm != ""){
+ print "<pre>";
+ print "<td class=\"vncellt\"width=30%><strong>Cache hits</strong></td>";
+ print "<td class=\"vncellt\"width=30%><strong>Cache hits pass</strong></td>";
+ print "<td class=\"vncellt\"width=30%><strong>Cache Missed</strong></td></tr>";
+
+ $backends=exec("varnishadm -T " . escapeshellarg($mgm) . " stats",$debug);
+ foreach ($debug as $line){
+ if (preg_match("/(\d+)\s+Cache\s+(hits.for|hits|misses)/",$line,$matches))
+ $cache[preg_replace("/\s+/","",$matches[2])]=$matches[1];
+ if (preg_match("/(\d+)\s+Client\s+(\w+)/",$line,$matches))
+ $client[$matches[2]]=$matches[1];
+ }
+ print "<td class=\"listlr\">".$cache['hits'] ."</td>";
+ print "<td class=\"listlr\">".$cache['hitsfor'] ."</td>";
+ print "<td class=\"listlr\">".$cache['misses']."</td></tr>";
+ close_table();
+
+ open_table();
+ print "<td class=\"vncellt\" width=30%><strong>Conn. Accepted</strong></td>";
+ print "<td class=\"vncellt\" width=30%><strong>Req. received</strong></td>";
+ print "<td class=\"vncellt\" width=30%><strong>Uptime</strong></td></tr>";
+ print "<td class=\"listlr\">".$client['connections'] ."</td>";
+ print "<td class=\"listlr\">".$client['requests'] ."</td>";
+ print "<td class=\"listlr\">".$client['uptime']."</td></tr>";
+ close_table();
+
+ open_table();
+ print "<td class=\"vncellt\" width=30%><strong>Backend</strong></td>";
+ print "<td class=\"vncellt\" width=30%><strong>LB applied</strong></td>";
+ print "<td class=\"vncellt\" width=30%><strong>Status</strong></td></tr>";
+ if (is_array($config['installedpackages']['varnishlbdirectors']['config']))
+ foreach($config['installedpackages']['varnishlbdirectors']['config'] as $lb){
+ foreach ($lb['row'] as $lb_backend){
+ ${$lb_backend['backendname']}++;
+ }
+ }
+ $backends=exec("varnishadm -T " . escapeshellarg($mgm) . " debug.health",$debug);
+ foreach ($debug as $line){
+ if (preg_match("/Backend (.*) is (\w+)/",$line,$matches)){
+ $backend=preg_replace("/BACKEND$/","",$matches[1]);
+ print "<td class=\"listlr\">". $backend ."</td>";
+ print "<td class=\"listlr\">". ${$backend} ."</td>";
+ print "<td class=\"listlr\">".$img[$matches[2]]."</td></tr>";
+ }
+ }
+ }
+else{
+ print "<td class=\"listlr\">Varnish Managment interface not set in config.</td></tr>";
+}
+echo" </tr>";
+echo"</table></div>";
+
+?>
+<script type="text/javascript">
+ function getstatus_varnish() {
+ scroll(0,0);
+ var url = "/widgets/widgets/varnish.widget.php";
+ var pars = 'getupdatestatus=yes';
+ var myAjax = new Ajax.Request(
+ url,
+ {
+ method: 'get',
+ parameters: pars,
+ onComplete: activitycallback_varnish
+ });
+ //I know it's ugly but works.
+ setTimeout('getstatus_varnish()', 10000);
+ }
+ function activitycallback_varnish(transport) {
+ $('varnish').innerHTML = transport.responseText;
+ }
+ getstatus_varnish();
+</script>
diff --git a/config/varnish3/varnish_backends.xml b/config/varnish3/varnish_backends.xml
new file mode 100644
index 00000000..d9597dd3
--- /dev/null
+++ b/config/varnish3/varnish_backends.xml
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* ========================================================================== */
+/*
+ varnish_backends.xml
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
+ Copyright (C) 2011 Marcello Coutinho
+ All rights reserved.
+*/
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>varnishbackends</name>
+ <version>0.0.5</version>
+ <title>Varnish: Backends</title>
+ <include_file>/usr/local/pkg/varnish.inc</include_file>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnish_lb_directors.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnish_settings.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnish_custom_vcl.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/widgets/widgets</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnish.widget.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnish.inc</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnish_sync.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnish_view_config.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnishstat.php</item>
+ </additional_files_needed>
+ <menu>
+ <name>Varnish</name>
+ <tooltiptext>Varnish</tooltiptext>
+ <section>Services</section>
+ <configfile>varnish_backends.xml</configfile>
+ </menu>
+ <service>
+ <name>varnish</name>
+ <rcfile>varnish.sh</rcfile>
+ <executable>varnishd</executable>
+ <description>Varnish HTTP accelerator</description>
+ </service>
+ <tabs>
+ <tab>
+ <text>Backends</text>
+ <url>/pkg.php?xml=varnish_backends.xml</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=varnish_settings.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Custom VCL</text>
+ <url>/pkg_edit.php?xml=varnish_custom_vcl.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>LB Directors</text>
+ <url>/pkg.php?xml=varnish_lb_directors.xml</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=varnish_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>View Configuration</text>
+ <url>/varnish_view_config.php</url>
+ </tab>
+ <tab>
+ <text>VarnishSTAT</text>
+ <url>/varnishstat.php</url>
+ </tab>
+ </tabs>
+ <adddeleteeditpagefields>
+ <columnitem>
+ <fielddescr>IPAddress</fielddescr>
+ <fieldname>ipaddress</fieldname>
+ </columnitem>
+ <columnitem>
+ <fielddescr>Name</fielddescr>
+ <fieldname>backendname</fieldname>
+ </columnitem>
+ </adddeleteeditpagefields>
+ <fields>
+ <field>
+ <fielddescr>BackendSettings</fielddescr>
+ <fieldname>BackendSettings</fieldname>
+ <type>listtopic</type>
+ <name>Backend settings</name>
+ </field>
+ <field>
+ <fielddescr>Backend name</fielddescr>
+ <fieldname>backendname</fieldname>
+ <description>Enter the name of this backend web server.</description>
+ <type>input</type>
+ <validate>^[a-z0-9.|-]+$</validate>
+ </field>
+ <field>
+ <fielddescr>IPAddress</fielddescr>
+ <fieldname>ipaddress</fieldname>
+ <description>Enter the IP Address of the backend web server.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Port</fielddescr>
+ <fieldname>port</fieldname>
+ <description>Enter the TCP/IP port of the webserver.</description>
+ <type>input</type>
+ <validate>^[0-9]+$</validate>
+ </field>
+ <field>
+ <fielddescr>PerformanceMetrics</fielddescr>
+ <fieldname>PerformanceMetrics</fieldname>
+ <type>listtopic</type>
+ <name>Performance metrics</name>
+ </field>
+ <field>
+ <fielddescr>First byte timeout</fielddescr>
+ <fieldname>first_byte_timeout</fieldname>
+ <description> time to wait for the first byte from the backend and .between_bytes_timeout for time to wait between each received byte.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Connect timeout</fielddescr>
+ <fieldname>connect_timeout</fieldname>
+ <description>The time to wait for a backend connection.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>ProbeInfo</fielddescr>
+ <fieldname>ProbeInfo</fieldname>
+ <type>listtopic</type>
+ <name>Probe settings</name>
+ </field>
+ <field>
+ <fielddescr>Probe URL</fielddescr>
+ <fieldname>probe_url</fieldname>
+ <description><![CDATA[<a href="https://www.varnish-cache.org/trac/wiki/BackendPolling">Enter the URL that varnish will use to ensure that this backend is healthy.</a><BR>It can be a url like "/", "/teste.htm" or a request "http://www.mysite.com/index.htm"]]></description>
+ <type>input</type>
+ <size>40</size>
+ </field>
+ <field>
+ <fielddescr>Probe Interval</fielddescr>
+ <fieldname>probe_interval</fieldname>
+ <description><![CDATA[<a href="https://www.varnish-cache.org/trac/wiki/BackendPolling">Enter the frequency in seconds that varnish will check the probe url.</a>]]></description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Probe Timeout</fielddescr>
+ <fieldname>probe_timeout</fieldname>
+ <description><![CDATA[<a href="https://www.varnish-cache.org/trac/wiki/BackendPolling">Enter the frequency in seconds that varnish will wait for a backend probe response.</a>]]></description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Probe Window</fielddescr>
+ <fieldname>probe_window</fieldname>
+ <description><![CDATA[<a href="https://www.varnish-cache.org/trac/wiki/BackendPolling">Enter the value of how many of the latest polls that should be examined.</a>]]></description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Probe Threshold</fielddescr>
+ <fieldname>probe_threshold</fieldname>
+ <description><![CDATA[<a href="https://www.varnish-cache.org/trac/wiki/BackendPolling">Enter the value of how many of those must have succeeded for us to consider the backend healthy.</a>]]></description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Mappings</fielddescr>
+ <fieldname>Mappings</fieldname>
+ <type>listtopic</type>
+ <name>Backend Mappings</name>
+ </field>
+ <field>
+ <fielddescr><![CDATA[<a href="https://www.varnish-cache.org/docs/master/tutorial/advanced_backend_servers.html">Leave empty if you plan to include this server in Load Balance (LB Directors)</a><br><br>use 0s grace time to force no cache.]]></fielddescr>
+ <fieldname>MapURLs</fieldname>
+ <type>rowhelper</type>
+ <rowhelper>
+ <rowhelperfield>
+ <fielddescr>Map</fielddescr>
+ <fieldname>maptype</fieldname>
+ <description>Select the field type that you would like to use in matching the URL.</description>
+ <type>select</type>
+ <options>
+ <option><name>Host</name><value>http.host</value></option>
+ <option><name>URL</name><value>url</value></option>
+ </options>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>Match</fielddescr>
+ <fieldname>fieldtype</fieldname>
+ <type>select</type>
+ <options>
+ <option><name>Equals</name><value>==</value></option>
+ <option><name>Regex</name><value>~</value></option>
+ </options>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>expression</fielddescr>
+ <fieldname>urlmapping</fieldname>
+ <type>input</type>
+ <size>30</size>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr><![CDATA[<a href="https://www.varnish-cache.org/trac/wiki/VCLExampleGrace">grace</a>]]></fielddescr>
+ <fieldname>grace</fieldname>
+ <type>input</type>
+ <size>5</size>
+ </rowhelperfield>
+ </rowhelper>
+ </field>
+ </fields>
+ <custom_php_install_command>
+ varnish_install();
+ </custom_php_install_command>
+ <custom_php_command_before_form>
+ </custom_php_command_before_form>
+ <custom_delete_php_command>
+ sync_package_varnish();
+ create_varnish_rcd_file();
+ varnish_start();
+ </custom_delete_php_command>
+ <custom_php_resync_config_command>
+ sync_package_varnish();
+ create_varnish_rcd_file();
+ varnish_start();
+ </custom_php_resync_config_command>
+ <custom_php_validation_command>
+ varnish_backends_post_validate($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+</packagegui> \ No newline at end of file
diff --git a/config/varnish3/varnish_custom_vcl.xml b/config/varnish3/varnish_custom_vcl.xml
new file mode 100644
index 00000000..ba6d4a51
--- /dev/null
+++ b/config/varnish3/varnish_custom_vcl.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* ========================================================================== */
+/*
+ varnish_settings.xml
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>varnishcustomvcl</name>
+ <version>0.0.2</version>
+ <title>Varnish custom VCL</title>
+ <aftersaveredirect>pkg_edit.php?xml=varnish_settings.xml&amp;id=0</aftersaveredirect>
+ <include_file>/usr/local/pkg/varnish.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Backends</text>
+ <url>/pkg.php?xml=varnish_backends.xml</url>
+ </tab>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=varnish_settings.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Custom VCL</text>
+ <url>/pkg_edit.php?xml=varnish_custom_vcl.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>LB Directors</text>
+ <url>/pkg.php?xml=varnish_lb_directors.xml</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=varnish_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>View Configuration</text>
+ <url>/varnish_view_config.php</url>
+ </tab>
+ <tab>
+ <text>VarnishSTAT</text>
+ <url>/varnishstat.php</url>
+ </tab>
+ </tabs>
+ <fields>
+ <field>
+ <fielddescr>vcl_recv_early</fielddescr>
+ <fieldname>vcl_recv_early</fieldname>
+ <description>Paste your custom <![CDATA[<a target=_new href='http://varnish-cache.org/wiki/VCL'>vcl_recv</a>]]> code here. This code will be included at the beginning of the vcl_recv function.</description>
+ <type>textarea</type>
+ <cols>50</cols>
+ <rows>10</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>vcl_recv_late</fielddescr>
+ <fieldname>vcl_recv_late</fieldname>
+ <description>Paste your custom <![CDATA[<a target=_new href='http://varnish-cache.org/wiki/VCL'>vcl_recv</a>]]> code here. This code will be included at the end of the vcl_recv function.</description>
+ <type>textarea</type>
+ <cols>50</cols>
+ <rows>10</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>vcl_fetch_early</fielddescr>
+ <fieldname>vcl_fetch_early</fieldname>
+ <description>Paste your custom <![CDATA[<a target=_new href='http://varnish-cache.org/wiki/VCL'>vcl_fetch</a>]]> code here. This code will be included at the beginning of the vcl_fetch function.</description>
+ <type>textarea</type>
+ <cols>50</cols>
+ <rows>10</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>vcl_fetch_late</fielddescr>
+ <fieldname>vcl_fetch_late</fieldname>
+ <description>Paste your custom <![CDATA[<a target=_new href='http://varnish-cache.org/wiki/VCL'>vcl_fetch</a>]]> code here. This code will be included at the end of the vcl_fetch function.</description>
+ <type>textarea</type>
+ <cols>50</cols>
+ <rows>10</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>vcl_pipe_early</fielddescr>
+ <fieldname>vcl_fetch_early</fieldname>
+ <description>Paste your custom <![CDATA[<a target=_new href='http://varnish-cache.org/wiki/VCL'>vcl_pipe</a>]]> code here. This code will be included at the beginning of the vcl_pipe function.</description>
+ <type>textarea</type>
+ <cols>50</cols>
+ <rows>10</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>vcl_pipe_late</fielddescr>
+ <fieldname>vcl_fetch_late</fieldname>
+ <description>Paste your custom <![CDATA[<a target=_new href='http://varnish-cache.org/wiki/VCL'>vcl_pipe</a>]]> code here. This code will be included at the end of the vcl_pipe function.</description>
+ <type>textarea</type>
+ <cols>50</cols>
+ <rows>10</rows>
+ <encoding>base64</encoding>
+ </field>
+ </fields>
+ <custom_php_validation_command>
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_varnish();
+ create_varnish_rcd_file();
+ varnish_start();
+ </custom_php_resync_config_command>
+</packagegui> \ No newline at end of file
diff --git a/config/varnish3/varnish_lb_directors.xml b/config/varnish3/varnish_lb_directors.xml
new file mode 100644
index 00000000..994320f3
--- /dev/null
+++ b/config/varnish3/varnish_lb_directors.xml
@@ -0,0 +1,258 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* ========================================================================== */
+/*
+ varnish_lb_directors.xml
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
+ Copyright (C) 2011 Marcello Coutinho
+
+ All rights reserved.
+*/
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>varnishlbdirectors</name>
+ <version>0.0.6</version>
+ <title>Varnish: Backends</title>
+ <include_file>/usr/local/pkg/varnish.inc</include_file>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnish_settings.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnish_custom_vcl.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/varnish64/varnish.inc</item>
+ </additional_files_needed>
+ <menu>
+ <name>Varnish </name>
+ <tooltiptext></tooltiptext>
+ <section>Services</section>
+ <configfile>varnish_lb_directors.xml</configfile>
+ </menu>
+ <tabs>
+ <tab>
+ <text>Backends</text>
+ <url>/pkg.php?xml=varnish_backends.xml</url>
+ </tab>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=varnish_settings.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Custom VCL</text>
+ <url>/pkg_edit.php?xml=varnish_custom_vcl.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>LB Directors</text>
+ <url>/pkg.php?xml=varnish_lb_directors.xml</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=varnish_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>View Configuration</text>
+ <url>/varnish_view_config.php</url>
+ </tab>
+ <tab>
+ <text>VarnishSTAT</text>
+ <url>/varnishstat.php</url>
+ </tab>
+ </tabs>
+ <adddeleteeditpagefields>
+ <columnitem>
+ <fielddescr>Director name</fielddescr>
+ <fieldname>directorname</fieldname>
+ </columnitem>
+ <columnitem>
+ <fielddescr>HOST</fielddescr>
+ <fieldname>directorurl</fieldname>
+ </columnitem>
+ <columnitem>
+ <fielddescr>URL</fielddescr>
+ <fieldname>directorurl2</fieldname>
+ </columnitem>
+
+ <columnitem>
+ <fielddescr>Type</fielddescr>
+ <fieldname>directortype</fieldname>
+ </columnitem>
+ <columnitem>
+ <fielddescr>Grace</fielddescr>
+ <fieldname>grace</fieldname>
+ </columnitem>
+ <columnitem>
+ <fielddescr>Failover</fielddescr>
+ <fieldname>failover</fieldname>
+ </columnitem>
+ </adddeleteeditpagefields>
+ <fields>
+ <field>
+ <fielddescr>DirectorSettings</fielddescr>
+ <fieldname>Director Settings</fieldname>
+ <type>listtopic</type>
+ <name>Director settings</name>
+ </field>
+ <field>
+ <fielddescr>Director name</fielddescr>
+ <fieldname>directorname</fieldname>
+ <type>input</type>
+ <size>40</size>
+ </field>
+ <field>
+ <fielddescr>Match type</fielddescr>
+ <fieldname>fieldtype</fieldname>
+ <description>Select the field type that you would like to use in matching the HOST/URL.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>Equals</name>
+ <value>==</value>
+ </option>
+ <option>
+ <name>Regex</name>
+ <value>~</value>
+ </option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Host</fielddescr>
+ <fieldname>directorurl</fieldname>
+ <description>Hint www.mysite.com</description>
+ <type>input</type>
+ <size>40</size>
+ </field>
+ <field>
+ <fielddescr>URL</fielddescr>
+ <fieldname>directorurl2</fieldname>
+ <description>Hint /images</description>
+ <type>input</type>
+ <size>40</size>
+ </field>
+ <field>
+ <fielddescr>Req Grace</fielddescr>
+ <fieldname>grace</fieldname>
+ <description><![CDATA[<a href="https://www.varnish-cache.org/trac/wiki/VCLExampleGrace">How many time varnish will keep cached objects for this director.</a> HINT 60s, 30m, 1h<br>Use 0s grace time to force no cache.]]></description>
+ <type>input</type>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>Additions options</fielddescr>
+ <fieldname>customapping</fieldname>
+ <description>Paste your custom varnish code for this host/url.</description>
+ <type>textarea</type>
+ <cols>70</cols>
+ <rows>3</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>Backendlist</fielddescr>
+ <fieldname>Backendlist</fieldname>
+ <type>listtopic</type>
+ <name>Backend Settings</name>
+ </field>
+ <field>
+ <fielddescr>Algorithms</fielddescr>
+ <fieldname>directortype</fieldname>
+ <description><![CDATA[<a href="https://www.varnish-cache.org/docs/2.1/reference/vcl.html#the-client-director">Choose how varnish will balance clientes.</a>]]></description>
+ <type>select</type>
+ <options>
+ <option><name>Round-robin</name><value>round-robin</value></option>
+ <option><name>Random</name><value>random</value></option>
+ <option><name>Client</name><value>client</value></option>
+ <option><name>Hash</name><value>hash</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Backend</fielddescr>
+ <fieldname>Backend</fieldname>
+ <type>rowhelper</type>
+ <rowhelper>
+ <rowhelperfield>
+ <fielddescr>Backend</fielddescr>
+ <fieldname>backendname</fieldname>
+ <description>Enter the URL that will be mapped to this lb_directors.</description>
+ <source><![CDATA[$config['installedpackages']['varnishbackends']['config']]]></source>
+ <source_name>backendname</source_name>
+ <source_value>backendname</source_value>
+ <type>select_source</type>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>Weight</fielddescr>
+ <fieldname>weight</fieldname>
+ <description>Enter the weight of this backend.</description>
+ <type>input</type>
+ </rowhelperfield>
+ </rowhelper>
+ </field>
+ <field>
+ <fielddescr>FailoverSettings</fielddescr>
+ <fieldname>FailoverSettings</fieldname>
+ <type>listtopic</type>
+ <name>Failover Settings</name>
+ </field>
+ <field>
+ <fielddescr>Failover Director</fielddescr>
+ <fieldname>failover</fieldname>
+ <description>Select a Director for failover or choose same director to do not configure it.</description>
+ <source><![CDATA[$config['installedpackages']['varnishlbdirectors']['config']]]></source>
+ <source_name>directorname</source_name>
+ <source_value>directorname</source_value>
+ <type>select_source</type>
+ </field>
+ </fields>
+ <custom_php_command_before_form>
+ </custom_php_command_before_form>
+ <custom_delete_php_command>
+ sync_package_varnish();
+ create_varnish_rcd_file();
+ varnish_start();
+ </custom_delete_php_command>
+ <custom_php_resync_config_command>
+ sync_package_varnish();
+ create_varnish_rcd_file();
+ varnish_start();
+ </custom_php_resync_config_command>
+ <custom_php_validation_command>
+ varnish_lb_directors_post_validate($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+</packagegui> \ No newline at end of file
diff --git a/config/varnish3/varnish_settings.xml b/config/varnish3/varnish_settings.xml
new file mode 100644
index 00000000..38c68a03
--- /dev/null
+++ b/config/varnish3/varnish_settings.xml
@@ -0,0 +1,290 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* ========================================================================== */
+/*
+ varnish_settings.xml
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
+ Copyright (C) 2011 Marcello Coutinho
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>varnishsettings</name>
+ <version>0.0.6</version>
+ <title>Varnish Settings</title>
+ <aftersaveredirect>pkg_edit.php?xml=varnish_settings.xml&amp;id=0</aftersaveredirect>
+ <include_file>/usr/local/pkg/varnish.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Backends</text>
+ <url>/pkg.php?xml=varnish_backends.xml</url>
+ </tab>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=varnish_settings.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Custom VCL</text>
+ <url>/pkg_edit.php?xml=varnish_custom_vcl.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>LB Directors</text>
+ <url>/pkg.php?xml=varnish_lb_directors.xml</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=varnish_sync.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>View Configuration</text>
+ <url>/varnish_view_config.php</url>
+ </tab>
+ <tab>
+ <text>VarnishSTAT</text>
+ <url>/varnishstat.php</url>
+ </tab>
+ </tabs>
+ <fields>
+ <field>
+ <fielddescr>Listening</fielddescr>
+ <fieldname>Listening</fieldname>
+ <type>listtopic</type>
+ <name>Daemon options</name>
+ </field>
+ <field>
+ <fielddescr>Enable Varnish</fielddescr>
+ <fieldname>enablevarnish</fieldname>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Listening port</fielddescr>
+ <fieldname>listeningport</fieldname>
+ <description><![CDATA[Enter the port you would like varnish to listen on. Defaults to 80.<BR><BR><strong>Before listening on port 80, you must check 'Disable webConfigurator redirect rule' in system advanced options.</strong>]]></description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Managment interface</fielddescr>
+ <fieldname>managment</fieldname>
+ <description>Enter the Ip address and port for managment interface. HINT 127.0.0.1:81</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Advanced startup options</fielddescr>
+ <fieldname>advancedstartup</fieldname>
+ <description>Enter advanced startup options to include in rc.d file</description>
+ <type>textarea</type>
+ <cols>70</cols>
+ <rows>2</rows>
+ <encoding>base64</encoding>
+ </field>
+ <field>
+ <fielddescr>StorageTypeLT</fielddescr>
+ <fieldname>StorageTypeLT</fieldname>
+ <type>listtopic</type>
+ <name>Storage type</name>
+ </field>
+ <field>
+ <fielddescr>Storage type</fielddescr>
+ <fieldname>storagetype</fieldname>
+ <description>Select which storage type you would like to use.</description>
+ <type>select</type>
+ <options>
+ <option><name>Memory</name><value>malloc</value></option>
+ <option><name>Disk</name><value>ondisk</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Cache storage size in megabytes</fielddescr>
+ <fieldname>storagesize</fieldname>
+ <description>Enter the size of the varnish cache in megabytes. HINT: 1024 == 1 Gigabyte</description>
+ <type>input</type>
+ </field>
+
+ <field>
+ <fielddescr>WorkerThreadLT</fielddescr>
+ <fieldname>WorkerThreadLT</fieldname>
+ <type>listtopic</type>
+ <name>Worker thread configuration</name>
+ </field>
+ <field>
+ <fielddescr>Minimum worker threads</fielddescr>
+ <fieldname>minworkers</fieldname>
+ <description>Enter the minimum number of varnish worker threads.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Maximum worker threads</fielddescr>
+ <fieldname>maxworkers</fieldname>
+ <description>Enter the maximum number of varnish worker threads.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Worker thread timeout</fielddescr>
+ <fieldname>timeoutworkers</fieldname>
+ <description>Enter the timeout time for the worker threads.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>BasicVCLLT</fielddescr>
+ <fieldname>BasicVCLLT</fieldname>
+ <type>listtopic</type>
+ <name>General VCL Settings</name>
+ </field>
+ <field>
+ <fielddescr>Client identity method</fielddescr>
+ <fieldname>clientbalance</fieldname>
+ <description><![CDATA[Select how varnish will balance clients when using client Load Balance method.]]></description>
+ <type>select</type>
+ <options>
+ <option><name>IP address (keep sessions working)</name><value>ip</value></option>
+ <option><name>Requested url</name><value>url</value></option>
+ <option><name>User Agent</name><value>agent</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Don't cache posts</fielddescr>
+ <fieldname>postcache</fieldname>
+ <description>Don't cache posts</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>streaming support</fielddescr>
+ <fieldname>streaming</fieldname>
+ <description>Enable streaming support</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Session Cache</fielddescr>
+ <fieldname>sessioncache</fieldname>
+ <description><![CDATA[<strong>Never</strong> Don't cache anything with JSESSION,PHPSESSID set.<br>
+ <strong>Per User</strong><a href="https://www.varnish-cache.org/trac/wiki/VCLExampleCacheCookies"> This causes a lookup for a given object to include the Cookie.</a><br><br>
+ Note: <strong>no-cache no-store private</strong> header directives are respected by default.]]></description>
+ <type>select</type>
+ <options>
+ <option><name>Never</name><value>never</value></option>
+ <option><name>Per User</name><value>user</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Cache static content</fielddescr>
+ <fieldname>staticache</fieldname>
+ <description><![CDATA[cache images, css and javascript files (.css .js .txt .gif .jpg .jpeg .bmp .png .ico .img .tga and .wmf .mp3 .ogg)<BR>
+ <strong>Always</strong><a href="https://www.varnish-cache.org/trac/wiki/VCLExampleCacheCookies"> Cache all static content. When cookies are present, varnish will unset it from object before caching.</a><br>
+ <strong>Never</strong> Do not cache static content.<br>
+ <strong>When possible</strong> Cache only static content and per user objects when session cache is set to it.<br>]]></description>
+ <type>select</type>
+ <options>
+ <option><name>When Possible</name><value>yes</value></option>
+ <option><name>Always</name><value>all</value></option>
+ <option><name>Never</name><value>no</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Fix gzip compression</fielddescr>
+ <fieldname>fixgzip</fieldname>
+ <description>Ignore compression for images files and unknow compression algorithm</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Be RFC2616 compliant</fielddescr>
+ <fieldname>rfc2616</fieldname>
+ <description>Ignore request different form GET HEAD PUT POST TRACE OPTIONS DELETE</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Foward client IP</fielddescr>
+ <fieldname>xforward</fieldname>
+ <description>Select how to forward clients real IP.</description>
+ <type>select</type>
+ <options>
+ <option><name>set X-Forwarded-For</name><value>set</value></option>
+ <option><name>append X-Forwarded-For</name><value>append</value></option>
+ <option><name>set X-Forwarded-Varnish</name><value>create</value></option>
+ <option><name>Unset</name><value>unset</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Fetch Grace</fielddescr>
+ <fieldname>grace</fieldname>
+ <description><![CDATA[<a href="https://www.varnish-cache.org/trac/wiki/VCLExampleGrace">How many time varnish will keep cached objects.</a> HINT 60s, 30m, 1h]]></description>
+ <type>input</type>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>ErrorVCLLT</fielddescr>
+ <fieldname>ErrorVCLLT</fieldname>
+ <type>listtopic</type>
+ <name>Error Settings</name>
+ </field>
+ <field>
+ <fielddescr>Retries</fielddescr>
+ <fieldname>restarts</fieldname>
+ <description><![CDATA[<a href="https://www.varnish-cache.org/trac/wiki/VCLExampleRestarts">How many times restart loop until Error messages.</a>]]></description>
+ <type>select</type>
+ <options>
+ <option><name>1</name><value>1</value></option>
+ <option><name>2</name><value>2</value></option>
+ <option><name>3</name><value>3</value></option>
+ <option><name>4</name><value>4</value></option>
+ <option><name>5</name><value>5</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Saintmode</fielddescr>
+ <fieldname>saint</fieldname>
+ <description><![CDATA[<a href="https://www.varnish-cache.org/trac/wiki/VCLExampleSaintMode">How many time varnish will send cached objects from a down backend to client.</a> HINT 60s, 30m, 1h]]></description>
+ <type>input</type>
+ <size>5</size>
+ </field>
+ <field>
+ <fielddescr>Custom Html error message</fielddescr>
+ <fieldname>htmlerror</fieldname>
+ <description>Paste your custom html error page code here.</description>
+ <type>textarea</type>
+ <cols>70</cols>
+ <rows>10</rows>
+ <encoding>base64</encoding>
+ </field>
+ </fields>
+ <custom_php_resync_config_command>
+ sync_package_varnish();
+ create_varnish_rcd_file();
+ varnish_start();
+ </custom_php_resync_config_command>
+ <custom_php_validation_command>
+ varnish_settings_post_validate($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+</packagegui> \ No newline at end of file
diff --git a/config/varnish3/varnish_sync.xml b/config/varnish3/varnish_sync.xml
new file mode 100644
index 00000000..02434389
--- /dev/null
+++ b/config/varnish3/varnish_sync.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* ========================================================================== */
+/*
+ varnish_sync.xml
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
+ Copyright (C) 2011 Marcello Coutinho
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>varnishsync</name>
+ <version>1.1</version>
+ <title>Varnish: Manual Sync</title>
+ <include_file>/usr/local/pkg/varnish.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Backends</text>
+ <url>/pkg.php?xml=varnish_backends.xml</url>
+ </tab>
+ <tab>
+ <text>Settings</text>
+ <url>/pkg_edit.php?xml=varnish_settings.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Custom VCL</text>
+ <url>/pkg_edit.php?xml=varnish_custom_vcl.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>LB Directors</text>
+ <url>/pkg.php?xml=varnish_lb_directors.xml</url>
+ </tab>
+ <tab>
+ <text>XMLRPC Sync</text>
+ <url>/pkg_edit.php?xml=varnish_sync.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>View Configuration</text>
+ <url>/varnish_view_config.php</url>
+ </tab>
+ <tab>
+ <text>VarnishSTAT</text>
+ <url>/varnishstat.php</url>
+ </tab>
+ </tabs>
+ <configpath>installedpackages->package->varnish</configpath>
+ <fields>
+ <field>
+ <type>listtopic</type>
+ <fieldname>temp</fieldname>
+ <name>Enable Varnish configuration sync</name>
+ </field>
+ <field>
+ <fielddescr>Automatically sync Varnish configuration changes</fielddescr>
+ <fieldname>synconchanges</fieldname>
+ <description>pfSense will automatically sync changes to the hosts defined below.</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Remote Server</fielddescr>
+ <fieldname>none</fieldname>
+ <type>rowhelper</type>
+ <rowhelper>
+ <rowhelperfield>
+ <fielddescr>IP Address</fielddescr>
+ <fieldname>ipaddress</fieldname>
+ <description>IP Address of remote server</description>
+ <type>input</type>
+ <size>20</size>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>Password</fielddescr>
+ <fieldname>password</fieldname>
+ <description>Password for remote server.</description>
+ <type>password</type>
+ <size>20</size>
+ </rowhelperfield>
+ </rowhelper>
+ </field>
+ </fields>
+ <custom_php_resync_config_command>
+ varnish_sync_on_changes();
+ </custom_php_resync_config_command>
+ <custom_php_command_before_form>
+ unset($_POST['temp']);
+ </custom_php_command_before_form>
+</packagegui> \ No newline at end of file
diff --git a/config/varnish3/varnish_view_config.php b/config/varnish3/varnish_view_config.php
new file mode 100644
index 00000000..2e449b51
--- /dev/null
+++ b/config/varnish3/varnish_view_config.php
@@ -0,0 +1,89 @@
+<?php
+/*
+ varnish_view_config.php
+ part of pfSense (http://www.pfsense.com/)
+ Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+
+$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
+if(strstr($pfSversion, "1.2"))
+ $one_two = true;
+
+$pgtitle = "Varnish: View Configuration";
+include("head.inc");
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php if($one_two): ?>
+<p class="pgtitle"><?=$pgtitle?></font></p>
+<?php endif; ?>
+
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<form action="varnishstat_view_config.php" method="post">
+
+<div id="mainlevel">
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Backends"), false, "/pkg.php?xml=varnish_backends.xml");
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=varnish_settings.xml&id=0");
+ $tab_array[] = array(gettext("Custom VCL"), false, "/pkg_edit.php?xml=varnish_custom_vcl.xml&id=0");
+ $tab_array[] = array(gettext("LB Directors"), false, "/pkg.php?xml=varnish_lb_directors.xml");
+ $tab_array[] = array(gettext("XMLRPC Sync"), false, "/pkg_edit.php?xml=varnish_sync.xml&id=0");
+ $tab_array[] = array(gettext("View Configuration"), true, "/varnish_view_config.php");
+ $tab_array[] = array(gettext("VarnishSTAT"), false, "/varnishstat.php");
+ display_top_tabs($tab_array);
+?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+ <textarea id="varnishlogs" rows="50" cols="100%">
+<?php
+ $config_file = file_get_contents("/var/etc/default.vcl");
+ echo $config_file;
+?>
+ </textarea>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </table>
+</div>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/varnish3/varnishstat.php b/config/varnish3/varnishstat.php
new file mode 100644
index 00000000..6374525a
--- /dev/null
+++ b/config/varnish3/varnishstat.php
@@ -0,0 +1,111 @@
+<?php
+/*
+ varnishstat_view_logs.php
+ part of pfSense (http://www.pfsense.com/)
+ Copyright (C) 2006 Scott Ullrich <sullrich@gmail.com>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+
+if($_REQUEST['getactivity']) {
+ $varnishstatlogs = `varnishstat -1`;
+ echo "<h2>VarnishSTAT Server logs as of " . date("D M j G:i:s T Y") . "</h2>";
+ echo $varnishstatlogs;
+ exit;
+}
+
+$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
+if(strstr($pfSversion, "1.2"))
+ $one_two = true;
+
+$pgtitle = "Varnish: VarnishSTAT";
+include("head.inc");
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
+ <script type="text/javascript">
+ function getlogactivity() {
+ var url = "/varnishstat.php";
+ var pars = 'getactivity=yes';
+ var myAjax = new Ajax.Request(
+ url,
+ {
+ method: 'post',
+ parameters: pars,
+ onComplete: activitycallback
+ });
+ }
+ function activitycallback(transport) {
+ $('varnishstatlogs').innerHTML = '<font face="Courier"><pre>' + transport.responseText + '</pre></font>';
+ setTimeout('getlogactivity()', 2500);
+ }
+ setTimeout('getlogactivity()', 1000);
+ </script>
+<?php include("fbegin.inc"); ?>
+
+<?php if($one_two): ?>
+<p class="pgtitle"><?=$pgtitle?></font></p>
+<?php endif; ?>
+
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<div id="mainlevel">
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Backends"), false, "/pkg.php?xml=varnish_backends.xml");
+ $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=varnish_settings.xml&id=0");
+ $tab_array[] = array(gettext("Custom VCL"), false, "/pkg_edit.php?xml=varnish_custom_vcl.xml&id=0");
+ $tab_array[] = array(gettext("LB Directors"), false, "/pkg.php?xml=varnish_lb_directors.xml");
+ $tab_array[] = array(gettext("XMLRPC Sync"), false, "/pkg_edit.php?xml=varnish_sync.xml&id=0");
+ $tab_array[] = array(gettext("View Configuration"), false, "/varnish_view_config.php");
+ $tab_array[] = array(gettext("VarnishSTAT"), true, "/varnishstat.php");
+ display_top_tabs($tab_array);
+?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+ <form action="varnishstat_view_logs.php" method="post">
+ <div id="varnishstatlogs">
+ <pre>One moment please, loading VarnishSTAT...</pre>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </table>
+</div>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>