From ed874d6fa0c64064ccb32017d3d3d4d777c61f58 Mon Sep 17 00:00:00 2001 From: Fabian Franz Date: Sun, 29 Oct 2017 08:28:02 +0100 Subject: [PATCH] add update cache; closes #1691 --- .../controllers/OPNsense/Proxy/forms/main.xml | 12 ++++++++++++ .../mvc/app/models/OPNsense/Proxy/Proxy.xml | 12 ++++++++++-- .../templates/OPNsense/Proxy/squid.conf | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/forms/main.xml b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/forms/main.xml index f682733b5..a21b0fc0c 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/forms/main.xml +++ b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/forms/main.xml @@ -160,6 +160,18 @@ true + + proxy.general.cache.local.cache_linux_packages + + checkbox + Enable or disable the caching of packages for linux distributions. This makes sense if you have multiple servers in your network and do not host your own package mirror. This will reduce internet traffic usage but increase disk access. + + + proxy.general.cache.local.cache_windows_updates + + checkbox + Enable or disable the caching of Windows updates. This makes sense if you don't have a WSUS server. If you can setup a WSUS server, this solution should be preferred. + diff --git a/src/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.xml b/src/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.xml index 88f7b8196..3073a2a02 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.xml +++ b/src/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.xml @@ -129,6 +129,14 @@ Specify a positive number of second-level subdirectories. Y + + 0 + Y + + + 0 + Y + @@ -205,8 +213,8 @@ Y - 0 - Y + 0 + Y N diff --git a/src/opnsense/service/templates/OPNsense/Proxy/squid.conf b/src/opnsense/service/templates/OPNsense/Proxy/squid.conf index 4b7096518..bdb47914c 100644 --- a/src/opnsense/service/templates/OPNsense/Proxy/squid.conf +++ b/src/opnsense/service/templates/OPNsense/Proxy/squid.conf @@ -311,6 +311,25 @@ coredump_dir /var/squid/cache # # Add any of your own refresh_pattern entries above these. # + +{% if helpers.exists('OPNsense.proxy.general.cache.local.cache_linux_packages') and OPNsense.proxy.general.cache.local.cache_linux_packages == '1' %} +# Linux package cache: +refresh_pattern pkg\.tar\.xz$ 0 20% 4320 refresh-ims +refresh_pattern d?rpm$ 0 20% 4320 refresh-ims +refresh_pattern deb$ 0 20% 4320 refresh-ims +refresh_pattern udeb$ 0 20% 4320 refresh-ims +refresh_pattern Packages\.bz2$ 0 20% 4320 refresh-ims +refresh_pattern Sources\.bz2$ 0 20% 4320 refresh-ims +refresh_pattern Release\.gpg$ 0 20% 4320 refresh-ims +refresh_pattern Release$ 0 20% 4320 refresh-ims +{% endif %} +{% if helpers.exists('OPNsense.proxy.general.cache.local.cache_windows_updates') and OPNsense.proxy.general.cache.local.cache_windows_updates == '1' %} +# http://wiki.squid-cache.org/SquidFaq/WindowsUpdate +refresh_pattern -i microsoft.com/.*\.(cab|exe|ms[i|u|f]|[ap]sf|wm[v|a]|dat|zip) 4320 80% 129600 reload-into-ims +refresh_pattern -i windowsupdate.com/.*\.(cab|exe|ms[i|u|f]|[ap]sf|wm[v|a]|dat|zip) 4320 80% 129600 reload-into-ims +refresh_pattern -i windows.com/.*\.(cab|exe|ms[i|u|f]|[ap]sf|wm[v|a]|dat|zip) 4320 80% 129600 reload-into-ims +{% endif %} + refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0