Brew install squid on macOS but can’t run squid

brewsquid

I followed this document today

http://macappstore.org/squid/

And tried running these two commands

  • /usr/local/Cellar/squid/4.11/sbin/squid -f squid.conf -N
  • sudo /usr/local/Cellar/squid/4.11/sbin/squid -f squid.conf -N

The first one has no output and I can't find logs anywhere. The second one outputs to stderr/stdout as it gets permission denied(what in the world, why is root getting permission denied?)

Here is my output from the second command…

Deans-MacBook-Pro:workspace dean$ sudo /usr/local/Cellar/squid/4.11/sbin/squid -f squid.conf -N
WARNING: Cannot write log file: /usr/local/var/logs/cache.log
/usr/local/var/logs/cache.log: Permission denied
         messages will be sent to 'stderr'.
2020/05/05 09:47:25| Created PID file (/usr/local/var/run/squid.pid)
2020/05/05 09:47:25| Current Directory is /Users/dean/workspace
WARNING: Cannot write log file: /usr/local/var/logs/cache.log
/usr/local/var/logs/cache.log: Permission denied
         messages will be sent to 'stderr'.
2020/05/05 09:47:25| Starting Squid Cache version 4.11 for x86_64-apple-darwin19.4.0...
2020/05/05 09:47:25| Service Name: squid
2020/05/05 09:47:25| Process ID 45668
2020/05/05 09:47:25| Process Roles: master worker
2020/05/05 09:47:25| With 256 file descriptors available
2020/05/05 09:47:25| Initializing IP Cache...
2020/05/05 09:47:25| DNS Socket created at [::], FD 9
2020/05/05 09:47:25| DNS Socket created at 0.0.0.0, FD 10
2020/05/05 09:47:25| Adding nameserver 192.168.2.1 from /etc/resolv.conf
2020/05/05 09:47:25| Logfile: opening log daemon:/usr/local/var/logs/access.log
2020/05/05 09:47:25| Logfile Daemon: opening log /usr/local/var/logs/access.log
2020/05/05 09:47:25| Store logging disabled
2020/05/05 09:47:25| Swap maxSize 0 + 262144 KB, estimated 20164 objects
2020/05/05 09:47:25| Target number of buckets: 1008
2020/05/05 09:47:25| Using 8192 Store buckets
2020/05/05 09:47:25| Max Mem  size: 262144 KB
2020/05/05 09:47:25| Max Swap size: 0 KB
2020/05/05 09:47:25| Using Least Load store dir selection
2020/05/05 09:47:25| Current Directory is /Users/dean/workspace
fopen: Permission denied
2020/05/05 09:47:25| Finished loading MIME types and icons.
2020/05/05 09:47:25| HTCP Disabled.
2020/05/05 09:47:25| Squid plugin modules loaded: 0
2020/05/05 09:47:25| Adaptation support is off.
2020/05/05 09:47:25| Accepting HTTP Socket connections at local=[::]:3128 remote=[::] FD 13 flags=9
2020/05/05 09:47:26| Configuring Parent zproxy.lum-superproxy.io/22225/0
2020/05/05 09:47:26| storeLateRelease: released 0 objects
2020/05/05 09:47:26| logfileHandleWrite: daemon:/usr/local/var/logs/access.log: error writing ((32) Broken pipe)
2020/05/05 09:47:26| Closing HTTP(S) port [::]:3128
2020/05/05 09:47:26| storeDirWriteCleanLogs: Starting...
2020/05/05 09:47:26|   Finished.  Wrote 0 entries.
2020/05/05 09:47:26|   Took 0.00 seconds (  0.00 entries/sec).
2020/05/05 09:47:26| FATAL: I don't handle this error well!
2020/05/05 09:47:26| Squid Cache (Version 4.11): Terminated abnormally.
CPU Usage: 0.045 seconds = 0.033 user + 0.012 sys
Maximum Resident Size: 45465600 KB
Page faults with physical i/o: 59
2020/05/05 09:47:26| Removing PID file (/usr/local/var/run/squid.pid)
Deans-MacBook-Pro:workspace dean$

Any ideas on how to get squid to work on mac?

My configuration file is simple

http_port 3128

cache_peer proxy-host-name parent proxy-port 0 \
  no-query \
  login=username:password \
  connect-fail-limit=99999999 \
  proxy-only \
  name=my_peer
cache_peer_access my_peer allow all

Best Answer

Generally, the standard squid -z approach seems to work, after taking care of the permission issue

brew install squid

vim /usr/local/etc/squid.conf

sudo mkdir /var/spool/squid
sudo chown -R myuser:admin /var/spool/squid

/usr/local/Cellar/squid/4.13/sbin/squid -z

/usr/local/Cellar/squid/4.13/sbin/squid -N

ls -la /usr/local/var/logs/