[squid-users] Howto make Squid config dependent on hostname?

Hildegard Meier daku8938 at gmx.de
Sat Sep 17 09:37:13 UTC 2022


> It is a poorly worded reference to "#line" directives used by some
> programming languages for documenting the original location of lines in
> preprocessed files. Here are the corresponding C++ preprocessor docs,
> for example: https://en.cppreference.com/w/cpp/preprocessor/line

I guess it would be helpful to add this explanation to the doc.

> > /usr/sbin/squid -k reconfigure -f '|/usr/local/script/squid/pre_process_squid_config_file.sh'
> >
> > gives the following line in /var/log/squid/cache.log
> > FATAL: parseConfigFile: '|/usr/local/script/squid/pre_process_squid_config_file.sh' failed with exit code -1
> > Squid Cache (Version 3.5.27): Terminated abnormally.
>
>  > is that a bug?

I found out that has nothing to do with the -f "|pre_processing_script.sh" syntax, it happens with the standard -f "/etc/squid/squid.conf" syntax the same.

We have IPv6 disabled on the host and Squid says "ERROR: Failed to create helper child read FD: UDP[::1]", so that let me to suspicion the "Terminated abnormally" could be an IPv6 issue.

Solution was to set http_port to the specific IPv4 host addresses.

Now, Squid still says "ERROR: Failed to create helper child read FD: UDP[::1]",
but squid -k reconfigure does work now without the above "parseConfigFile failed with exit code -1" and "Terminated abnormally" message.

(I understand that IPv6 should be availabe on node ("IPv6 Support Required for All IP-Capable Nodes" https://www.rfc-editor.org/rfc/rfc6540), but we have still disabled it on Ubuntu 18, maybe we will not disable it it anymore as of Ubuntu 22)

Regarding the initial question of how to use Macros, I made it now simpler.

We use now /etc/squid/squid.conf.TEMPLATE as config template file, having custom (non-squid, self defined) Macros available.
After the template file has been deployed with rsync to a host, a Bash script is executed locally on the host that replaces (with sed) the Macros with the values (e.g. Hostname, Peer hostname etc.)
and writes the result to /etc/squid/squid.conf
With that, there is no need to use the -f '|pre_processing_script.sh' tweak. That's simpler and more standard, no need for custom /etc/default/squid anymore.

With that we can now deploy host-specific "unique_hostname", "cache_peer" etc. using uniform files on all hosts.

So issue should be solved now.

Thanks and best regards.



More information about the squid-users mailing list