Squid proxy

Main configuration file is /etc/squid/squid.conf, and mine looks like this :

#User port per which network users access proxy. Any port out of 0-1024
http_port 7777
icp_port 0
####################
forwarded_for off
####################
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY

cache_dir ufs /var/spool/squid 4000 16 256
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log

#redirect_program /usr/local/bin/squidGuard
#Redirecting program, more about it later!

redirect_children 5

ftp_list_width 64
ftp_passive on
ftp_sanitycheck on

refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320

acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8

acl SSL_ports port 5190
acl SSL_ports port 443 563
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports

redirector_access deny localhost
redirector_access deny SSL_ports

#From here on are our own ACLs
acl mine src 10.10.10.10/32
acl it src 10.10.10.0/24
##########
acl whitelists dstdomain .bla.bla.com
##########
acl mynetwork src 10.0.0.0/8
#Which files should not be downloaded
acl badfiles urlpath_regex -i \.asf$ \.avi$ \.dv$ \.flv$ \.m1v$ \.m3u$ \.mmm$ \.mov$ \.mpa$ \.mpe$ \.mpeg$ \.mpg$ \.mp2$ \.mp3$ \.qif$ \.qt$ \.qtm$ \.ra$ \.ram$ \.rm$ \.rmi$ \.rmj$ \.rmm$ \.rnx$ \.rtm$ \.rv$ \.smi$ \.smil$ \.ssm$ \.tmp$ \.temp$ \.viv$ \.vob$ \.wav$ \.wma$ \.wmv$
#If URL has there words it is forbidden
acl naughtyurl dstdom_regex -i sex pussy hardcor viagra penis vagina
###
#Allow ICQ
acl icq_domen dstdomain .icq.com .aol.com
acl icq_adresa dst 64.12.0.0/16 205.188.0.0/16
acl icq_port port 5190
acl icq_proto proto HTTPS
####
http_access allow mine
###
http_access allow whitelists
###
http_access allow it icq_adresa icq_port icq_proto CONNECT
###
http_access allow it
http_access deny badfiles all
http_access deny naughty all

deny_info ERR_CUSTOM_ACCESS_DENIED badfiles
deny_info ERR_CUSTOM_ACCESS_DENIED naughty
#=====
http_access allow mynetwork
http_access allow localhost
http_access deny all
http_reply_access allow all
icp_access allow all
#Take care, all ACL names MUST be one word, with NO special characters such as -,./|\;:+*

##################
cache_mgr root
cache_effective_user squid
cache_effective_group squid
visible_hostname proxy-2012.my.domain

coredump_dir /var/spool/squid

##########################
request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access WWW-Authenticate allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
################################

Before turning on Squid, its cache needs to be initialized (take care!!! this folder MUST exist, with following ownership and rights of access) :

# cd /var/spool
drwxr-x—. 18 squid squid 4096 Aug 22 15:50 squid

# squid -z
2013/08/22 15:21:47| WARNING: (B) ‘::/0’ is a subnetwork of (A) ‘::/0’
2013/08/22 15:21:47| WARNING: because of this ‘::/0’ is ignored to keep splay tree searching predictable
2013/08/22 15:21:47| WARNING: You should probably remove ‘::/0’ from the ACL named ‘all’
2013/08/22 15:21:47| Creating Swap Directories
2013/08/22 15:21:47| /var/spool/squid exists
2013/08/22 15:21:47| Making directories in /var/spool/squid/00
2013/08/22 15:21:47| Making directories in /var/spool/squid/01
2013/08/22 15:21:47| Making directories in /var/spool/squid/02
2013/08/22 15:21:47| Making directories in /var/spool/squid/03
2013/08/22 15:21:47| Making directories in /var/spool/squid/04
2013/08/22 15:21:47| Making directories in /var/spool/squid/05
2013/08/22 15:21:47| Making directories in /var/spool/squid/06
2013/08/22 15:21:47| Making directories in /var/spool/squid/07
2013/08/22 15:21:47| Making directories in /var/spool/squid/08
2013/08/22 15:21:47| Making directories in /var/spool/squid/09
2013/08/22 15:21:47| Making directories in /var/spool/squid/0A
2013/08/22 15:21:47| Making directories in /var/spool/squid/0B
2013/08/22 15:21:47| Making directories in /var/spool/squid/0C
2013/08/22 15:21:47| Making directories in /var/spool/squid/0D
2013/08/22 15:21:47| Making directories in /var/spool/squid/0E
2013/08/22 15:21:47| Making directories in /var/spool/squid/0F

This entry was posted in Linux and tagged , . Bookmark the permalink.

Comments are closed.