Guide to setup a proxy server with squid on fedora 13
Introduction
Well this is very much depends of what you actually want to achieve with a proxy server. An open proxy server or a restricted proxy server. An open proxy is just to cache all the data and information to the local hard disk of the proxy server without any restrictions applied, meaning that, user can go to whatever website they want and whatever service they like. For eg. ftp service. One good thing is that, you will save a lot of bandwidth when using a proxy server. While a restricted proxy means that there are some restriction applied to the proxy and it can be some rules applied that certain website or ip address, certain ports or even the downloading of certain file extension can be blocked by using a squid proxy.
Requirement
Well you will need at least a PC to do this and it depends on the no. of clients who is going to connect to this machine.
2 network interface cards, one is for connecting to the Internet and another for your LAN and last but not least a Fedora Installer of course.
Steps
1. Boot up system using the Fedora 13 live media.
2. The system will boot up until a login screen. Select login temporary and click login.
3. Double click on the Install to hard drive option found on the desktop icon.
4. Select the preferred language then click on next.
5. Select Basic Storage if you are on sata or ide drive.
6. Enter a hostname for your computer. eg proxyserver
7. Select your timezone.
8. Key in the root password
9. Select Replace Existing Linux System, this is most common option if you are using a new harddisk and do not want to create customized a partition on your own. Basically the system will auto partition for you.
10. The system will start to install and you will see this screen when it is done.
11. Once it is all setup, reboot once to make sure everything is running fine.
12. Log in Fedora, click Applications then system tools and select terminal.
13. When at terminal, you will need to install squid using yum, but first you must be root to do this. Key in su at # prompt and key in the root password that you have created during the installation of Fedora.
14. Type yum -y install squid. Note that you must connect to the internet to do this.
15. After yum has finished installing squid, goto squid config directory by keying in cd /etc/squid
16. Edit squid config file by keying in vi squid.conf
17. You need to at least tell squid what is your local LAN ip address to allow your LAN client to connect to squid. Locate the line acl localnet and key in acl localnet src 192.168.1.0/24 - (change this to your ip subnet) then press the Esc key and followed by a : then wq to save the file and exit.
18. You will need to restart squid to reload the config file by issuing the command service squid restart. For open proxy without restriction, the above is good enough.
19. As for applying restrictions, edit squid.conf again and locate the acl Safe_ports line and you can start adding policies after the acl Safe_ports port 777, below are a lists of restriction that may apply to your environment:
acl BAD_IP dst "/etc/squid/bad_ip"
acl msnmime req_mime_type ^application/x-msn-messenger
acl msngw url_regex -i gateway.dll
acl numeric_IPs urlpath_regex ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+
acl skype url_regex ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+
acl BAD_DOMAINS dstdom_regex -i "/etc/squid/bad_domains"
acl blockfiles urlpath_regex "/etc/squid/blocks.files.acl"
Explanation
Line 1 is for you to key in all the ip addresses that you may want to block.
Line 2 & 3 line is for you to restrict user from logging in to MSN chat
Line 4 & 5 line is for you to restrict user from logging in to skype
Line 6 is for you to block domain names or any keyword that appear in the search engine.
Line 7 is for you to block the downloading of certain file ext. For eg. .mp3
20. Once you have key in the acl then locate the line http_access deny manager and start adding the http_access deny for the above to apply for the restrictions.
For eg.
http_access deny BAD_IP
http_access deny msnmime
http_access deny msngw
http_access deny connect numeric_IPs all
http_access deny connect skype all
http_access deny BAD_DOMAINS
http_access deny blockfiles
21. Save and quit squid.conf file and create the file bad_ip, bad_domains and blocks.files.acl in /etc/squid/ directory.
The content of the file blocks.files.acl should be something shown below:
\. [Mm] [Pp] 3$
The content of the file bad_domains should be something shown below:
skype.com
msn
The content of the file bad_ip should be something shown below:
64.4.13.0/24 #MSN
207.46.104.0/24 #MSN
216.239.37.125 #gtalk
72.14.253.125 #gtalk
72.14.217.189 #gtalk
209.85.137.125 #gtalk
98.136.48.227 #yahoo chat
98.136.48.236 #yahoo chat
98.136.48.244 #yahoo chat
98.136.48.171 #yahoo chat
98.136.48.216 #yahoo chat
98.136.48.218 #yahoo chat
98.136.48.219 #yahoo chat
98.136.48.223 #yahoo chat
98.136.48.229 #yahoo chat
216.155.194.30 #yahoo chat
22. Once this is done just reload squid using the command service squid reload and you can start testing out your squid proxy server.