SQUID PROXY SERVER

HMM, Now it is time to create a caching server using squid proxy open source project

sudo apt install squid

sudo systemctl enable --now squid

the configuration file is stored in /etc/squid

touk@ubuntu:/etc/squid$ tree
.
├── conf.d
│   ├── debian.conf
│   └── local.conf
├── errorpage.css
└── squid.conf

1 directory, 4 files

For simplicity, we’ll create our customize config file in conf.d, and as you can see i have local.conf file under the conf.d directory

touk@ubuntu:/etc/squid/conf.d$ cat local.conf
http_port 8080
cache_dir ufs /var/spool/squid 100 16 256

Here, I have setup squid to use port 8080, and use it as my caching server

ufs: i am using unified file system, you can specify the type of your file system like if it is ext4, xfs etc

this will work only for my local host because i need to create some acl and decide which clients will use it

sudo systemctl restart squid

squid will use the default port 3128 by default ( other ports are in UNCONN state)

touk@ubuntu:/etc/squid/conf.d$ sudo ss -tunap | less -s | grep 8080
tcp    LISTEN  0       256                                             *:8080                                              *:*                                   users:(("squid",pid=117073,fd=17))
touk@ubuntu:/etc/squid/conf.d$ sudo ss -tunap | less -s | grep squid
udp    UNCONN  0       0                                         0.0.0.0:53267                                       0.0.0.0:*                                   users:(("squid",pid=117073,fd=9))
udp    UNCONN  0       0                                               *:38167                                             *:*                                   users:(("squid",pid=117073,fd=5))
udp    ESTAB   0       0                                           [::1]:48837                                         [::1]:47244                               users:(("squid",pid=117073,fd=20))
tcp    LISTEN  0       256                                             *:8080                                              *:*                                   users:(("squid",pid=117073,fd=17))
tcp    LISTEN  0       256                                             *:3128                                              *:*                                   users:(("squid",pid=117073,fd=18))

And sure enough, from the access logs i can see my caching is working perfect:

root@ubuntu:/etc/squid/conf.d# tail -f /var/log/squid/access.log
1693403379.468 293103 127.0.0.1 TCP_TUNNEL/200 2459 CONNECT incoming.telemetry.mozilla.org:443 - HIER_DIRECT/34.120.208.123 -
1693403379.468 293171 127.0.0.1 TCP_TUNNEL/200 5155 CONNECT incoming.telemetry.mozilla.org:443 - HIER_DIRECT/34.120.208.123 -
1693403381.469 171233 127.0.0.1 TCP_TUNNEL/200 5919 CONNECT adservice.google.dz:443 - HIER_DIRECT/142.251.143.98 -
1693403381.469 289049 127.0.0.1 TCP_TUNNEL/200 6976 CONNECT googleads.g.doubleclick.net:443 - HIER_DIRECT/142.251.143.162 -
1693403381.469 171521 127.0.0.1 TCP_TUNNEL/200 8278 CONNECT adservice.google.com:443 - HIER_DIRECT/142.251.143.162 -
1693403390.429 175780 127.0.0.1 TCP_TUNNEL/200 18484 CONNECT encrypted-tbn0.gstatic.com:443 - HIER_DIRECT/142.251.143.206 -
1693403391.429 171131 127.0.0.1 TCP_TUNNEL/200 8341 CONNECT id.google.com:443 - HIER_DIRECT/142.251.143.131 -
1693403391.429 286197 127.0.0.1 TCP_TUNNEL/200 18109 CONNECT www.gstatic.com:443 - HIER_DIRECT/142.251.143.99 -
1693403392.429 294374 127.0.0.1 TCP_TUNNEL/200 1654131 CONNECT www.google.com:443 - HIER_DIRECT/142.251.143.100 -
1693403478.431 171006 127.0.0.1 TCP_TUNNEL/200 5449 CONNECT contile.services.mozilla.com:443 - HIER_DIRECT/34.117.237.239 -

Last updated