[squid-users] variable/macro, setting outgoing address
Amos Jeffries
squid3 at treenet.co.nz
Thu Nov 26 11:05:00 UTC 2026
On 26/11/2026 05:13, Nishant Sharma wrote:
>
>
> On 25 November 2026 2:39:21 pm UTC, Matus UHLAR - fantomas wrote:
>
>> Is it possible to have kind of variable/macro that would be defined in included (conf.d) file, to be used in config_file instead of local IP address?
>>
>
> Would it work if you keep all the config same on all squids except one that you include from a conf.d directory - that config just has:
>
> tcp_outgoing_address x.x.x.x special_hosts
>
> Define the
>
> acl special_hosts src "/path/to/hosts_file"
>
> in main config which is common across the squids and you just have to manage the value of x.x.x.x on each squid server (can be scripted / squid init script be modified to populate x.x.x.x on start-up)
You can also assign the x.x.x.x to a unique hostname in /etc/hosts (or
DNS), and configure:
tcp_outgoing_address hostname special_hosts
Squid will resolve the hostname to find x.x.x.x on each startup and
reconfigure action.
If you do this way, be careful that the hostname only resolves to a
single IP, and that IP is assigned to one of the network interfaces of
the machine.
HTH
Amos
More information about the squid-users
mailing list