From d1dce3495cf5fdddddb5b9ca0c1b7334b4dd29ac Mon Sep 17 00:00:00 2001 From: geijt Date: Sat, 9 Feb 2013 17:16:29 +0100 Subject: Added redirects for squid-reverse Added the options for squid-reverse to redirect from http/https on the specified URI to an URL --- config/squid-reverse/squid.inc | 5 + config/squid-reverse/squid_monitor.php | 1 + config/squid-reverse/squid_reverse.inc | 35 +++++ config/squid-reverse/squid_reverse_general.xml | 4 + config/squid-reverse/squid_reverse_peer.xml | 4 + config/squid-reverse/squid_reverse_redir.xml | 182 +++++++++++++++++++++++++ config/squid-reverse/squid_reverse_sync.xml | 4 + config/squid-reverse/squid_reverse_uri.xml | 4 + 8 files changed, 239 insertions(+) create mode 100644 config/squid-reverse/squid_reverse_redir.xml (limited to 'config') diff --git a/config/squid-reverse/squid.inc b/config/squid-reverse/squid.inc index 941395f6..fef9590c 100644 --- a/config/squid-reverse/squid.inc +++ b/config/squid-reverse/squid.inc @@ -6,6 +6,7 @@ Copyright (C) 2006 Fernando Lemos Copyright (C) 2012 Martin Fuchs Copyright (C) 2012 Marcello Coutinho + Copyright (C) 2013 Gekkenhuis All rights reserved. Redistribution and use in source and binary forms, with or without @@ -1053,6 +1054,10 @@ acl manager proto cache_object acl purge method PURGE acl connect method CONNECT +# Define protocols used for redirects +acl HTTP proto HTTP +acl HTTPS proto HTTPS + EOD; diff --git a/config/squid-reverse/squid_monitor.php b/config/squid-reverse/squid_monitor.php index c2164023..86c7d33a 100644 --- a/config/squid-reverse/squid_monitor.php +++ b/config/squid-reverse/squid_monitor.php @@ -83,6 +83,7 @@ include("head.inc"); $tab_array[] = array(gettext("General"), false, "/pkg_edit.php?xml=squid_reverse_general.xml&id=0"); $tab_array[] = array(gettext("Web Servers"), false, "/pkg.php?xml=squid_reverse_peer.xml"); $tab_array[] = array(gettext("Mappings"), false, "/pkg.php?xml=squid_reverse_uri.xml"); + $tab_array[] = array(gettext("Redirects"), false, "/pkg.php?xml=squid_reverse_redir.xml"); $tab_array[] = array(gettext("Real time"), true, "/squid_monitor.php?menu=reverse"); $tab_array[] = array(gettext("Sync"), false, "/pkg_edit.php?xml=squid_reverse_sync.xml"); } diff --git a/config/squid-reverse/squid_reverse.inc b/config/squid-reverse/squid_reverse.inc index 652931c8..eb2d4c73 100644 --- a/config/squid-reverse/squid_reverse.inc +++ b/config/squid-reverse/squid_reverse.inc @@ -4,6 +4,7 @@ squid_reverse.inc Copyright (C) 2012 Martin Fuchs Copyright (C) 2012 Marcello Coutinho + Copyright (C) 2013 Gekkenhuis All rights reserved. Redistribution and use in source and binary forms, with or without @@ -40,6 +41,8 @@ function squid_resync_reverse() { $reverse_peers=$config['installedpackages']['squidreversepeer']['config']; if (is_array($config['installedpackages']['squidreverseuri'])) $reverse_maps=$config['installedpackages']['squidreverseuri']['config']; + if (is_array($config['installedpackages']['squidreverseredir'])) + $reverse_redir=$config['installedpackages']['squidreverseredir']['config']; $conf = "# Reverse Proxy settings\n"; @@ -124,6 +127,38 @@ function squid_resync_reverse() { } } + //REDIRECTS + if (is_array($reverse_redir)) { + foreach ($reverse_redir as $rdr) { + if($rdr['enable'] == "on" && $rdr['name'] != "" && $rdr['pathregex'] != "" && $rdr['redirurl'] != "") { + $conf_rdr = "# Redirect: {$rdr['description']}\n"; + + if (is_array($rdr['row'])) { + foreach ($rdr['row'] as $uri) { + $conf_rdr .= "acl rdr_dst_{$rdr['name']} dstdomain {$uri['uri']}\n"; + } + } + + $conf_rdr .= "acl rdr_path_{$rdr['name']} urlpath_regex {$rdr['pathregex']}\n"; + $conf_rdr .= "deny_info {$rdr['redirurl']} rdr_path_{$rdr['name']}\n"; + + foreach (explode(',', $rdr['protocol']) as $rdr_protocol) { + if($rdr_protocol == "HTTP") { + $conf_rdr .= "http_access deny HTTP rdr_dst_{$rdr['name']} rdr_path_{$rdr['name']}\n"; + } + + if($rdr_protocol == "HTTPS") { + $conf_rdr .= "http_access deny HTTPS rdr_dst_{$rdr['name']} rdr_path_{$rdr['name']}\n"; + } + } + + $conf_rdr .= "\n"; + } + + $conf .= $conf_rdr; + } + } + //ACLS and MAPPINGS //create an empty owa_dirs to populate based on user selected options diff --git a/config/squid-reverse/squid_reverse_general.xml b/config/squid-reverse/squid_reverse_general.xml index ec0bcb7a..2211bb20 100644 --- a/config/squid-reverse/squid_reverse_general.xml +++ b/config/squid-reverse/squid_reverse_general.xml @@ -63,6 +63,10 @@ Mappings /pkg.php?xml=squid_reverse_uri.xml + + Redirects + /pkg.php?xml=squid_reverse_redir.xml + Real time /squid_monitor.php?menu=reverse diff --git a/config/squid-reverse/squid_reverse_peer.xml b/config/squid-reverse/squid_reverse_peer.xml index 6341567e..abfbf19b 100644 --- a/config/squid-reverse/squid_reverse_peer.xml +++ b/config/squid-reverse/squid_reverse_peer.xml @@ -63,6 +63,10 @@ Mappings /pkg.php?xml=squid_reverse_uri.xml + + Redirects + /pkg.php?xml=squid_reverse_redir.xml + Real time /squid_monitor.php?menu=reverse diff --git a/config/squid-reverse/squid_reverse_redir.xml b/config/squid-reverse/squid_reverse_redir.xml new file mode 100644 index 00000000..de25f56a --- /dev/null +++ b/config/squid-reverse/squid_reverse_redir.xml @@ -0,0 +1,182 @@ + + + + + + . + 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. + */ +/* ============================================================================ */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + squidreverseredir + none + Reverse Proxy server: Redirects + /usr/local/pkg/squid.inc + + + General + /pkg_edit.php?xml=squid_reverse_general.xml&id=0 + + + Web Servers + /pkg.php?xml=squid_reverse_peer.xml + + + Mappings + /pkg.php?xml=squid_reverse_uri.xml + + + Redirects + /pkg.php?xml=squid_reverse_redir.xml + + + + Real time + /squid_monitor.php?menu=reverse + + + Sync + /pkg_edit.php?xml=squid_reverse_sync.xml&id=0 + + + + + Status + enable + + + Redirect Name + name + + + Redirect to + redirurl + + + Description + description + + + + + Squid Redirect Mappings + listtopic + + + Enable this redirect + enable + + checkbox + + + Redirect name + name + + example: REDIR1]]> + input + 20 + + + Redirect Description + description + + input + 60 + + + Redirect Protocol + protocol + + Use CTRL + click to select multiple]]> + select + + 03 + + + + + + + Blocked domains + none + Domains to redirect for + rowhelper + + + Domains to match

+ Samples: mydomain.com sub.mydomain.com www.mydomain.com

+ Do not enter http:// or https:// here! only the hostname is required.]]>
+ uri + input + 60 +
+
+
+ + Path regex + pathregex +
]]> + Enter ^/$ to match the domain only.
+ input + 60 +
+ + URL to redirect to + redirurl + + input + 60 + +
+ + + + + + + squid_resync(); + +
\ No newline at end of file diff --git a/config/squid-reverse/squid_reverse_sync.xml b/config/squid-reverse/squid_reverse_sync.xml index 408f14f1..db5e6145 100755 --- a/config/squid-reverse/squid_reverse_sync.xml +++ b/config/squid-reverse/squid_reverse_sync.xml @@ -58,6 +58,10 @@ Mappings /pkg.php?xml=squid_reverse_uri.xml
+ + Redirects + /pkg.php?xml=squid_reverse_redir.xml + Real time /squid_monitor.php?menu=reverse diff --git a/config/squid-reverse/squid_reverse_uri.xml b/config/squid-reverse/squid_reverse_uri.xml index 81c9af3b..1232cfe3 100644 --- a/config/squid-reverse/squid_reverse_uri.xml +++ b/config/squid-reverse/squid_reverse_uri.xml @@ -63,6 +63,10 @@ /pkg.php?xml=squid_reverse_uri.xml + + Redirects + /pkg.php?xml=squid_reverse_redir.xml + Real time /squid_monitor.php?menu=reverse -- cgit v1.2.3