Help with squid in transparent mode

  • What can be done with the constant problem of the Squid access log and swap.state file growing so large?

    It ends up taking up more
    disk space than the cache and crashes the system.. very annoying.

    I have configured the swap.state to rotate daily, this seems to be working, but the access.log gets HUGE!!

    Any way that i can make it so this doesnt happen?

    I am looking into installing a second pfsense box  with just WAN and make it only a squid caching server. If i do this i understand that i have to have squid installed still on the main server, so will the access.log and swap.state be stored on the second box or still on the main box?  I am sure that the cache folder will be on the second box.

    I mainly need to know this because, if everything gets stored on the second box, then i obviously only need a very small partition for the main box, as it will not be doing much more than just being a firewall.

    I have everything running on a ESXi server, so if all is good, i will have Main pfsense on a 10gb drive, and will have the squid server on a 400gb drive.  If this is enough space for the main server it will be good as i will create 2 and have them synchronised using carp.. when i can work out how to do that.

  • You can rotate squid logs using /usr/local/sbin/squid -k rotate at console or via cron.

    On sarg package, you have this option to create reports and then rotate the log.

  • So al you guys using squid have to manually rotate logs all the time? this seems wrong.

    In the Proxy Server setup i have Rotate Logs set to 1 day, but it definately does not rotate them every day.

    I just had to manually rotate the logs cause the access.log got to 1.7gb.. hasn't rotated at all like it should each day

  • hi luke240778,

    I know you did not had good experience with sarg yet but if want to give it a second try, squid log rotates works fine after sarg report.

    You can try to copy it's rotate log code in a php script and run it via cron.

    function log_rotate($log_file){
    	global $config, $g;
    	#remove .10 rotate log file
    	#rotate logs from 9 to 0
    	while ($i>=0){
    		if (file_exists($log_file.".".$i))
    			rename ($log_file.".".$i,$log_file.".".($i+1));
    	#rotate current log
    	if (file_exists("$log_file"))
    		rename ($log_file,$log_file.".0");	


    Marcello Coutinho

  • Thanks marcello.. ill take another look at sarg.  Sorry for the late reply, have been away from the forum for a while (pfsense has been up and running nicely for the past 50 days.. yay!)

Log in to reply