Install Squid on Windows Server with Access List and Cache Cygwin for Proxy Internet
Install Squid on Windows Server with Access List and Cache Cygwin
Configure Gateway in Windows server with 2 LAN Card
Set public ip with gateway and DNS in one LAN Card to have internet connection on your server.
In other LAN card you need to setup LAN IP without Gateway as 2 gateway are not possible in one machine. So workaround shall be activate Static Routing and Remote access service in windows.
Add a static route for all your LAN traffic like my internal LAN in 10.0.0.0 and gateway is 10.0.236.20 then my entry shall be
Destination: 10.0.0.0
Mask: 255.0.0.0
Gateway: 10.0.236.20
You can do the same using command line
> route add -p 10.0.0.0 mask 255.0.0.0 10.0.236.20
> route print
Now my both LAN card have been configured.
Install Squid on Windows Server with Access List and Cache Cygwin
Download the MSI from http://squid.diladele.com. Currently only 64 bit version is provided.
Install on D drive
service can be configured from task bar.
Change the port to 8080 from 3182 in squid conf file.
# Squid normally listens to port 3128
http_port 8080
Access Control List for web filtering and IP Filtering:
add following lined to acl section
##################################################################
acl bad_url dstdomain "/etc/bad-sites.acl"
acl porn_sites dstdomain '/etc/porn-sites.acl'
acl ad_sites dstdomain '/etc/ad-sites.acl'
acl banned_machines src '/etc/banned_machines.acl'
acl vip_machines src '/etc/vip_machines.acl'
acl localnet src '/etc/allowed_machines.acl' # RFC1918 possible internal network
###################################################################
add following lines to http_access section
######################################################################
http_access deny banned_machines
http_reply_access deny banned_machines
http_access deny bad_url
http_access allow porn_sites vip_machines
http_access deny porn_sites
#http_access deny ad_sites
http_access allow localnet
http_access allow localhost
######################################################################
# And finally deny all other access to this proxy
http_access deny all
Create acl file under etc folder like:
/etc/bad-sites.acl
#.google.com
.msn.com
/etc/banned_machines.acl
#10.0.254.24/255.255.255.255
10.0.254.25/255.255.255.255
/etc/allowed_machines.acl
#192.168.1.0/255.255.255.0
#10.0.254.24/255.255.255.255
#10.0.254.25/255.255.255.255
10.0.254.0/255.255.0.0
/etc/porn-sites.acl
www.spankbangc.com/
http://spankbangc.com/
http://spankbangc.com/74qv/video/faketaxi+vic+summers
spankbangc.com/
spankbangc
/etc/vip_machines.acl
#192.168.1.0/255.255.255.0
#10.0.254.24/255.255.255.255
#10.0.254.25/255.255.255.255
10.0.254.24/255.255.255.255
Enable Caching to load page faster
Add the caching directive to the config file squid.config to enable pipelining compatability, disk cache and enhanced memory cache.
####################################################
#HTTP PIPELINING
pipeline_prefetch 8 # def 0, 1+value - 11 max parallel connections on mosts ISP's
maximum_single_addr_tries 4 #def 1
read_ahead_gap 32 KB
connect_retries 8
detect_broken_pconn on
client_request_buffer_max_size 1024 KB
client_persistent_connections on
server_persistent_connections on
dead_peer_timeout 11 seconds
minimum_icp_query_timeout 50
icp_query_timeout 3500
maximum_icp_query_timeout 4000
mcast_icp_query_timeout 3500
server_idle_pconn_timeout 30 seconds
request_header_max_size 96 KB
#CACHE TWEAKS
cache_swap_low 90
cache_swap_high 95
#MEMORY CACHE
cache_mem 128 MB #default values is 128
maximum_object_size_in_memory 2048 KB #default is 512KB
#DISK CACHE
# cache_dir ufs path/to/cache/directory size_in_MB 16 256
cache_dir ufs E:/Squid/var/cache/squid 1024 16 256
maximum_object_size 4096 KB
minimum_expiry_time 90 seconds
# pictures & images
refresh_pattern -i \.(gif|png|jpeg|jpg|bmp|tif|tiff|ico)$ 10080 60% 26600 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-auth ignore-private ignore-no-store
refresh_pattern -i \.(gif|png|jpeg|jpg|bmp|tif|tiff|ico)\? 10080 60% 26600 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-auth ignore-private ignore-no-store
#flash & media
refresh_pattern -i \.(iso|avi|wav|mp3|mp4|mpeg|swf|flv|x-flv)$ 43200 95% 432000 override-expire ignore-no-cache ignore-no-store ignore-private store-stale
#to cache no-cache images and flash content and revalidate them when needed
#########################################################3
Stop the squid service
Run the squid terminal shortcut on your desktop as administrator and perform the following commands:
squid.exe -z
It will create the cache folders in Squid root directory.
Start the squid service again and your clients can access internet using
your server LAN ip with 8080 port
This is how my complete woriking squid.conf file looked for Windows server:
# # Recommended minimum configuration: # # Example rule allowing access from your local networks. # Adapt to list your (internal) IP networks from where browsing # should be allowed # Enter IP range or particular ip to allow #acl localnet src 10.0.254.0/255.255.0.0 # RFC1918 possible internal network #acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12 # RFC1918 possible internal network acl localnet src 192.168.0.0/16 # RFC1918 possible internal network acl localnet src fc00::/7 # RFC 4193 local private network range acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https 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 ################################################################## acl bad_url dstdomain "/etc/bad-sites.acl" acl porn_sites dstdomain '/etc/porn-sites.acl' acl ad_sites dstdomain '/etc/ad-sites.acl' acl banned_machines src '/etc/banned_machines.acl' acl vip_machines src '/etc/vip_machines.acl' acl localnet src '/etc/allowed_machines.acl' # RFC1918 possible internal network ################################################################### # Recommended minimum Access Permission configuration: # # Only allow cachemgr access from localhost http_access allow localhost manager http_access deny manager # Deny requests to certain unsafe ports http_access deny !Safe_ports # Deny CONNECT to other than secure SSL ports http_access deny CONNECT !SSL_ports # We strongly recommend the following be uncommented to protect innocent # web applications running on the proxy server who think the only # one who can access services on "localhost" is a local user #http_access deny to_localhost # # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS # ###################################################################### # Example rule allowing access from your local networks. # Adapt localnet in the ACL section to list your (internal) IP networks # from where browsing should be allowed ###################################################################### http_access deny banned_machines http_reply_access deny banned_machines http_access deny bad_url http_access allow porn_sites vip_machines http_access deny porn_sites #http_access deny ad_sites http_access allow localnet http_access allow localhost # And finally deny all other access to this proxy http_access deny all # Squid normally listens to port 3128 http_port 8080 # Uncomment the line below to enable disk caching - path format is /cygdrive/, i.e./cygdrive/d/squid #cache_dir aufs /cygdrive/d/squidcachedir/cache 3000 16 256 #cache_replacement_policy heap LFUDA #cache_dir aufs /cygdrive/d/Squid/var/cache/squid 150000 32 256 ######################################################## #HTTP PIPELINING pipeline_prefetch 8 # def 0, 1+value - 11 max parallel connections on mosts ISP's maximum_single_addr_tries 4 #def 1 read_ahead_gap 32 KB connect_retries 8 detect_broken_pconn on client_request_buffer_max_size 1024 KB client_persistent_connections on server_persistent_connections on dead_peer_timeout 11 seconds minimum_icp_query_timeout 50 icp_query_timeout 3500 maximum_icp_query_timeout 4000 mcast_icp_query_timeout 3500 server_idle_pconn_timeout 30 seconds request_header_max_size 96 KB #CACHE TWEAKS cache_swap_low 90 cache_swap_high 95 #MEMORY CACHE cache_mem 128 MB #default values is 128 maximum_object_size_in_memory 1024 KB #default is 512KB #DISK CACHE # cache_dir ufs path/to/cache/directory size_in_MB 16 256 cache_dir ufs E:/Squid/var/cache/squid 2048 16 256 maximum_object_size 4096 KB minimum_expiry_time 90 seconds # pictures & images refresh_pattern -i \.(gif|png|jpeg|jpg|bmp|tif|tiff|ico)$ 10080 60% 26600 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-auth ignore-private ignore-no-store refresh_pattern -i \.(gif|png|jpeg|jpg|bmp|tif|tiff|ico)\? 10080 60% 26600 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-auth ignore-private ignore-no-store #flash & media refresh_pattern -i \.(iso|avi|wav|mp3|mp4|mpeg|swf|flv|x-flv)$ 43200 95% 432000 override-expire ignore-no-cache ignore-no-store ignore-private store-stale #to cache no-cache images and flash content and revalidate them when needed ############################################# # Leave coredumps in the first cache dir coredump_dir /var/cache/squid # Add any of your own refresh_pattern entries above these. refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320 dns_nameservers 8.8.8.8 202.56.230.7 max_filedescriptors 3200
Written By:
Vinod Kotiya
Comments