Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-17-2012, 01:44 AM   #1
LQ Newbie
Registered: May 2012
Posts: 24

Rep: Reputation: Disabled
How to Make The Blocked Page Work in A squidGuard

I have downloaded the following script file from the net but as I am new to linux I dont know how to make it run. At present I am displaying a static page whenever someone visits a restricted site.

I want to display more details when displaying a blocked page.

I need to know how to run this script and what more changes I have to do in this script to make it run.
A step by step instruction will be very helpful to me
Thanks in advance.

#! /usr/bin/perl
# Sample CGI to explain to the user that the URL is blocked and by which rule set
# By Pål Baltzersen 1998

require '/var/ipcop/';


$clientaddr = "";
$clientname = "";
$clientident = "";
$srcclass = "";
$targetclass = "";
$url = "";
$time = time;
@day = ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
@month = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

$swroot = '/var/ipcop';
my %netsettings;
my %proxysettings;

&readhash("${swroot}/ethernet/settings", \%netsettings);
$netsettings = {'GREEN_ADDRESS'};

&readhash("${swroot}/proxy/sgsettings", \%proxysettings);

while ($QUERY_STRING =~ /^\&?([^&=]+)=([^&=]*)(.*)/) {
$key = $1;
$value = $2;
if ($key =~ /^(clientaddr|clientname|clientident|srcclass|targetclass|url)$/) {
eval "\$$key = \$value";
if ($QUERY_STRING =~ /^url=(.*)/) {
$url = $1;
print "Content-type: text/html\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($time);
printf "Expires: %s, %02d-%s-%02d %02d:%02d:%02d GMT\n\n", $day[$wday],$mday,$month[$mon],$year,$hour,$min,$sec;
print "<HTML>\n\n <HEAD>\n <TITLE>302 Access denied</TITLE>\n </HEAD>\n\n";
print " <BODY BGCOLOR=\"#FFFFFF\">\n";
print " <P ALIGN=CENTER>\n";
print " <IMG SRC=\"http://$netsettings{'GREEN_ADDRESS'}:81/images/title.gif\"\n";
print " BORDER=0></A> </P>\n";
print " <H1 ALIGN=CENTER>Access to the page:</H1>\n";
print " <TR><TH ALIGN=CENTER>$url\n";
print " <TR><TH ALIGN=CENTER>... has been denied for the following reason:\n";
print " <TR><TH ALIGN=CENTER>$targetclass\n";
print " </TABLE>\n";
print " <table border=1 TH ALIGN=CENTER bgcolor='#FFEE00'>\n";
print " <tr><td>You are seeing this error because the page you attempted<br>\n";
print " to access contains, or is labled as containing, material that<br>\n";
print " has been deemed inappropriate.</td></tr>\n";
print " </TABLE>\n\n";
print " <P ALIGN=CENTER>If this is wrong, contact your<BR>\n";
print " <A HREF=mailto:$proxysettings{'ADMIN_NAME'}>Network Administrator</A><P>\n\n";
print " <P ALIGN=CENTER>This site Protected by:<BR>\n";
print " <A HREF=\"\"><P ALIGN=CENTER>SquidGuard<BR>\n";
print " <IMG SRC=\"http://$netsettings{'GREEN_ADDRESS'}:81/images/squidGuard.gif\"\n";
print " </P>\n\n";
print " </BODY>\n\n</HTML>\n";
exit 0;

Last edited by vineetcornelius; 02-27-2013 at 11:09 PM.
Old 05-17-2012, 02:27 AM   #2
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203

You'll first have to install this script in the cgi-bin directory on your webserver, and then use the squidGuard "redirect" rule in /etc/squidguard.conf to display it - see for details. An example from my config looks like this:


Hope this helps.

EDIT: You may also want to look at the later version of this script, which you can find in the samples directory of the latest squidGuard source (

Last edited by cliffordw; 05-17-2012 at 02:40 AM.
Old 05-17-2012, 02:32 AM   #3
Satyaveer Arya
Senior Member
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
This is a perl script and you can run a perl script using this commmand-

# /usr/bin/perl
But before this you have to save the file in .pl extension.

And for step by step configuration of squidGuard you can check here.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to make page numbering start on a certain page in or LibreOffice Writer LXer Syndicated Linux News 0 02-13-2012 04:30 AM
SquidGuard: include some config file in squidGuard.conf toure32 Linux - Server 1 04-12-2011 02:10 PM
SquidGuard doesn't work! gubak Linux - Server 13 12-17-2009 03:58 AM
Help redirecting blocked user to page landysaccount Linux - Newbie 1 02-21-2009 11:10 AM
how to Change TCP_MISS/403 to TCP_DENIED whn the page is redirected by squidguard msivasakthi Linux - Software 0 02-20-2008 05:20 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:11 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration