aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfig/varnish3/pkg_varnish.inc11
-rw-r--r--config/varnish3/varnish.inc101
-rw-r--r--config/varnish3/varnish_backends.xml26
-rw-r--r--config/varnish3/varnish_custom_vcl.xml49
-rw-r--r--config/varnish3/varnish_lb_directors.xml3
-rw-r--r--config/varnish3/varnish_sync.xml33
-rw-r--r--pkg_config.8.xml8
-rw-r--r--pkg_config.8.xml.amd648
8 files changed, 192 insertions, 47 deletions
diff --git a/config/varnish3/pkg_varnish.inc b/config/varnish3/pkg_varnish.inc
new file mode 100755
index 00000000..509f24e5
--- /dev/null
+++ b/config/varnish3/pkg_varnish.inc
@@ -0,0 +1,11 @@
+<?php
+
+global $shortcuts;
+
+$shortcuts['varnish'] = array();
+$shortcuts['varnish']['main'] = "pkg.php?xml=varnish_backends.xml";
+$shortcuts['varnish']['log'] = "diag_logs.php";
+$shortcuts['varnish']['status'] = "status_services.php";
+$shortcuts['varnish']['service'] = "varnish";
+
+?> \ No newline at end of file
diff --git a/config/varnish3/varnish.inc b/config/varnish3/varnish.inc
index 4adf0575..983804c9 100644
--- a/config/varnish3/varnish.inc
+++ b/config/varnish3/varnish.inc
@@ -4,7 +4,7 @@
varnish.inc
part of pfSense (http://www.pfSense.com)
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
- Copyright (C) 2011 Marcello Coutinho
+ Copyright (C) 2011-2013 Marcello Coutinho
Copyright (C) 2012 Marcio Carlos Antao
All rights reserved.
*/
@@ -32,6 +32,14 @@
POSSIBILITY OF SUCH DAMAGE.
*/
/* ========================================================================== */
+$shortcut_section = "varnish";
+
+$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
+if ($pf_version > 2.0)
+ define('VARNISH_LOCALBASE', '/usr/pbi/varnish-' . php_uname("m"));
+else
+ define('VARNISH_LOCALBASE','/usr/local');
+
function varnish_settings_post_validate($post, $input_errors) {
if( !is_numeric($post['storagesize']))
@@ -244,7 +252,6 @@ 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
@@ -641,7 +648,15 @@ sub vcl_fini {
}
EOF;
-
+ file_put_contents("/var/etc/default.vcl",$varnish_config_file,LOCK_EX);
+ $cc_file="/usr/local/bin/cc";
+ foreach (glob(VARNISH_LOCALBASE."/bin/gcc*") as $bin_file) {
+ $gcc_file=$bin_file;
+ }
+ if (!file_exists($cc_file) && file_exists($gcc_file)){
+ symlink($gcc_file,$cc_file);
+ }
+
$fd = fopen("/var/etc/default.vcl", "w");
fwrite($fd, $varnish_config_file);
fclose($fd);
@@ -652,29 +667,67 @@ EOF;
/* 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);
+ if (is_array($config['installedpackages']['varnishsync']['config'])){
+ $varnish_sync=$config['installedpackages']['varnishsync']['config'][0];
+ $synconchanges = $varnish_sync['synconchanges'];
+ $synctimeout = $varnish_sync['synctimeout'];
+ switch ($synconchanges){
+ case "manual":
+ if (is_array($varnish_sync[row])){
+ $rs=$varnish_sync[row];
+ }
+ else{
+ log_error("[varnish] xmlrpc sync is enabled but there is no hosts to push on varnish config.");
+ return;
+ }
+ break;
+ case "auto":
+ if (is_array($config['hasync'])){
+ $hasync=$config['hasync'][0];
+ $rs[0]['ipaddress']=$hasync['synchronizetoip'];
+ $rs[0]['username']=$hasync['username'];
+ $rs[0]['password']=$hasync['password'];
+ }
+ else{
+ log_error("[varnish] xmlrpc sync is enabled but there is no system backup hosts to push varnish config.");
+ return;
+ }
+ break;
+ default:
+ return;
+ break;
}
- }
- log_error("[varnish] varnish_xmlrpc_sync.php is ending.");
+ if (is_array($rs)){
+ log_error("[varnish] xmlrpc sync is starting.");
+ foreach($rs as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $password = $sh['password'];
+ if($sh['username'])
+ $username = $sh['username'];
+ else
+ $username = 'admin';
+ if($password && $sync_to_ip)
+ varnish_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout);
+ }
+ log_error("[varnish] xmlrpc sync is ending.");
+ }
+ }
}
/* Do the actual XMLRPC sync */
-function varnish_do_xmlrpc_sync($sync_to_ip, $password) {
+function varnish_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout) {
global $config, $g;
-
+
+ if(!$username)
+ return;
+
if(!$password)
return;
if(!$sync_to_ip)
return;
+
+ if(!$synctimeout)
+ $synctimeout=25;
$xmlrpc_sync_neighbor = $sync_to_ip;
if($config['system']['webgui']['protocol'] != "") {
@@ -710,18 +763,18 @@ function varnish_do_xmlrpc_sync($sync_to_ip, $password) {
$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);
+ $cli->setCredentials($username, $password);
if($g['debug'])
$cli->setDebug(1);
- /* send our XMLRPC message and timeout after 250 seconds */
- $resp = $cli->send($msg, "250");
+ /* send our XMLRPC message and timeout after $synctimeout seconds */
+ $resp = $cli->send($msg, $synctimeout);
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");
+ $resp = $cli->send($msg, $synctimeout);
$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", "");
@@ -742,15 +795,15 @@ function varnish_do_xmlrpc_sync($sync_to_ip, $password) {
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");
+ $cli->setCredentials($username, $password);
+ $resp = $cli->send($msg, $synctimeout);
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");
+ $resp = $cli->send($msg, $synctimeout);
$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", "");
diff --git a/config/varnish3/varnish_backends.xml b/config/varnish3/varnish_backends.xml
index e480a8d6..28e7caca 100644
--- a/config/varnish3/varnish_backends.xml
+++ b/config/varnish3/varnish_backends.xml
@@ -9,7 +9,7 @@
varnish_backends.xml
part of pfSense (http://www.pfSense.com)
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
- Copyright (C) 2011 Marcello Coutinho
+ Copyright (C) 2011-2013 Marcello Coutinho
All rights reserved.
/*/
/* ========================================================================== */
@@ -85,6 +85,11 @@
<chmod>0755</chmod>
<item>http://www.pfsense.com/packages/config/varnish3/varnishstat.php</item>
</additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/shortcuts/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.org/packages/config/varnish3/pkg_varnish.inc</item>
+ </additional_files_needed>
<menu>
<name>Varnish</name>
<tooltiptext>Varnish</tooltiptext>
@@ -129,14 +134,23 @@
</tab>
</tabs>
<adddeleteeditpagefields>
+ <movable>on</movable>
<columnitem>
<fielddescr>IPAddress</fielddescr>
<fieldname>ipaddress</fieldname>
</columnitem>
<columnitem>
+ <fielddescr>Port</fielddescr>
+ <fieldname>port</fieldname>
+ </columnitem>
+ <columnitem>
<fielddescr>Name</fielddescr>
<fieldname>backendname</fieldname>
- </columnitem>
+ </columnitem>
+ <columnitem>
+ <fielddescr>Description</fielddescr>
+ <fieldname>description</fieldname>
+ </columnitem>
</adddeleteeditpagefields>
<fields>
<field>
@@ -163,9 +177,17 @@
<fieldname>port</fieldname>
<description>Enter the TCP/IP port of the webserver.</description>
<type>input</type>
+ <size>6</size>
<validate>^[0-9]+$</validate>
</field>
<field>
+ <fielddescr>Description</fielddescr>
+ <fieldname>description</fieldname>
+ <description>Enter the description for this Backend.</description>
+ <type>input</type>
+ <size>40</size>
+ </field>
+ <field>
<fielddescr>PerformanceMetrics</fielddescr>
<fieldname>PerformanceMetrics</fieldname>
<type>listtopic</type>
diff --git a/config/varnish3/varnish_custom_vcl.xml b/config/varnish3/varnish_custom_vcl.xml
index 86a9cdca..c0bb0e80 100644
--- a/config/varnish3/varnish_custom_vcl.xml
+++ b/config/varnish3/varnish_custom_vcl.xml
@@ -9,6 +9,7 @@
varnish_settings.xml
part of pfSense (http://www.pfSense.com)
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
+ Copyright (C) 2013 Marcello Coutinho
All rights reserved.
*/
/* ========================================================================== */
@@ -78,56 +79,92 @@
</tabs>
<fields>
<field>
+ <type>listtopic</type>
+ <name>vcl_recv_early</name>
+ </field>
+ <field>
<fielddescr>vcl_recv_early</fielddescr>
<fieldname>vcl_recv_early</fieldname>
+ <dontdisplayname/>
+ <usecolspan2/>
<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>
+ <cols>90</cols>
<rows>10</rows>
<encoding>base64</encoding>
</field>
<field>
+ <type>listtopic</type>
+ <name>vcl_recv_late</name>
+ </field>
+ <field>
<fielddescr>vcl_recv_late</fielddescr>
<fieldname>vcl_recv_late</fieldname>
+ <dontdisplayname/>
+ <usecolspan2/>
<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>
+ <cols>90</cols>
<rows>10</rows>
<encoding>base64</encoding>
</field>
<field>
+ <type>listtopic</type>
+ <name>vcl_fetch_early</name>
+ </field>
+ <field>
<fielddescr>vcl_fetch_early</fielddescr>
<fieldname>vcl_fetch_early</fieldname>
+ <dontdisplayname/>
+ <usecolspan2/>
<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>
+ <cols>90</cols>
<rows>10</rows>
<encoding>base64</encoding>
</field>
<field>
+ <type>listtopic</type>
+ <name>vcl_fetch_late</name>
+ </field>
+ <field>
<fielddescr>vcl_fetch_late</fielddescr>
<fieldname>vcl_fetch_late</fieldname>
+ <dontdisplayname/>
+ <usecolspan2/>
<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>
+ <cols>90</cols>
<rows>10</rows>
<encoding>base64</encoding>
</field>
<field>
+ <type>listtopic</type>
+ <name>vcl_pipe_early</name>
+ </field>
+ <field>
<fielddescr>vcl_pipe_early</fielddescr>
<fieldname>vcl_pipe_early</fieldname>
+ <dontdisplayname/>
+ <usecolspan2/>
<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>
+ <cols>90</cols>
<rows>10</rows>
<encoding>base64</encoding>
</field>
<field>
+ <type>listtopic</type>
+ <name>vcl_pipe_late</name>
+ </field>
+ <field>
<fielddescr>vcl_pipe_late</fielddescr>
<fieldname>vcl_pipe_late</fieldname>
+ <dontdisplayname/>
+ <usecolspan2/>
<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>
+ <cols>90</cols>
<rows>10</rows>
<encoding>base64</encoding>
</field>
diff --git a/config/varnish3/varnish_lb_directors.xml b/config/varnish3/varnish_lb_directors.xml
index 0912e267..b9d8cc24 100644
--- a/config/varnish3/varnish_lb_directors.xml
+++ b/config/varnish3/varnish_lb_directors.xml
@@ -9,7 +9,7 @@
varnish_lb_directors.xml
part of pfSense (http://www.pfSense.com)
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
- Copyright (C) 2011 Marcello Coutinho
+ Copyright (C) 2011-2013 Marcello Coutinho
All rights reserved.
*/
@@ -99,6 +99,7 @@
</tab>
</tabs>
<adddeleteeditpagefields>
+ <movable>on</movable>
<columnitem>
<fielddescr>Director name</fielddescr>
<fieldname>directorname</fieldname>
diff --git a/config/varnish3/varnish_sync.xml b/config/varnish3/varnish_sync.xml
index 02434389..fd387fdb 100644
--- a/config/varnish3/varnish_sync.xml
+++ b/config/varnish3/varnish_sync.xml
@@ -9,7 +9,7 @@
varnish_sync.xml
part of pfSense (http://www.pfSense.com)
Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
- Copyright (C) 2011 Marcello Coutinho
+ Copyright (C) 2011-2013 Marcello Coutinho
All rights reserved.
*/
/* ========================================================================== */
@@ -82,12 +82,34 @@
<type>listtopic</type>
<fieldname>temp</fieldname>
<name>Enable Varnish configuration sync</name>
- </field>
+ </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>
+ <description>Select a sync method for bind.</description>
+ <type>select</type>
+ <required/>
+ <default_value>auto</default_value>
+ <options>
+ <option><name>Sync to configured system backup server</name><value>auto</value></option>
+ <option><name>Sync to host(s) defined below</name><value>manual</value></option>
+ <option><name>Do not sync this package configuration</name><value>disabled</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Sync timeout</fielddescr>
+ <fieldname>synctimeout</fieldname>
+ <description>Select sync max wait time</description>
+ <type>select</type>
+ <required/>
+ <default_value>25</default_value>
+ <options>
+ <option><name>30 seconds(Default)</name><value>30</value></option>
+ <option><name>60 seconds</name><value>60</value></option>
+ <option><name>90 seconds</name><value>90</value></option>
+ <option><name>250 seconds</name><value>250</value></option>
+ <option><name>120 seconds</name><value>120</value></option>
+ </options>
</field>
<field>
<fielddescr>Remote Server</fielddescr>
@@ -111,8 +133,7 @@
</rowhelper>
</field>
</fields>
- <custom_php_resync_config_command>
- varnish_sync_on_changes();
+ <custom_php_resync_config_command>
</custom_php_resync_config_command>
<custom_php_command_before_form>
unset($_POST['temp']);
diff --git a/pkg_config.8.xml b/pkg_config.8.xml
index ff3f1e6f..517462bb 100644
--- a/pkg_config.8.xml
+++ b/pkg_config.8.xml
@@ -787,17 +787,17 @@
<internal_name>varnish</internal_name>
<descr><![CDATA[Varnish is a state-of-the-art, high-performance HTTP accelerator.<br />
It uses the advanced features in FreeBSD 6/7/8 to achieve its high performance.<br />
- Version 3.0.2 includes streaming support]]></descr>
+ Version 3 includes streaming support]]></descr>
<website>http://varnish-cache.org</website>
<pkginfolink>http://doc.pfsense.org/index.php/Varnish_package</pkginfolink>
<category>Services</category>
- <version>3.0.2 pkg v.0.1</version>
- <status>BETA</status>
+ <version>3.0.4 pkg v.0.2</version>
+ <status>RC</status>
<required_version>2.0</required_version>
<config_file>http://www.pfsense.com/packages/config/varnish3/varnish_backends.xml</config_file>
<configurationfile>varnish_backends.xml</configurationfile>
<depends_on_package_base_url>http://files.pfsense.org/packages/8/All/</depends_on_package_base_url>
- <depends_on_package_pbi>varnish-3.0.3_2-i386.pbi</depends_on_package_pbi>
+ <depends_on_package_pbi>varnish-3.0.4-i386.pbi</depends_on_package_pbi>
<depends_on_package>varnish-3.0.2.tbz</depends_on_package>
<depends_on_package>pcre-8.21_1.tbz</depends_on_package>
<build_pbi>
diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64
index f872aba8..44f72f8d 100644
--- a/pkg_config.8.xml.amd64
+++ b/pkg_config.8.xml.amd64
@@ -774,17 +774,17 @@
<internal_name>varnish</internal_name>
<descr><![CDATA[Varnish is a state-of-the-art, high-performance HTTP accelerator.<br />
It uses the advanced features in FreeBSD 6/7/8 to achieve its high performance.<br />
- Version 3.0.2 includes streaming support]]></descr>
+ Version 3 includes streaming support]]></descr>
<website>http://varnish-cache.org</website>
<pkginfolink>http://doc.pfsense.org/index.php/Varnish_package</pkginfolink>
<category>Services</category>
- <version>3.0.2 pkg v.0.1</version>
- <status>BETA</status>
+ <version>3.0.4 pkg v.0.2</version>
+ <status>RC</status>
<required_version>2.0</required_version>
<config_file>http://www.pfsense.com/packages/config/varnish3/varnish_backends.xml</config_file>
<configurationfile>varnish_backends.xml</configurationfile>
<depends_on_package_base_url>http://files.pfsense.org/packages/amd64/8/All/</depends_on_package_base_url>
- <depends_on_package_pbi>varnish-3.0.3_2-amd64.pbi</depends_on_package_pbi>
+ <depends_on_package_pbi>varnish-3.0.4-amd64.pbi</depends_on_package_pbi>
<depends_on_package>varnish-3.0.2.tbz</depends_on_package>
<depends_on_package>pcre-8.21_1.tbz</depends_on_package>
<build_pbi>