Username/Email:  Password: 
TwitterFacebookFlickrRSS

Zap Annoyances on the Web, Part I

Get rid of annoying Web marketing and protect your privacy, using both the browser and a proxy server.

Surfing the Web is something most of us do daily. At home I am on a dial-up connection, and I'm constantly looking for ways to make my browsing experience more efficient and to protect my privacy while on-line. The approach I describe here allows you to stop many ads, images, Web bugs and pop-up windows. In case you are not familiar with Web bugs, they are small graphics included on a Web site or in an e-mail that are used to track who is reading. Whether you are on a dial-up connection or a high-speed connection, the tools presented in this article are guaranteed to make your on-line browsing experience more enjoyable and to protect your personal habits from nosy marketers.

My environment consists of an IBM A31 ThinkPad with a 1.9GHz Pentium 4 Mobile CPU and 1GB of RAM running Fedora Core 1 (fedora.redhat.com). I am using Mozilla 1.5 (www.mozilla.org) as my Web browser.

The Approach

The approach we take here consists of the following three basic parts: Mozilla's image, JavaScript and pop-up window management capabilities; a proxy server to cache Web content; and a program to intercept requests for undesired content.

If you are not familiar with proxy servers, here's a quick overview. For the purpose of this article, we define a proxy server as an intermediate server used to intercept requests for Web pages and associated files. The proxy server either handles the request itself or passes the request on to another proxy server or to the original target. A proxy server can be transparent, intercepting all requests automatically. In our example we manually configure the browser to go through our proxy server. Proxy servers also can be used to proxy other types of requests, but that falls outside the scope of this article.

We are using Squid (www.squid-cache.org) as our proxy server. Squid is an extremely popular proxy server that's in use all over the world. Squid allows you to cache Web content locally, so instead of going out to the Internet for content you have previously downloaded, you can retrieve it from Squid's local cache. Squid is smart enough to know if content can be read from cache or if it must be updated from the originating Web site. If you are looking at a news site, for example, Squid knows that it needs to refresh the text on the site, but it usually loads the static images on the site from cache. Squid also gives us the ability to add in something called redirects, which intercept requests and possibly modify them in some way. For example, if you request an image that is known to be an advertisement, the intercept may return a placeholder image instead of the image requested, completely bypassing the request for the original image.

Implementing Our Solution

The first step is to set up Mozilla to block pop-up windows. The option to enable this feature can be found under Edit→Preferences→Privacy & Security→Popup Windows. You are greeted by the screen shown in Figure 1. Choosing the option to Block unrequested pop-up windows does exactly that. You can play a sound or display an icon when pop-ups are blocked if you so desire. There also is an option to allow pop-ups explicitly from certain sites. If you click on the button labeled Allowed Sites..., you are shown the screen in Figure 2. This feature is handy for sites that pop up external windows for things like showing progress for a long-running task. You can leave this list blank to start and add sites as you go.

Figure 1. Block unrequested pop-up windows from Mozilla.

Figure 2. You can permit pop-ups from sites that use them for legitimate purposes.

The second step is to configure Mozilla to manage JavaScript events. These settings can be found under Edit→Preferences→Advanced→Scripts & Plugins. Check boxes on this screen allow you to turn off JavaScript completely for your browser, mail and news readers. You also can keep JavaScript enabled and configure Mozilla to stop scripts from moving or resizing windows, raising or lowering windows, hiding or changing the statusbar, changing images, creating or changing cookies and reading cookies. The settings I use can be seen in Figure 3 and should work well for most situations.

Figure 3. Disable the JavaScript features that Webmasters use to create annoyances.

The next step is to tackle setting up our Squid proxy server. If you have never set up a proxy server before, have no fear; setting up Squid is much easier than you think. First, check to see if you have Squid already installed on your system. This can be done by typing which squid. If you get back a path to Squid you're all set. If not, you can download prebuilt RPMs from rpmfind.net/linux/rpm2html/search.php?query=squid&submit=Search+..., or download the source from www.squid-cache.org. You also need Perl installed, which is pretty much guaranteed to be on your system already. Installing from source is easy; follow the three-step install instructions in the INSTALL file included with the source distribution:

% ./configure --prefix=/usr/local/squid
% make all
% make install

The latest version of Squid, at the time of this writing, is 2.5.STABLE4. I am using version 2.5.STABLE3, which shipped with Fedora Core 1.

Next, we configure Squid. Before updating your Squid configuration, we issue the stop command, /etc/init.d/squid stop, to make sure Squid is not running.

Now, edit the /etc/squid/squid.conf file as root. We are going to change only one setting in the default squid.conf file. Locate the line that reads:

# http_port 3128

______________________

Comments

Comment viewing options

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

Re: Zap Annoyances on the Web, Part I

Anonymous's picture

Try adblock - it's a VERY nifty little tool that plugs right into Mozilla or Firefox...

Re: Zap Annoyances on the Web, Part I

Anonymous's picture

Do you have any suggestions on Content Filtering with Squid?
ie blocking explicit sites

Thanks in advance

Re: Zap Annoyances on the Web, Part I

Anonymous's picture

squid-guard

Re: Zap Annoyances on the Web, Part I

dmarti's picture

Privoxy

Anonymous's picture

I use Privoxy to block ads--they really have done a lot of this work already. http://www.privoxy.org/

I believe it can also be chained to a cache (like squid) if desired.

Re: Zap Annoyances on the Web, Part I

Anonymous's picture

I note that Mozilla allows one to set a very large cache, under Preferences. The default on my Mozilla came at 50 MB. I increased this to 150 MB, and now have a sizeable cache to speed up web page loading, using dialup.

Do you think squid provides better caching than the one in Mozilla?

Re: Zap Annoyances on the Web, Part I

Anonymous's picture

man, that is so blindingly fast, i can`t believe it! my browser now runs "blink and you miss it".

Re: Zap Annoyances on the Web, Part I

Anonymous's picture

I configured Squid as per your instructions in both Mozilla 1.6 and in Firebird 0.8 and get the following error message:

"The connection was refused when attempting to contact the proxy server you have configured. Please check your proxy settings and try again."

The file I edited was "/etc/squid/squid.conf" and not "/etc/squid/squid.conf.default." The file read:
#Default:
# http_port 3128

I just uncommented the line "# http_port 3128" and made the proxy setting in Mozilla and Firebird read the same port "3128". I don't know what I am doing wrong.

Re: Zap Annoyances on the Web, Part I

Anonymous's picture

I am having a similar problem (I'm running Slackware current) with details as follows:

I changed the conf file to this, which I think should work (I got the
IP address from LISaDaemom):

INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS

# Example rule allowing access from your local networks. Adapt
# to list your (internal) IP networks from where browsing should
# be allowed
acl our_networks src 192.168.0.0/24
http_access allow our_networks

# And finally deny all other access to this proxy
http_access deny all

I set the http_port to 8080 and then configured firefox as follows:

HTTP Proxy : 127.0.0.1 Port: 8080
SSL Proxy : 127.0.0.1 Port :8080

and there is no proxy for localhost, 127.0.0.1

Squid is running fine. When I try to open a web page, I now get a
message that says "The connection was refused when attempting to
contact the proxy server you have configured. Please check your proxy
settings and try again."

I am also running a firewall script as follows, could this be part of
the problem?

#!/bin/bash
#
# Basic script to keep the nasties out of slack-lap
# First we make the default policy to drop everything
iptables -P INPUT DROP
iptables -P FORWARD DROP
# Allow established connections and programs that use loopback
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 127.0.0.0/8 -d 127.0.0.0/8 -i lo -j ACCEPT
# Lets allow ssh to connect
iptables -A INPUT -p tcp --dport 22 -i ppp0 -j ACCEPT
#end script

I am really new to linux and I find this networking stuff a bit
confusing..but I'm learning..., so please bear with me!

Thanks,
Lucinda

Re: Zap Annoyances on the Web, Part I

Anonymous's picture

You have to permit or allow your own network to use the proxy. I believe the entry is something like:

my network 192.168.0.0
allow my network

Then reload squid and you should be good to go.

Cheers