Modifying squid.conf when WAN is up / down ?
I don't know if it's possible but to solve my problem and use a backup proxy available in OPT1, a solution could be to change squid.conf in real time.
If WAN is up, squid is up in transparent mode with SquidGuard or HAVP for high security.
If WAN is down, squid is not in transparent mode and just use a parent proxy and "never_direct allow all" is activated.
I think i can create the two squid.conf but i dont know how to monitor WAN and execute a script ?
With PHPService ?
And to reload squid ?
- make and start sh/php script for monitoring Wan state
- get string from grep ifconfig wan state & memory last state
- check state change with prevoius
- if state changed - reconfigure squid, else - nothing
- sleep 30-60c
- goto 1
squid reconfiguring :
- stop squid: killall squid
- start squid: squid …tram-pam-pam-keys.. /selected_config_path
Ok thanks i'm on the good way then.
Squid.conf is generated by pfsense on start / stop service right ?
But where are stored the configuration ?
I want to make something smart, stop squid, modifying squid.conf stored in Pfsense, start squid.
So i just have to put my conf somewhere but if i control with WebGUI i'll see the real conf.
with this kind of php code i can change my config :)
require_once("pfsense-utils.inc"); require_once("functions.inc"); require_once('config.inc'); var_dump($config['installedpackages']['squid']); var_dump($config['installedpackages']['squidcache']); $config['installedpackages']['squid']['config']['admin_email'] = "admin@localhost"; write_config();
squid config generated by squid_resync() cmd or by Save button ib GUI or by pfSense restart.
squid service start/stop use current config.
if you want generate config with GUI mechanism - use php script
But bad way generate new conf each up<>down state WAN Maybe need recheck state via timeout
<monitor state="" cycle="">test state - if changed - wite (30-60s) - check state new => generate squid conf
Thanks a lot dvserg, it's working :)
Can you attach the code and make this a sticky. This would be really useful for many people.
Finally it dosen't work :(
With my multiwan config squid on the pfsense is lost with DNS resolution…Sometimes it's working, sometimes not...The OPT1 is really important for my client so i need a perfect access.
I put a debian lenny only with squid3 on my lan and it's working really better, the squid is configured to use the pfsense as DNS server and default gateway.
If i put down my WAN connection, it send an alert to the Squid3 wich restart with a special "conf" and use the parent proxy from my OPT1.