Installing Squid Cache for Windows

Linux users mostly already know Squid proxy server as the best and most used proxy server. As on my previous post “Bandwidth Shaping Using Squid Cache and WIPFW” I need a free proxy server for my windows server. I found SquidNT which is ported from its Linux version by Guido Serassio.

You can download SquidNT from Acme Consulting’s website or here. If you want to do bandwidth shaping then you must download SquidNT with Delay Pool version. On this installation guide, I use the Delay Pool version as I want to do bandwidth shaping.

Step 1: download SquidNT Delay Pool version here

Step 2: extract the zip file and put it on C: drive

Step 3: configure the squid.conf file on /etc folder. There is squid.conf.default you can rename it to squid.conf and edit it.

Step 4: configure the DNS nameserver. On squid.conf find:

# TAG: dns_nameservers
# Use this if you want to specify
# a list of DNS name servers (IP addresses)
# to use instead of those given in your
# /etc/resolv.conf file.
#
# Example: dns_nameservers 10.0.0.1 192.172.0.4
#
#Default:
# none
dns_nameservers 192.168.0.1

To find what is your nameserver is type: ipconfig on command prompt and find the IP number on Default Gateway field. Copy it to your squid.conf file like above.

Step 5: setup ACL

# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from
# where browsing should be allowed
#acl our_networks src 192.168.1.0/24 192.168.2.0/24
#http_access allow our_networks
acl our_networks src 192.168.0.0/16
http_access allow our_networks

Here you can setup which network that allowed to use your proxy server. From ipconfig command you can find out what is your IP address, usually it have 192.168.0.x format so you can apply the configuration above.

Step 6: Setup the hostname

# TAG: visible_hostname
# If you want to present a special hostname …
# then define this. Otherwise, the return …
# will be used. If you have multiple caches …
# get errors about IP-forwarding you must …
# names with this setting.
#
#Default:
# none
visible_hostname localhost

Here you can define the name for your hostname, for example you can use “localhost” or “server.youdomain.com”

Step 7: Setup cache directory

Run this command from command prompt: c:\squid\sbin\squid -D -z

Step 8: On Windows XP/2000/2003 you can setup SquidNT as a service

Run this command from command prompt: c:\squid\sbin\squid -i

You can start/stop/restart the service called Squid from: Control Panel > Administrative Tools > Services

Step 9: Setup your browser to use proxy server

For Internet Explorer users, go to: Tools > Internet Options. Select Connection tab and click on LAN Settings

On the pop up window you’ll find proxy box, give a check on “Use a proxy server for your LAN…” and fill your server’s IP (where you install SquidNT) on the address field and fill “3128” on port field. 3128 is the default port for SquidNT.

Click Ok to save the configuration. Now try to open a web page and see if you can open it. If you can then the configuration is set correctly.

Step 10: Setup the Delay Pool.

As I want to do bandwidth shaping then I needs to setup the Delay Pool. Here is the configuration:

#
#Default:
# delay_pools 0
delay_pools 1
delay_class 1 1

Then create delay_access:

# delay_access 2 allow lotsa_little_clients
# delay_access 2 deny all
#
#Default:
# none
delay_access 1 allow our_networks
delay_access 1 deny all

Now we setup how much bandwidth we want to allocate. For example, you have 384 Kbps ADSL connection which means you can download at around 40KB/s. Now you want to shape the maximum to around 30KB/s download rate, here is the configuration:

#
#delay_parameters 2 32000/32000 8000/8000 600/8000
#
# There must be one delay_parameters line for each delay pool.
#
#Default:
# none
delay_parameters 1 30000/30000

Step 11: Restart the Squid service from: Control Panel > Administrative Tools > Services

Done! Now you have 30KB/s for browsing and another 10KB/s reserved for other internet connection like chatting or streaming radio :)

121 thoughts on “Installing Squid Cache for Windows”

  1. i am providing interne services to 20 user ok i configure squid proxy server in linux it is working fine on client side browsing is fine msn messenger working fine issue comes when client is using torrent or P2P sofware,

    P2p and torrent are not connecting so i decided to configure transperent proxy but i am unable to configure on linux then i search the Squid Nt read your article now squid is working fine as proxy server But when i direct the connect Eg no setting on Client side then it is not working no browsing no thing and when i set setting in explorer proxy setting then its working mean that squid is working as a proxy not transperent proxy i want to make every thing direct i am 2 LAn one connected to the DSL other to the internal network my BM port forwarding is not working

  2. Hello i have lease line (configure win 2003 server as router for share)

    how could i see the log if the services are not running this is the error comes in front when i start the services

    Could not start the SquidNT service on Local Computer.
    Error 1067: The process terminated unexpectedly

    Error 1067

    1. the configuration here is allowing access to the proxy server from local network, see step 5:

      acl our_networks src 192.168.0.0/16
      http_access allow our_networks

      if your network not using 192.168.x.x IP configuration then you have to change it.

      then follow step 9 on each of your client PCs

  3. Hello
    I got the error DNS lookup fail when start service in Windows server 2003 how should i do:
    009/09/28 12:24:03| Starting Squid Cache version 2.7.STABLE5 for i686-pc-winnt…
    2009/09/28 12:24:03| Running as Squid Windows System Service on Windows Server 2003
    2009/09/28 12:24:03| Service command line is:
    2009/09/28 12:24:03| Process ID 2272
    2009/09/28 12:24:03| With 2048 file descriptors available
    2009/09/28 12:24:03| With 2048 CRT stdio descriptors available
    2009/09/28 12:24:03| Windows sockets initialized
    2009/09/28 12:24:03| Using select for the IO loop
    2009/09/28 12:24:03| Performing DNS Tests…
    FATAL: ipcache_init: DNS name lookup tests failed.
    Squid Cache (Version 2.7.STABLE5): Terminated abnormally.

  4. Hi Markus,

    I have tried already using your suggestion, but still not effected if user download any file such as mp3. the speed still higher then i specified in squid.conf.

    FYI: I install squid in win server 2000.

    Thank you

    1. hi, i managed to install squid on windows 2008, the proxy works fine, when i install the BDM it redirects the http requests to the squid, but the squid wont give a reply.

      i do get bunch of messages:
      1274344238.652 60326 127.0.0.1 TCP_MISS/302 431 GET http://www.google.co.il/url? – DIRECT/74.125.43.104 text/html
      1274344370.044 63219 127.0.0.1 TCP_MISS/504 1520 GET http://markus.revti.com/2007/06/installing-squid-cache-for-windows/ – DIRECT/64.120.141.148 text/html
      1274344544.656 62938 127.0.0.1 TCP_MISS/504 1477 GET http://www.softperfect.com/products/bandwidth/ – DIRECT/216.92.24.234 text/html
      1274344588.017 63033 127.0.0.1 TCP_MISS/504 1457 GET http://www.softperfect.com/download/ – DIRECT/216.92.24.234 text/html
      1274344588.314 62877 127.0.0.1 TCP_MISS/504 1457 GET http://www.softperfect.com/download/ – DIRECT/216.92.24.234 text/html
      1274344588.517 62877 127.0.0.1 TCP_MISS/504 1457 GET http://www.softperfect.com/download/ – DIRECT/216.92.24.234 text/html

      please assist,
      thanks in advance
      Sagi

      1. HTTP error 504:

        504 Gateway Timeout
        The server was acting as a gateway or proxy and did not receive a timely request from the upstream server.

        make sure the gateway/proxy server can reach the internet.

  5. Thanks for this great guide markus, i could successfully install squidnt on a mini-home server i’ve got to store backups, as an internet bridge etc. However, i have my c: drive frozen for protection from malware and other malicious software. I installed squidnt on another partition though (after fighting with the installation for the paths) so the frozen state of my c: drive would not affect squid. But my question is, is installing squid on my d: drive enough or do you think it might not keep some configuration files that would make the cache info useless? (since squid is a service and i assume services are on the c: drive) the squid.conf, and all the other configuration files under the squid folder are on the d: drive.

    Thanks :)

  6. Hello thanks for your excellent guide, I´m a new squid user and have been trying to installing in my windows 2003 server, but when i add the acl : acl our_networks src 192.168.0.0/16, and the line: http_access allow our_networks, the service no start, when you refer to our_networks it means the name of my work_group? in my case MICROTEL, sorry about my english I´m from Colombia.
    Thank for what yo can do for me.

    1. acl our_networks src 192.168.0.0/16
      http_access allow our_networks

      our_networks = is the name of the acl and not your windows network. you should check the log files to see what went wrong

  7. hi : do you know what is going on?
    sbin.sqid.exe.log

    2010/08/15 10:10:49| aclParseIpData: WARNING: Netmask masks away part of the specified IP in ‘10.1.1.3/24’
    2010/08/15 10:10:49| parseConfigFile: squid.conf:3478 unrecognized: ‘delay_pools’
    2010/08/15 10:10:49| parseConfigFile: squid.conf:3479 unrecognized: ‘delay_class’
    2010/08/15 10:10:49| parseConfigFile: squid.conf:3540 unrecognized: ‘delay_access’
    2010/08/15 10:10:49| parseConfigFile: squid.conf:3541 unrecognized: ‘delay_access’
    2010/08/15 10:10:49| parseConfigFile: squid.conf:3603 unrecognized: ‘delay_parameters’

    is the first line that use 10.1.1.3 to 10.1.1.24 ip as client ip only?

    the other few lines, i have no idea…

    1. also, i don’t know squid is working or not, when i enable proxy, i set 10.1.1.10 (my ip) as proxy, prot 3128, it is ok to connect to internet, but when i disable proxy, it still can connect to internet, is this ok?
      how can i setup to: client must using proxy to connect internet, else no connection. ??

      please help, thanks

      1. if what you mean by disabling proxy is from your browser then it’s correct behavior. that means your browser is connecting to the internet directly and not via proxy..

        if you stop the proxy service and still able to connect although on your browser’ configuration is still set to use proxy then this is unlikely to happens. you should get an error message that saying the proxy is denying the connection.

  8. can u help me on the delay pool regarding bandwidth shaping of streaming videos and downloads, i have this but it doesnt seem to work. can u please look at it and tell me what have i done wrong. thanks.

    acl files url_regex -i .flv .avi .wmv .mpg .mpeg .mpe .divx .mov
    .qt .mp3 .wav .ram .rm .rar .zip .gz .bz2 .iso .exe .rpm .deb .raw
    acl files url_regex -i youtube.com
    delay_pools 1
    delay_class 1 1
    delay_parameters 1 56000/56000
    delay_access 1 allow files youtube

    AND Here is my whole squid.conf

    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 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 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

    http_access allow manager localhost
    http_access deny manager

    http_access deny !Safe_ports

    http_access deny CONNECT !SSL_ports

    acl our_networks src 192.168.0.100/24 192.168.0.199/24
    http_access allow our_networks

    http_access deny all

    icp_access allow localnet
    icp_access deny all

    http_port 192.168.0.xxx:3128

    hierarchy_stoplist cgi-bin ?

    cache_mem 500 MB

    maximum_object_size_in_memory 10 MB

    cache_dir ufs c:/squid/var/cache 7000 16 512

    maximum_object_size 8192 KB

    access_log c:/squid/var/logs/access.log squid

    refresh_pattern ^ftp: 1440 20% 10080
    refresh_pattern ^gopher: 1440 0% 1440
    refresh_pattern -i \.(gif|png|jpg|jpeg|ico)$ 10080 90% 43200 override-expire ignore-no-cache ignore-no-store ignore-private
    refresh_pattern -i \.(iso|avi|wav|mp3|mp4|mpeg|swf|flv|x-flv)$ 43200 90% 432000 override-expire ignore-no-cache ignore-no-store ignore-private
    refresh_pattern -i \.(deb|rpm|exe|zip|tar|tgz|ram|rar|bin|ppt|doc|tiff)$ 10080 90% 43200 override-expire ignore-no-cache ignore-no-store ignore-private
    refresh_pattern -i \.index.(html|htm)$ 0 40% 10080
    refresh_pattern -i \.(html|htm|css|js)$ 1440 40% 40320
    refresh_pattern -i youtube.com/.* 10080 90% 43200
    refresh_pattern -i facebook.com/.* 10080 90% 43200
    refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
    refresh_pattern . 0 40% 40320

    acl shoutcast rep_header X-HTTP09-First-Line ^ICY\s[0-9]
    upgrade_http0.9 deny shoutcast

    acl apache rep_header Server ^Apache
    broken_vary_encoding allow apache

    visible_hostname localhost

    acl files url_regex -i .flv .avi .wmv .mpg .mpeg .mpe .divx .mov
    .qt .mp3 .wav .ram .rm .rar .zip .gz .bz2 .iso .exe .rpm .deb .raw
    acl files url_regex -i youtube.com
    delay_pools 1
    delay_class 1 2
    delay_parameters 1 56000/56000
    delay_access 1 allow files youtube
    dns_nameservers 192.168.0.1

    coredump_dir c:/squid/var/cache

  9. how about using 2 connection at the same time? what i want to do is browsing use my modem (1st connection) and i still can do my works that use Office’s LAN (2nd connection) which it should be a full connection.

  10. Having a problem with Google search when I installed Squid following your instructions:

    ERROR
    The requested URL could not be retrieved

    While trying to process the request:

    GET /search?q=where&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&safe=active HTTP/1.1
    Host: http://www.google.com
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Proxy-Connection: keep-alive
    Cookie: PREF=ID=1e62c30140e82e07:U=fc39a1053e09d45b:FF=0:TM=1288614717:LM=1288614746:S=nZ65DIKuAiQ0Afhr; NID=40=N9e1uDnrsZk1vpsWza6pOL9DhjCUyGJ6uswFgzYUSdvgJWY02bn1tky40TzTWyo6G8MxLoSqAuMYo6Q716VOvQEtsatdyHqZ7Sjg8mRCqRwJ3NveobZem-fzpmL5QkxW; SID=DQAAAJ0AAACng52Tu70efrb5o54pw8sX62DtzqRihRRL6cCjvtVwQ5sOGKfAd_c0DJHpvYEtdqEJlRkkByn3lejx_Kl9azP2Uw0B82MGs51IS-lYwEEw8iKtkb10lNDBpnvbg4l4kfbSWNtEVllyT17j6idGoFr7S1nk_4W8dWLu-OSMO603hXwk4RaueknDDjemYuokUUwNWOSX_3836HUpYHOVT-Nc; HSID=AJHhh5CGt3KGld7_R

    The following error was encountered:

    * Invalid Request

    Some aspect of the HTTP Request is invalid. Possible problems:

    * Missing or unknown request method
    * Missing URL
    * Missing HTTP Identifier (HTTP/1.0)
    * Request is too large
    * Content-Length missing for POST or PUT requests
    * Illegal character in hostname; underscores are not allowed

    Your cache administrator is webmaster.
    Generated Tue, 02 Nov 2010 04:55:41 GMT by squidhost (squid/2.7.STABLE8)

  11. When I try to install squid with the above steps, at step 7 and 8 I get the following error on command window:

    C:\squid\sbin>squid -D -z
    FATAL: Unable to open configuration file: c:/squid/etc/squid.conf: (2) No such f
    ile or directory
    Squid Cache (Version 2.7.STABLE5): Terminated abnormally.
    CPU Usage: 0.000 seconds = 0.000 user + 0.000 sys
    Maximum Resident Size: 0 KB
    Page faults with physical i/o: 0

    abnormal program termination

    C:\squid\sbin>squid -i
    CreateService failed

    How can I deal with this?

Leave a Reply

Your email address will not be published. Required fields are marked *