Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Start the Squid web proxy as a service at start up Internet

The Squid web proxy can be run on OS X as a proxy server for those with a network of web users wishing to speed access to static web content and eliminate duplicate downloads. The Squid Manager GUI makes it fairly easy to manage Squid, but currently doesn't provide a way to enable it at startup. Mac OS X provides a mechanism for this called SystemStarter, which looks in /Library -> StartupItems for particularly configured folders and files to tell it what to start up and how. After a bit of pain (partly due to leaving my firewall running during testing and hence tripping over it), I have created a functioning StartupItem for Squid.

A caveat: the owners, groups, and permissions for Squid's files and folders need to be set properly for Squid to run successfully (and safely) as a service. There's plenty of documentation accessible from the Squid website and elsewhere on the web about this. Suffice to say that even if Squid runs fine for you when invoked via Squid Manager or the command line, it may not run as a service if permissions are not appropriate.

To set up the startup item, download Squid.sit [2.4K download], expand it, then put the resulting folder into /Library -> StartupItems (not the folder of the same name under /System). Also, check the content to be sure it's not some Trojan or other nasty (you are sufficiently paranoid to consider such a check necessary, I hope). The files are all plain text.

Another caveat: the files I've created assume that the Squid executable is in the default location of /usr/local/squid/sbin/squid and the config file for it is in /usr/local/squid/etc/squid.conf.You'll need to set up squid.conf appropriately as well. This is so site-specific, I won't even begin to offer advice on that. Again, the Squid documentation is helpful, and I've found that it writes pretty useful error messages to the cache.log file if things are not quite right.

[robg adds: I have not tested this one; a previous hint explains how to use Squid to get around firewall authentication problems.]

    •    
  • Currently 1.60 / 5
  You rated: 2 / 5 (5 votes cast)
 
[23,003 views]  

Start the Squid web proxy as a service at start up | 9 comments | Create New Account
Click here to return to the 'Start the Squid web proxy as a service at start up' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Start the Squid web proxy as a service at start up
Authored by: nxor on Mar 14, '03 11:06:27AM

Funny, I was just about to do this this morning. Thanks for doing the work for me.



[ Reply to This | # ]
For those with Fink
Authored by: vogunaescht on Mar 14, '03 11:48:43AM

It's as easy as this: Type "fink install squid" in the shell and that's it. A valid Startup Item is created for you.



[ Reply to This | # ]
For those with Fink
Authored by: Ranger Rick on Mar 14, '03 12:46:27PM

Well, by default it's not enabled. You need to run 'sudo daemonic enable squid' (or squid-ssl, depending on which version you installed)



[ Reply to This | # ]
Start the Squid web proxy as a service at start up
Authored by: nofutureuk on Mar 14, '03 12:25:21PM

what you could also do (I use this for my dial-up connections with the notebook), is to start squid only on demand if you have an online connection.
to do that, you need to place the following scripts into /etc/ppp/:
/etc/ppp/ip-up
-------------------
#!/bin/sh
/sw/sbin/squid -z
/sw/sbin/squid -D
-------------------
/etc/ppp/ip-down
-------------------
#!/bin/sh
/sw/sbin/squid -k shutdown
-------------------

cheers



[ Reply to This | # ]
FANTASTIC!
Authored by: nednieuws on Mar 21, '03 07:01:28AM

Thank you.

In my StartupItem I've disabled the DNS tests on startup, but judging from the debug output squid still expects to see a DNS somewhere, or read it from /etc/resolv.conf. That file doesn't exist until a connection is established, so no joy.

Your solution works perfectly for all of us that live in the boonies (eg. without ADSL), so now I can have a cache for all the browsers I use.


---
Regards, Charles.



[ Reply to This | # ]
Start the Squid web proxy as a service at start up
Authored by: merlyn on Mar 14, '03 12:41:39PM

The already-installed Apache contains mod_proxy, which is usually more than adequate to serve as a caching proxy. No need to install any new software... just add a dozen lines or so to the config file, and you're up and running!

If anyone is curious about what those dozen lines are, just ask.



[ Reply to This | # ]
Start the Squid web proxy as a service at start up
Authored by: berniecase on Mar 15, '03 04:14:10PM

How I wish I could get this to work, but I haven't had any luck. SystemStarter start Squid works fine. But, getting it all to start during a bootup doesn't. /usr/local/squid/ is owned by nobody:wheel and the cache_effective_user is nobody. Cache_effective_group is wheel.

Not sure where I'm going wrong here, but I haven't had any luck getting this to work... I'm running 2.5STABLE1. I compiled it myself. Oh well...



[ Reply to This | # ]
Start the Squid web proxy as a service at start up
Authored by: NetBSD on Aug 05, '03 12:26:57PM

After a little research, I finally got this to work. There is most likely a way to make this work the the XML StartupParameters.plist included in the Squid.sit, but, for me, why use XML when plain text will work. Here is what I did:
# rm -f /Library/StartupItems/Squid/StartupParameters.plist
# pico -w /Library/StartupItems/Squid/StartupParameters.plist
{
Description = "Squid Web Cache Proxy Server";
Provides = ("Squid");
Requires = ("Network");
Uses = ("Network");
OrderPreferece = "none";
}
# chmod 644 /Library/StartupItems/Squid/StartupParameters.plist
#shutdown -r now


Squid started when it rebooted. It looks as if SystemStarter won't start things properly if StartupParameters.plist is set 755, and I added in the network option so that SystemStarter knows to start the network before starting Squid.

Enjoy.

---
Microsoft is no the answer.
It is the question.
The answer is NO!



[ Reply to This | # ]
Start the Squid web proxy as a service at start up
Authored by: lsloan on Jul 20, '04 12:11:52AM
I changed the StartupParameters.plist similarly, too:

{
  Description    = "Squid proxy service";
  Provides       = ("Squid");
  Requires       = ("Network", "Resolver");
  Uses           = ("Network");
  OrderPreferece = "none";
  Messages =
  {
    start = "Starting Squid proxy service";
    stop  = "Stopping Squid proxy service";
  };
}
I also changed Resources/English.lproj/Localizable.strings, though it may not have been necessary:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
        <key>Starting Squid proxy service</key>
        <string>Starting Squid proxy service</string>
</dict>
</plist>
And I changed the Squid script to start squid with the "-s" (syslog) option and without the "-f" (configuration filename) option. My changes are available at http://umich.edu/~lsloan/Squid.tar.gz.

---
--
Lance E Sloan

[ Reply to This | # ]