Add Web Porn Filtering and Other Content Filtering to Linux Desktops

How to set up the DansGuardian content filter with the lightweight Tinyproxy.
Adjust Your Browser Settings

Ubuntu comes with Firefox as the preferred client browser, so the instructions here are specific to Firefox. Other client browsers will likely have similar capabilities and documentation to show how to mimic these instructions.

This last installation step points the browser at port 8080, so it sends data only through DansGuardian and Tinyproxy. With Firefox, go to Edit→Preferences→General tab→Connection Settings to see the screen shown in Figure 1. As shown, select manual proxy configuration, enter localhost and port 8080. This assumes you are going to install and use DansGuardian and Tinyproxy on every workstation. If you set up DansGuardian and Tinyproxy on a separate server, then you need to enter the name or IP address of the server machine that runs DansGuardian and Tinyproxy instead of the word localhost in the HTTP Proxy: line.

Figure 1. Set up your browser to use the proxy.

Restart your browser and test how well the filter works.

When testing the new filter, you should see an access denied screen similar to the one shown in Figure 2. Before going any further, it's a good idea to look for problems you may find with the default filter settings. For example, I often download .tar and other executable files. The default configuration file stops these files from download. To fix this problem, you need to edit the bannedextensionlist.txt file, and place a # to comment out the file extensions you want to let through the filter.

Figure 2. A Typical DansGuardian Access Denied Page

To be thorough, you should look through all default configuration .txt files with DansGuardian to tailor how you want the filters to react. You won't know all the situations you'll run into at first, but this is a good opportunity to gain an understanding of this application's powerful features.

Some Vulnerabilities

No system is perfect, and there are several obvious ways to defeat DansGuardian and Tinyproxy. The most noteworthy is how easily users can bypass the proxy and filters. Without further protection, a user can restore Firefox's preferences back to Direct Connection, which bypasses DansGuardian and Tinyproxy. Once reversed, users have unrestricted access to the Internet.

However, there are more ways to secure the DansGuardian filters further by forcing all communication with the Internet through port 8080. A link on the DansGuardian documentation Web page explains a well-thought-out method of using FireHol to force this condition on all Internet thoroughfares (see Resources).

For the novice user, an easier approach is to set up a filtering plan that includes restricted user privileges, locked browser preferences and making sure the proxy filters start each time the computer reboots.

For test purposes, I created a new user account on Ubuntu Dapper Drake (Figure 3). Using the checklist features, I severely limited the capability of the user test. Although these privileges could be just right for anyone who has no computer experience or who is plainly not trustworthy. Utilities like update-rc.d and fcconf define certain programs to start at the system boot. I used a bootup manager called BUM to make DansGuardian and Tinyproxy start at each boot.

Figure 3. Ubuntu Dapper Drake User Privilege Settings

Figure 4. Set up DansGuardian and Tinyproxy to run every time you boot Linux.

Finally, I decided to lock down the preferences of Firefox. Restricting Firefox's preferences is not as difficult as it may sound. An older copyrighted article titled “HOWTO Lock Down Mozilla Preferences for LTSP” by Warren Togami (see Resources) describes how to carry this out in great detail. Although, I didn't want to mess with byte shift coding to achieve similar results.

After rummaging through's Web site, I chose to add lockPref statements to my Firefox configuration file to keep users from changing connection settings. I edited the file /usr/lib/firefox/firefox.cfg to appear as the one shown in Figure 5. The last three lines force a manual proxy selection on localhost, port 8080. After saving this file and restarting Firefox, you can't reset the connection settings. Further, other users without administrative privileges could not quickly change the settings and bypass the filters.

Figure 5. Lock down Firefox settings so they can't be changed without administrative privileges.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

what is i'm looking :)

MASOKIS's picture

wow..i din't know linux can do this.. nice:)


Anonymous's picture

I just wanted to say p-0-r-n.

I've followed the

felixvah's picture

I've followed the instruction as mention above, but I did come a cross a problem. Can someone point me to the right direction. After install danguardians tinyproxy and follow as in mention, but when I get to the point open firefox click on edit - > preference - > General tab→Connection Settings which I did not find the General Tab on my browser. did I do something wrong?

Ohh thats nice

Stalin's picture

may be if i will add this my workers won't browse to sites like and similar review sites, and start working.
i should also close the facebook access for them, it's annoying to see a log full of social network instead of work websites

I believe we have a similar

Jamie Aston's picture

I believe we have a similar situation at my workplace and works fine so far.

Just what I needed

djmadkins's picture

Excellent article, I just did this on my home ubuntu system which my 13 year old daughter uses for surfing the internet and it works like a charm.

Using the work PORN in comments.

Keith Daniels's picture

If you use the word porn in any of your comments the spam filter will reject it. If I don't keep the filter up we will get swamped by pornographic spam from spammers who noticed we were talking about porn on the site.

If you have to use porn in your comment -- use p o r n, p-o-r-n, p.o.r.n or some variant like that.


All the new OSs and windowing systems are oriented towards content consumption instead of content production.

--Steve Daniels 2013