diff options
author | Serg <dv_serg@mail.ru> | 2010-04-27 09:33:07 +0400 |
---|---|---|
committer | Serg <dv_serg@mail.ru> | 2010-04-27 09:33:07 +0400 |
commit | 3fdcb2bd0f337503bba03b856023ff50f00ed655 (patch) | |
tree | 7529abff5493f103d487820c1dd7522eaa340474 | |
parent | 1c02dc3cbb3129de7f071b94326229434d5c5060 (diff) | |
parent | 678612936ebfcc5fb2638eba377b9c8b7df4cea2 (diff) | |
download | pfsense-packages-3fdcb2bd0f337503bba03b856023ff50f00ed655.tar.gz pfsense-packages-3fdcb2bd0f337503bba03b856023ff50f00ed655.tar.bz2 pfsense-packages-3fdcb2bd0f337503bba03b856023ff50f00ed655.zip |
Merge branch 'master' of http://gitweb.pfsense.org/pfsense-packages/mainline
-rw-r--r-- | config/varnish64/varnish.inc | 68 | ||||
-rw-r--r-- | config/varnish64/varnish_backends.xml | 9 | ||||
-rw-r--r-- | config/varnish64/varnish_custom_vcl.xml | 9 | ||||
-rw-r--r-- | config/varnish64/varnish_lb_directors.xml | 144 | ||||
-rw-r--r-- | config/varnish64/varnish_settings.xml | 9 | ||||
-rwxr-xr-x | pkg_config.8.xml.amd64 | 2 |
6 files changed, 220 insertions, 21 deletions
diff --git a/config/varnish64/varnish.inc b/config/varnish64/varnish.inc index 1a1cd0a3..c4fd5b4b 100644 --- a/config/varnish64/varnish.inc +++ b/config/varnish64/varnish.inc @@ -32,6 +32,7 @@ /* ========================================================================== */ function sync_package_varnish() { + global $config, $g; if($config['installedpackages']['varnishcustomvcl']['config'] != "") { foreach($config['installedpackages']['varnishcustomvcl']['config'] as $vcl) { if($vcl['vcl_fetch_early']) @@ -103,23 +104,57 @@ deliver; EOF; $backends = ""; + $urlmappings = ""; + + if($config['installedpackages']['varnishlbdirectors']['config'] != "") { + foreach($config['installedpackages']['varnishlbdirectors']['config'] as $backend) { + $director = ""; + if($backend['row']) + foreach($backend['row'] as $be) + $director .= "\t{\n\t\t.backend = {$be['backendname']};\n\t}"; + $backends .= <<<EOFA +director {$backend['directorname']} {$backend['directortype']} { +{$director} +} + + +EOFA; + } + } + + if($config['installedpackages']['varnishbackends']['config'] != "") { foreach($config['installedpackages']['varnishbackends']['config'] as $backend) { - $urlmappings = ""; $isfirst = true; - if($config['installedpackages']['varnishurlmappings']['config'] != "") { - foreach($config['installedpackages']['varnishurlmappings']['config'] as $urlmapping) { + if($config['installedpackages']['varnish_lb_directors']['config'] != "") { + foreach($config['installedpackages']['varnish_lb_directors']['config']['row'] as $urlmapping) { if(!$isfirst) $urlmappings .= "else "; - $urlmappings = <<<EOAU -if (req.http.host == "{$urlmapping['url']}") { - set req.backend = "{$urlmapping['backend']}"; + $urlmappings .= <<<EOAU +if (req.http.host == "{$urlmapping['urlmapping']}") { + set req.backend = "{$backend['backend']}"; + set req.http.host = "{$urlmapping['urlmapping']}"; +} + +EOAU; + } + } + if($config['installedpackages']['varnishbackends']['config']) + foreach($config['installedpackages']['varnishbackends']['config'] as $urlmapping) { + if($config['installedpackages']['varnishbackends']['config']['row']) + foreach($config['installedpackages']['varnishbackends']['config']['row'] as $urlmapping) { + if(!$isfirst) + $urlmappings .= "else "; + $urlmappings .= <<<EOAU +if (req.http.host == "{$urlmapping['urlmapping']}") { + set req.backend = "{$backend['backend']}"; set req.http.host = "{$urlmapping['url']}"; } EOAU; - $isfirst = false; + $isfirst = false; } } + if($backend['connect_timeout']) $connect_timeout = $backend['connect_timeout'] . "s"; else @@ -136,13 +171,24 @@ EOAU; backend {$backend['backendname']} { .host = "{$backend['ipaddress']}"; .port = "{$backend['port']}"; - .first_byte_timeout = "{$first_btye_timeout}"; + .first_byte_timeout = "{$first_byte_timeout}"; .connect_timeout = "{$connect_timeout}"; } EOFA; } } + +if($vcl_fetch_early or $vcl_fetch_late) { + $vcl_fetch = <<<FETCH +sub vcl_fetch { + {$vcl_fetch_early} + {$vcl_fetch_late} + return(deliver); +} + +FETCH; +} $varnish_config_file = <<<EOF # Varnish configuration file @@ -198,11 +244,7 @@ sub vcl_pipe { {$vcl_pipe_late} } -sub vcl_fetch { - {$vcl_fetch_early} - {$vcl_fetch_late} - return(deliver); -} +{$vcl_fetch} EOF; diff --git a/config/varnish64/varnish_backends.xml b/config/varnish64/varnish_backends.xml index f8ba9953..89d2f2ba 100644 --- a/config/varnish64/varnish_backends.xml +++ b/config/varnish64/varnish_backends.xml @@ -43,6 +43,7 @@ <name>varnishbackends</name> <version>0.0.1</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> @@ -72,11 +73,15 @@ </tab> <tab> <text>Settings</text> - <url>/pkg.php?xml=varnish_settings.xml</url> + <url>/pkg_edit.php?xml=varnish_settings.xml&id=0</url> </tab> <tab> <text>Custom VCL</text> - <url>/pkg.php?xml=varnish_custom_vcl.xml</url> + <url>/pkg_edit.php?xml=varnish_custom_vcl.xml&id=0</url> + </tab> + <tab> + <text>LB Directors</text> + <url>/pkg.php?xml=varnish_lb_directors.xml</url> </tab> </tabs> <adddeleteeditpagefields> diff --git a/config/varnish64/varnish_custom_vcl.xml b/config/varnish64/varnish_custom_vcl.xml index c03d3352..6cd6d877 100644 --- a/config/varnish64/varnish_custom_vcl.xml +++ b/config/varnish64/varnish_custom_vcl.xml @@ -52,14 +52,17 @@ </tab> <tab> <text>Settings</text> - <url>/pkg.php?xml=varnish_settings.xml</url> - + <url>/pkg_edit.php?xml=varnish_settings.xml&id=0</url> </tab> <tab> <text>Custom VCL</text> - <url>/pkg.php?xml=varnish_custom_vcl.xml</url> + <url>/pkg_edit.php?xml=varnish_custom_vcl.xml&id=0</url> <active/> </tab> + <tab> + <text>LB Directors</text> + <url>/pkg.php?xml=varnish_lb_directors.xml</url> + </tab> </tabs> <fields> <field> diff --git a/config/varnish64/varnish_lb_directors.xml b/config/varnish64/varnish_lb_directors.xml new file mode 100644 index 00000000..1c771dbb --- /dev/null +++ b/config/varnish64/varnish_lb_directors.xml @@ -0,0 +1,144 @@ +<?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 + 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>varnish_lb_directors</name> + <version>0.0.1</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>Varnish Backends</text> + <url>/pkg.php?xml=varnish_backends.xml</url> + </tab> + <tab> + <text>Settings</text> + <url>/pkg_edit.php?xml=varnish_settings.xml&id=0</url> + </tab> + <tab> + <text>Custom VCL</text> + <url>/pkg_edit.php?xml=varnish_custom_vcl.xml&id=0</url> + </tab> + <tab> + <text>LB Directors</text> + <url>/pkg.php?xml=varnish_lb_directors.xml</url> + <active/> + </tab> + </tabs> + <adddeleteeditpagefields> + <columnitem> + <fielddescr>URL</fielddescr> + <fieldname>directorurl</fieldname> + </columnitem> + <columnitem> + <fielddescr>Type</fielddescr> + <fieldname>directortype</fieldname> + </columnitem> + </adddeleteeditpagefields> + <fields> + <field> + <fielddescr>Director name</fielddescr> + <fieldname>directorname</fieldname> + <type>input</type> + <size>40</size> + </field> + <field> + <fielddescr>URL</fielddescr> + <fieldname>directorurl</fieldname> + <type>input</type> + <size>40</size> + </field> + <field> + <fielddescr>Type</fielddescr> + <fieldname>directortype</fieldname> + <type>select</type> + <options> + <option><name>Round-robin</name><value>round-robin</value></option> + <option><name>Random</name><value>random</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> + </rowhelper> + </field> + </fields> + <custom_php_command_before_form> + </custom_php_command_before_form> + <custom_delete_php_command> + sync_package_varnish(); + </custom_delete_php_command> + <custom_php_resync_config_command> + sync_package_varnish(); + </custom_php_resync_config_command> +</packagegui>
\ No newline at end of file diff --git a/config/varnish64/varnish_settings.xml b/config/varnish64/varnish_settings.xml index 2d7e6ea8..2e9032cd 100644 --- a/config/varnish64/varnish_settings.xml +++ b/config/varnish64/varnish_settings.xml @@ -52,12 +52,17 @@ </tab> <tab> <text>Settings</text> - <url>/pkg.php?xml=varnish_settings.xml</url> + <url>/pkg_edit.php?xml=varnish_settings.xml&id=0</url> <active/> </tab> <tab> <text>Custom VCL</text> - <url>/pkg.php?xml=varnish_custom_vcl.xml</url> + <url>/pkg_edit.php?xml=varnish_custom_vcl.xml&id=0</url> + </tab> + <tab> + <text>LB Directors</text> + <url>/pkg.php?xml=varnish_lb_directors.xml</url> + <active/> </tab> </tabs> <fields> diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 736fb9cb..79d9d6a4 100755 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -4,7 +4,7 @@ <packages> <package> <name>Varnish</name> - <descr>Varnish is a state-of-the-art, high-performance HTTP accelerator. It uses the advanced features in Linux 2.6, FreeBSD 6/7 and Solaris 10 to achieve its high performance.</descr> + <descr>Varnish is a state-of-the-art, high-performance HTTP accelerator. It uses the advanced features in Linux 2.6, FreeBSD 6/7/8 and Solaris 10 to achieve its high performance.</descr> <website>http://varnish-cache.org</website> <pkginfolink>http://doc.pfsense.org/index.php/Varnish_package</pkginfolink> <category>Services</category> |