Skip to content

Commit

Permalink
web proxy: disable caching more carefully; /var MFS caching is ok
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed Jan 10, 2017
1 parent d3e27cf commit cf48dbb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
14 changes: 9 additions & 5 deletions src/opnsense/mvc/app/controllers/OPNsense/Proxy/forms/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,13 @@
<id>proxy.general.cache.local.cache_mem</id>
<label>Memory Cache size in Megabytes</label>
<type>text</type>
<help><![CDATA[Enter the cache memory size to use.]]></help>
<advanced>true</advanced>
<help><![CDATA[Enter the cache memory size to use or zero to disable completely.]]></help>
</field>
<field>
<id>proxy.general.cache.local.enabled</id>
<label>Enable local cache (requires service restart)</label>
<type>checkbox</type>
<help><![CDATA[Enable or disable the local cache.<br/>
Currently only ufs directory cache type is supported.<br/>
<b class="text-danger">Do not enable on embedded systems with SD or CF cards as this may break your drive.</b>]]></help>
<help><![CDATA[Enable or disable the local cache. Only UFS directory cache type is supported. Do not enable on embedded systems with SD or CF cards without the /var MFS option as this will wear down your drive.]]></help>
</field>
<field>
<id>proxy.general.cache.local.size</id>
Expand All @@ -135,6 +132,13 @@
<help><![CDATA[Enter the storage size for the local cache (default is 100).]]></help>
<advanced>true</advanced>
</field>
<field>
<id>proxy.general.cache.local.directory</id>
<label>Cache directory location</label>
<type>text</type>
<help><![CDATA[Enter the directory location for thee local cache (default is /var/squid/cache).]]></help>
<advanced>true</advanced>
</field>
<field>
<id>proxy.general.cache.local.l1</id>
<label>Number of first-level subdirectories</label>
Expand Down
2 changes: 1 addition & 1 deletion src/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</directory>
<cache_mem type="IntegerField">
<default>256</default>
<MinimumValue>1</MinimumValue>
<MinimumValue>0</MinimumValue>
<ValidationMessage>Specify a positive memory cache size. (number of MB's)</ValidationMessage>
<Required>Y</Required>
</cache_mem>
Expand Down
20 changes: 13 additions & 7 deletions src/opnsense/service/templates/OPNsense/Proxy/squid.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Automatic generated configuration for Squid.
# Do not edit this file manually.
#

{# wrap http_port ssl bump configuration for reuse #}
{% macro sslbump_httpsconfig(network, tags='') -%}
Expand Down Expand Up @@ -264,18 +265,23 @@ icap_enable off

{% include "OPNsense/Proxy/squid.user.post_auth.conf" ignore missing with context %}

{% if helpers.exists('OPNsense.proxy.general.cache.local') and OPNsense.proxy.general.cache.local.enabled == '1' %}
# Caching settings
{% if helpers.exists('OPNsense.proxy.general.cache.local') %}
{% if OPNsense.proxy.general.cache.local.cache_mem|default('256')|int == 0 and OPNsense.proxy.general.cache.local.enabled == '0' %}
cache deny all
cache_mem 0
{% else %}
cache_mem {{ OPNsense.proxy.general.cache.local.cache_mem|default('256') }} MB
{% if OPNsense.proxy.general.cache.local.maximum_object_size|default('') != '' %}
{% if OPNsense.proxy.general.cache.local.maximum_object_size|default('') != '' %}
maximum_object_size {{OPNsense.proxy.general.cache.local.maximum_object_size}} MB
{% if OPNsense.proxy.general.cache.local.maximum_object_size|int > 4 %}
{% if OPNsense.proxy.general.cache.local.maximum_object_size|int > 4 %}
cache_replacement_policy heap LFUDA
{% endif %}
{% endif %}
{% endif %}
{% if OPNsense.proxy.general.cache.local.enabled == '1' %}
cache_dir ufs {{OPNsense.proxy.general.cache.local.directory}} {{OPNsense.proxy.general.cache.local.size}} {{OPNsense.proxy.general.cache.local.l1}} {{OPNsense.proxy.general.cache.local.l2}}
{% else %}
cache deny all
cache_mem 0
{% endif %}
{% endif %}
{% endif %}

# Leave coredumps in the first cache dir
Expand Down

0 comments on commit cf48dbb

Please sign in to comment.