[Day 4] 6. SQUID
For this setup, we need to configure Squid as a reverse proxy. Follow the steps below:
Important: SQUID runs on port 3128 by default. Make sure that your web server is not running (Apache or Nginx)
Preparation:
-
You'll need a fresh machine for Squid setup.
-
The Squid configuration file has over 9149 lines. Check its line count using:
bashwc -l /etc/squid/squid.conf -
Backup the configuration file before editing:
bashcp /etc/squid/squid.conf /etc/squid/squid.conf.bak
Steps for Configuration:
-
Configure ACL (Access Control List):
-
Search for the
tag in the configuration file and scroll to the end of the ACL section. In Vim editor, you can useACLto search./TAG: acl -
Add the following ACL entry:
bashacl shuhari_users dstdomain <squid_ip> -
Place this above the line that says
. This tells Squid that any traffic with the destination IPacl ssl_ports port 443is associated with<squid_ip>.shuhari_users
-
-
Allow Access for shuhari_users:
-
Search for the
tag and scroll to the end of the HTTP section. In Vim editor, you can useHTTPto search./TAG: http_access -
Add this line:
bashhttp_access allow shuhari_users -
Place it above the line
. This allows thehttp_access deny !Safe_portsto pass through.shuhari_users
-
-
Set the HTTP Port for Squid:
-
Find the
section usinghttp_port. and add the following line:/TAG: http_portbashhttp_port 3128 accel defaultsite=<squid_ip> vhost -
This configures Squid to listen on port
and use reverse proxy mode (3128). Replaceaccelwith the actual Squid IP.<squid_ip>
-
-
Configure Cache Peer:
-
Search for the
section usingcache_peerand add this line to the end of this section:/TAG: cache_peerbashcache_peer <apache_ip> parent 80 0 no-query originserver name=<line_name> -
Replace
with the Apache server's IP and<apache_ip>with any name you choose.<line_name> -
The
disables caching (Internet Caching Protocol), and0indicates that this is the source server.originserver -
For the
section, add this to the end of this section:cache_peer_accessbashcache_peer_access <line_name> allow shuhari_users cache_peer_access shuhari deny all -
This allows
to access the cache peer and denies all other access (recommended for security).shuhari_users
-
-
Restart Squid:
-
After making the changes, restart Squid:
bashsudo systemctl restart squid sudo systemctl status squid
-
-
Access the Proxy:
-
To test, try accessing Squid through the browser:
plaintexthttp://<squid_ip>:3128
-
This setup configures Squid to act as a reverse proxy, forwarding requests to an Apache server. Ensure you replace placeholder values like
<squid_ip><apache_ip><line_name>Read Next
[Day 4] 7. Extra
1. **Router can have multiple Network Interface Cards (NICs):** - A router can have multiple network interfaces to connect to different net...
[Day 5] 1. Virtual Private Network (VPN)
### **What is a VPN?** A VPN (Virtual Private Network) allows a secure connection between a trusted network and another trusted network over an unt...