[Guide] Setup Squid and SquidGuard with Ubuntu Server 14.04.1 LTS


Recommended Posts

After reading a lot of guides on how to set this up, I never found one guide that didn't leave something out that made me have to search for some answers.. I've made a very straightforward and simple guide on how to setup Squid/SquidGuard on a network.. If you have any questions or something in the guide is left out/wrong, please let me know.

How to setup a Squid Server with SquidGuard 
Protecting your Network from Ads/Spyware/Malware
Follow this guide at your own risk! I will not be held responsible for any damages

For this guide, we are going to use Ubuntu 14.04.1 LTS, I will assume that you have the knowledge on how to install an Ubuntu Server on hardware or a VM. Also, set a static IP for the server.

Just follow these commands, and you’ll be up and running!

1. sudo apt-get update
2.  sudo apt-get upgrade
3. sudo apt-get install squid3
4. sudo nano /etc/squid3/squid.conf
5. You can actually just copy and paste this into the squid.conf, everything is commented out..  Just change the hostname to the hostname of the server.. 
visible_hostname your-machines-hostname
http_port 3128
cache_dir ufs /var/spool/squid 1000 16 256
cache_access_log /var/log/squid/access.log
6. Add this also to your squid.conf “intranet” is just the name of the group you are making to allow access to the squid server. Make sure you use your IP range and correct subnet. You can make additional groups if needed, either to allow or deny them. The next is giving access to the group, “intranet”.
acl intranet 10.50.0.0/32
http_access allow intranet
7. sudo service restart squid3

Now, you have a fully working squid server that is going to only allow the IP range of 10.50.0.0/32. If someone tries to connect to the proxy server in a different IP range, they will be blocked by the proxy. You can use this to limit access to certain departments and groups as well as set up times which they can allow internet access.. That is for a more in-depth guide. 
To test your proxy with Firefox, go to options, Advance, Network, Connection Settings. Enter your proxy’s IP and proxy’s port number. Default port number is 3128 as we set in the squid.conf. If you want to use a different port number, edit it in the squid.conf under “http_port”. 


Now, it’s time to install SquidGuard!
1.    sudo apt-get install squidguard
2.    sudo mkdir /opt/3rdparty
We are going to use the list from shalalist.de for “testing”, since it’s 100% free for non-commerical.  For a bigger and much more through blacklist, I use http://urlblacklist.com/. It’s free to try once, and has different pricing tiers for person/school/business.
3.    sudo wget http://www.shallalist.de/Downloads/shallalist.tar.gz
4.    sudo tar xzf shallalist.tar.gz
5.    sudo cp -a /opt/3rdparty/BL/porn/var/lib/squidguard/db
sudo cp -a /opt/3rdparty/BL/adv/var/lib/squidguard/db
sudo cp -a /opt/3rdparty/BL/spyware /var/lib/squidguard/db
6.    Add this to  /etc/squid3/squid.conf , type “sudo nano /etc/squid3/squid.conf”
url_rewrite_program /usr/bin/squidGuard
7.    sudo squidGuard -C all
8.    chown -R proxy:proxy /var/lib/squidguard/db
9.    Add this to my /etc/squid3/squid.conf  type, “sudo nano /etc/squid3/squid.conf”
url_rewrite_program /usr/bin/squidGuard

Now, we need to edit the squidGuard.conf

I recommend to make a backup of your squidGuard.conf then making a new one..
1. sudo cp /etc/squidguard/squidGuard.conf /etc/squidGuard.conf.bak
2. sudo rm /etc/squidguard/squidGuard.conf
3.sudo nano /etc/suqidgurd/squidGuard.conf
Copy and paste this,
#
# CONFIG FILE FOR SQUIDGUARD
#
dbhome /usr/local/squidGuard/db
logdir /usr/local/squidGuard/logs
dest porn {
domainlist porn/domains
urllist porn/urls
}
dest adv {
domainlist adv/domains
urllist adv/urls
}
dest spyware {
domainlist spyware/domains
urllist spyware/urls
}
acl {
default {
pass !porn !adv !spyware all
redirect http://localhost/block.html
}
}
You can test your squidguard by doing a dry run
sudo echo "http://www.pornhub.com 10.50.55.10/- - GET" | squidGuard -c /etc/squidguard/squidGuard.conf –d

You should see, 
squidGuard ready for requests 
squidGuard stopped 
If there are errors, it will tell you.. The most likely errors you’ll run into are permission issues.. If it gives you permission issues with your database, make sure that you set the user and group named “proxy” ownership. You can tell that by “sudo ls -l /var/lib/squidguard/db*”

You can now use the Firefox browser you setup to use with your proxy server to make sure you are blocking porn and ads. For better protection, I recommend using the blacklist from,  http://urlblacklist.com/

Yes I need this. We've got one set up and it looks like a botched up job. I'll be following this guide to set and test a proxy. 

Cheers

Thanks! 

Shouldn't this be in the guide section and not in visualization

Ah, I thought it would be best in the networking section.. Maybe the mods will move it.. Thanks.  

why did you put it under vitalization subsection?

It looks like it is under Home  Technical Help & Support  Internet, Network & Security  [Guide] Setup Squid and SquidGuard with Ubuntu Server 14.04.1 LTS like I intended it to me..  

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Opinion. All you did was blame Democrats for everything. You offered nothing but a hit piece to support your pro Trump, anti union right wing ideology.
    • Excuse me for having an opinion, fella'... (Why am I not surprised?...) Congrats on your very informative post however...
    • By the sounds of that wall of Fox News propaganda gibberish attacking the Democratic Party you've already had plenty of "juices" flowing this morning. You've ruined what could have been a productive comment thread.
    • (Topic to get the juices flowing this Sunday morning!...) Actually, the situation has almost nothing to do with "lack of skills", especially since assembly-line skills can be taught to anyone, including Americans, certainly. Rather, the inadequacy-to-impossibility of large-scale tech manufacturing in America today, and the reasons why America finds tech manufacturing completely onerous in the 21st century, has to do with politically driven laws amid a plethora of non-scientific, utterly politicized "science-fact" that is patently false, punitive business taxation at every turn, an array of judicial fines of unimaginable scope and complexity, and, last but not least, American unionization strictures that serve to actually slay job creation and hobble all such manufacturing endeavors in America before they can get off the ground. Globalism emerged, they tell us, as the needed answer to American hubris and an unholy American drive to excel. Unless one is buried under mounds of political propaganda, it's easy to see the absurdity of labeling the employees of SpaceX, for instance, as "unskilled labor"... Etc. ad infinitum. At one time in the recent past, American manufacturing prowess was the envy of the world in a wide variety of technical fields! The current federal and state government roadblocks against America becoming competitive globally in tech manufacturing are considerable, it's true, as anyone with a working brain knows. But remarkably, that is only half the story! The other half of the story is, of course, the corporations themselves... Chinese tech manufacturing is simply unassailable in terms of profits, because the Chinese government wants to see its tech manufacturing second-to-none globally so that no companies/nations can compete in terms of ROI, and China has completely succeeded in that goal. Let's tic-off a few things: *Chinese tariff policies are set according to what is considered best for Chinese business, Chinese employees, and the Chinese people. Huge difference with how things are done with tariffs in the US--as the US government (SCOTUS in this case, Congress in others) plainly feels that tariffs are "unfair" for the limited number of citizens who may pay them, whereas nothing is "unfair" when Congress considers the Personal Income Tax rates to be infinitely hike-able, along with infinitely enlarging annual budget deficits. *The Chinese government boldly subsidizes Chinese companies to artificially amplify their profits. *The Chinese government deliberately refuses to avidly demonize Chinese businesses and does not consider Chinese businesses "the enemy", so very unlike American (D)s these days. *Chinese labor laws and businesses are allowed to set their own labor policies according to what Chinese companies consider is best for companies and their employees... Simply put, American workers in tech manufacturing are not allowed to set their own labor policies! * One additional problem corporations have that I also do not sympathize with is they don't want to pay to train their American employees. They could easily do so, but would rather not have to pay for it. I find that pathetic, actually. It is the height of hypocrisy for Americans to decry working conditions in China while simultaneously ensuring that American products are manufactured in China, not in the US, simply to maximize profits. There is nothing wrong with making a profit, of course, absolutely nothing. But there is plenty wrong with attempts to normalize hypocrisy of this kind! But rank hypocrisy and the (D) party in the US are longtime bedfellows... The current government in Washington is working overtime to see if it can toss out the horribly poor, failed economic policies of the past, while the (D)s still in Washington work very hard to bring back the stupidity whenever possible. With the right policies in place, America can be an infinitely competitive manufacturer.
  • Recent Achievements

    • Conversation Starter
      jessse3334 earned a badge
      Conversation Starter
    • Reacting Well
      JuvenileDelinquent earned a badge
      Reacting Well
    • One Month Later
      Excellence2025 earned a badge
      One Month Later
    • Week One Done
      Excellence2025 earned a badge
      Week One Done
    • Week One Done
      flexorcist earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      508
    2. 2
      +Edouard
      198
    3. 3
      PsYcHoKiLLa
      152
    4. 4
      Steven P.
      73
    5. 5
      FloatingFatMan
      62
  • Tell a friend

    Love Neowin? Tell a friend!