Installing and configuring Squid



This guide walks you through setting up a Proxy server on a Ubuntu box via Squid.

install Squid:

<?php
sudo apt
-get install squid
?>

Configuring Squid:

When Squid is installed, it will try to run and it will probably fail.

First, backup the default configuration file for Squid and make a new one.

<?php
sudo cp 
/etc/squid/squid.conf /etc/squid/squid.conf.backup
sudo rm 
/etc/squid/squid.conf
sudo vi 
/etc/squid/squid.conf
?>

Below is a basic configuration file for Squid you can use for squid.conf:

<?php
# # General Setup
http_port 3128
icp_port 3130
htcp_port 4827
visible_hostname server_hostname 
#Replace "server_hostname" with the hostname of your Ubuntu machine

cache_mem 16 MB
refresh_pattern 
0 208640
hierarchy_stoplist cgi
-bin ?
acl QUERY urlpath_regex cgi-bin ?
no_cache deny QUERY

acl www_ports src 80 443
acl ftp_ports src 21
acl localhost src 127.0.0.1
/32
acl all src 0.0.0.0
/0.0.0.0
acl manager proto cache_object
acl CONNECT method CONNECT
acl PURGE method PURGE

http_access allow manager localhost
http_access deny manager
http_access allow PURGE localhost
http_access deny PURGE

# HTTP Access
# Allows access to HTTP(S) webpages. Comment these lines out if you don't want to allow access to HTTP(S) webpages.
acl wwwusers src 0.0.0.0/0.0.0.0
http_access allow all all
?>

Be sure to replace "server_hostname" with the hostname of your Ubuntu machine. If you don't know (or can't remember) just use the following command.

<?php
hostname
?>

Now you have to create the cache files for squid:

<?php
sudo squid 
-z
?>

Restart Squid

<?php
sudo 
/etc/init.d/squid start
?>