aboutsummaryrefslogtreecommitdiffstats
path: root/config/varnish64
diff options
context:
space:
mode:
Diffstat (limited to 'config/varnish64')
-rw-r--r--config/varnish64/varnish.inc11
-rwxr-xr-xconfig/varnish64/varnish.widget.php126
-rw-r--r--config/varnish64/varnish_backends.xml5
-rw-r--r--config/varnish64/varnish_settings.xml2
4 files changed, 137 insertions, 7 deletions
diff --git a/config/varnish64/varnish.inc b/config/varnish64/varnish.inc
index 50d804fb..7b514780 100644
--- a/config/varnish64/varnish.inc
+++ b/config/varnish64/varnish.inc
@@ -141,7 +141,6 @@ function varnish_get_url_mappings_txt() {
else{
if(!$isfirst)
$urlmappings .= "\telse ";
- #req.http.host == "procesual.trf1.jus.br"
$urlmappings .= "if (req.$req $fieldtype ".'"'.$url['directorurl'].$url['directorurl2'].'") {'."\n";
#check failover
$urlbackend = "\t\t\tset req.backend = ".$url['directorname'].";";
@@ -283,7 +282,7 @@ function get_backend_config_txt() {
else
$first_byte_timeout = "300s";
if($backend['probe_url'])
- if (preg_match("@^(http)://([a-zA-Z0-9.]*)/(.*)$@",$backend['probe_url'],$matches)){
+ 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";
@@ -395,7 +394,7 @@ function sync_package_varnish() {
}
$vcl_recv_set_basic='#BASIC VCL RULES SETTING'."\n";
$vcl_recv_action_basic='#BASIC VCL RULES ACTIONS'."\n";
- $plataform=posix_uname();
+ #$plataform=posix_uname();
foreach($config['installedpackages']['varnishsettings']['config'] as $vcl) {
if($vcl['fixgzip']){
$vcl_recv_set_basic.="\t#Fix gzip compression\n";
@@ -405,7 +404,7 @@ function sync_package_varnish() {
$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'){
+ #if($vcl['clientbalance'] && $plataform['machine'] == 'amd64'){
$vcl_recv_set_basic.="\t#set client balance identity\n";
switch ($vcl['clientbalance']){
case 'url':
@@ -418,7 +417,7 @@ function sync_package_varnish() {
$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";
}
@@ -597,7 +596,7 @@ sub vcl_fetch {
## 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 != 303 && beresp.status != 302 && beresp.status != 301 && beresp.status != 401 ) {
{$vcl_saint_mode}restart;
}
diff --git a/config/varnish64/varnish.widget.php b/config/varnish64/varnish.widget.php
new file mode 100755
index 00000000..f2b68aec
--- /dev/null
+++ b/config/varnish64/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/varnish64/varnish_backends.xml b/config/varnish64/varnish_backends.xml
index 417cc8a1..d9597dd3 100644
--- a/config/varnish64/varnish_backends.xml
+++ b/config/varnish64/varnish_backends.xml
@@ -61,6 +61,11 @@
<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>
diff --git a/config/varnish64/varnish_settings.xml b/config/varnish64/varnish_settings.xml
index fdbf91e2..0576caad 100644
--- a/config/varnish64/varnish_settings.xml
+++ b/config/varnish64/varnish_settings.xml
@@ -166,7 +166,7 @@
<field>
<fielddescr>Client identity method</fielddescr>
<fieldname>clientbalance</fieldname>
- <description><![CDATA[Select how varnish will balance clients when using client Load Balance method. (Choose IP address on i386 systems)]]></description>
+ <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>