[squid-users] Define and use a variable in squid.conf (Was: What happens when duplicate external_acl_type are mentioned)

Alex Rousskov rousskov at measurement-factory.com
Mon Dec 3 04:21:15 UTC 2018


On 12/2/18 8:59 PM, Amish wrote:
> On 02/12/18 11:14 pm, Alex Rousskov wrote:
>> You do not need to modify main.conf to
>> generate a configuration file that is actually used. My earlier
>> authentication.conf sketch is one example. And even something as simple
>> as the following sed-based script may work in many cases:
>>
>>    sed s/AmishForceFoo/true/ main.conf > squid.conf

> Actual squid.conf is:
> include pre.conf
> include main.conf

... but it does not have to be. In the sed-based approach, there is no
pre.conf at all, and squid.conf is generated from main.conf.


> And I do not want to modify main.conf

The variable/sed-based approach requires a single main.conf modification
(once). Just like the authentication.conf approach requires a single
main.conf modification (that you have already performed).


> May be atleast 'if' statement can have define variable support.

The "I will just add this little thing in this little corner" is how we
ended up with terrible syntax in the first place...


> Because it already has similar support for ${process_number} etc.

Yes, and preprocessor macros are supported throughout the configuration
file, not just in if statements. However, they are preprocessor macros,
not configuration variables. We can add support for custom preprocessor
macros (in addition to the existing built-in ones), but, again, doing so
correctly requires some serious work. Meanwhile, template substitutions
are available as a local ready-to-use alternative.

Alex.


More information about the squid-users mailing list